@superwall/cli 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +10 -0
  2. package/dist/{apple-z2qjOzIZ.js → apple-Dyr7OFBx.js} +17 -16
  3. package/dist/approve-Czs1-JO9.js +186 -0
  4. package/dist/{assets-DXXegdDt.js → assets-BrB9jQPQ.js} +3 -3
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +3 -3
  7. package/dist/{billing-B8tOjsnY.js → billing-D5qqIlVb.js} +3 -3
  8. package/dist/{bind-Bx9K6LwP.js → bind-B3eEcRyp.js} +4 -4
  9. package/dist/browser-Bp3yRKlU.js +36 -0
  10. package/dist/{build-Bu2kkzRe.js → build-DD9pSwHX.js} +10 -8
  11. package/dist/{client-DOgk9gAS.js → client-AI9H4GGB.js} +3 -3
  12. package/dist/{config-BO1Y87kV.js → config-CGcG7GOt.js} +9 -1
  13. package/dist/{create-B03MAuPe.js → create-B4m-IKlr.js} +8 -8
  14. package/dist/create-CJljlkJK.js +20 -0
  15. package/dist/{create-DzC_89gq.js → create-ChfgWpiM.js} +41 -69
  16. package/dist/{doctor-BGZSKY_B.js → doctor-XtXW6tKE.js} +6 -6
  17. package/dist/download-2Zu2I_Og.js +58 -0
  18. package/dist/{drivers-DqLgQxkC.js → drivers-CMEL13gp.js} +4 -4
  19. package/dist/entry.js +69 -33
  20. package/dist/{environment-i8BhiBDB.js → environment-BWT2S4qC.js} +9 -2
  21. package/dist/{existing-BPOG5zLO.js → existing-b0GxFcnc.js} +2 -2
  22. package/dist/{session-BDLQUJyV.js → git-D7AVdugb.js} +97 -335
  23. package/dist/held-CX7Zf8u-.js +17 -0
  24. package/dist/{held-C56PYMRH.js → held-D3PUNky2.js} +7 -7
  25. package/dist/install-CVUXsx8c.js +103 -0
  26. package/dist/{integrate-DZ4Qvoch.js → integrate-qvKd9pVW.js} +29 -27
  27. package/dist/{log-NVhVe_oe.js → log-C0MDCfA2.js} +1 -1
  28. package/dist/{login-p9GVEKzD.js → login-COmGHrU5.js} +2 -1
  29. package/dist/login-ClnJi1Ea.js +17 -0
  30. package/dist/{login-ONZdK8vN.js → login-PMoXUGqq.js} +9 -42
  31. package/dist/{lookup-flTi0at0.js → lookup-gjcKIZvh.js} +4 -3
  32. package/dist/{migrate-DnXpbhL1.js → migrate-SkkLLdmr.js} +33 -28
  33. package/dist/{migration-DJ1uNKhk.js → migration-DS44-3Zr.js} +10 -10
  34. package/dist/{notification-url-CCDeS5S-.js → notification-url-BjQPLf4-.js} +4 -4
  35. package/dist/{open-QdsZ_N47.js → open-DQpm2yVs.js} +2 -2
  36. package/dist/{org-BiFPjoHD.js → org-C04eAO-j.js} +3 -2
  37. package/dist/organization-BOECL3vZ.js +39 -0
  38. package/dist/orgs-D6Kk96mG.js +81 -0
  39. package/dist/{paths-yRgm5Jpa.js → paths-REb-GrbX.js} +2 -2
  40. package/dist/{playbook-B-pRKNa4.js → playbook-Du4Oydbf.js} +11 -11
  41. package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
  42. package/dist/project-CP6hiHra.js +47 -0
  43. package/dist/{promote-Djzk4C81.js → promote-Dm2_b1WK.js} +24 -19
  44. package/dist/pull-DsdOoG-D.js +36 -0
  45. package/dist/{pull-BLA9XwHj.js → pull-F6pvO4To.js} +9 -28
  46. package/dist/pull-zYAbqo9n.js +106 -0
  47. package/dist/{push-gSBxGDik.js → push-BIFLhAiO.js} +9 -7
  48. package/dist/push-CJVfvFZq.js +29 -0
  49. package/dist/push-D_l9KJZN.js +290 -0
  50. package/dist/push-SVzv7fzE.js +22 -0
  51. package/dist/{registry-D3xmWk9p.js → registry-DIJB0mJa.js} +890 -158
  52. package/dist/resolve--GsHj0Q1.js +171 -0
  53. package/dist/{resources-BTnczJCA.js → resources-BaP3p_LY.js} +3 -80
  54. package/dist/{run-C1SoizcJ.js → run-C5OPwhvS.js} +2 -2
  55. package/dist/run-CgLmD2vR.js +1345 -0
  56. package/dist/{scan-Dwk_lT5q.js → scan-Bj5y0zTZ.js} +1 -1
  57. package/dist/scan-v_WTE722.js +4 -0
  58. package/dist/{scope-Db7blD-l.js → scope-Bp_zwJOo.js} +6 -5
  59. package/dist/scope-CCb_7UvN.js +89 -0
  60. package/dist/sdk-TvT0p_nO.js +71 -0
  61. package/dist/selection-BltBpyp5.js +179 -0
  62. package/dist/series-TAixFBWW.js +685 -0
  63. package/dist/{server-Cb2N75JL.js → server-CdVIboQn.js} +10 -8
  64. package/dist/server-CvJVusw3.js +29 -0
  65. package/dist/session-B8JNXkwN.js +6 -0
  66. package/dist/session-D3fgXQBt.js +219 -0
  67. package/dist/{session-CnDJp_HO.js → session-Ywim-P8M.js} +1 -1
  68. package/dist/{setup-BLahHpgy.js → setup-zzjtTy8k.js} +9 -8
  69. package/dist/skills/index.json +5 -0
  70. package/dist/skills/superwall/SKILL.md +48 -30
  71. package/dist/skills/superwall/references/api.md +3 -2
  72. package/dist/skills/superwall-editor/SKILL.md +7 -5
  73. package/dist/skills/superwall-framework/SKILL.md +11 -8
  74. package/dist/skills/superwall-framework/references/onboarding-state.md +21 -14
  75. package/dist/skills/superwall-workspaces/SKILL.md +313 -0
  76. package/dist/skills/superwall-workspaces/references/cli.md +174 -0
  77. package/dist/skills/superwall-workspaces/references/slots.md +103 -0
  78. package/dist/{skills-zebMTZyr.js → skills-2qYaUXGE.js} +15 -9
  79. package/dist/skills-8um2fBPS.js +14 -0
  80. package/dist/{source-push-DxuJuwEf.js → source-push-kAep4gPe.js} +6 -5
  81. package/dist/{spinner-BN3U1CVB.js → spinner-BANVLncC.js} +17 -5
  82. package/dist/starter-CiLrp1cN.js +190 -0
  83. package/dist/status-CoYMK7QL.js +139 -0
  84. package/dist/{storage-VagEaaJC.js → storage-DzP22xKn.js} +1 -1
  85. package/dist/storekit-D5eopLM0.js +17 -0
  86. package/dist/{storekit-CoOf4Rvh.js → storekit-n1x0bWkQ.js} +4 -4
  87. package/dist/{telemetry-CM0BDwCK.js → telemetry-CXN6f-ZX.js} +2 -2
  88. package/dist/{token-lUUOkTJA.js → token-FmeHywYt.js} +1 -1
  89. package/dist/tools-skills/superwall/SKILL.md +49 -31
  90. package/dist/tools-skills/superwall/references/api.md +3 -2
  91. package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
  92. package/dist/tools.d.ts +1 -1
  93. package/dist/tools.js +575 -75
  94. package/dist/try-BWbzgelb.js +120 -0
  95. package/dist/{selection-u2KiKu_d.js → types-JdxmnCko.js} +1 -178
  96. package/dist/upgrade-Bk5boOgW.js +206 -0
  97. package/dist/upgrade-CoWCEnoi.js +7 -0
  98. package/package.json +5 -3
  99. package/prompts/commandments.xml +2 -0
  100. package/dist/create-BdZS_T68.js +0 -19
  101. package/dist/held-DSNUY-NZ.js +0 -16
  102. package/dist/login-Blrkm6oi.js +0 -16
  103. package/dist/push-BkMgOT6X.js +0 -24
  104. package/dist/scan-Kp-MAutK.js +0 -4
  105. package/dist/server-psYghr9K.js +0 -24
  106. package/dist/session-CehHJWZk.js +0 -6
  107. package/dist/skills-DDV4zcLR.js +0 -14
  108. package/dist/storekit-BcBb2jXB.js +0 -16
  109. package/dist/upgrade-CpTJv_M7.js +0 -7
  110. package/dist/upgrade-DZbKb67W.js +0 -117
  111. /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
  112. /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
  113. /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
  114. /package/dist/{reports-CwwKLUh0.js → reports-CuhB1_ub.js} +0 -0
  115. /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
  116. /package/dist/{storage-gRyQetN9.d.ts → storage-BjQCiTuz.d.ts} +0 -0
  117. /package/dist/{timing-BVxPrYq3.js → timing-Ca0TXY-A.js} +0 -0
@@ -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,30 @@
1
- import "./token-lUUOkTJA.js";
1
+ import "./token-FmeHywYt.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import { v as VERSION } from "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import { t as ApiError } from "./client-DOgk9gAS.js";
6
- import "./config-BO1Y87kV.js";
7
- import "./telemetry-CM0BDwCK.js";
3
+ import { x as VERSION } from "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import { t as ApiError } from "./client-AI9H4GGB.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-CXN6f-ZX.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-BN3U1CVB.js";
9
+ import "./spinner-BANVLncC.js";
10
10
  import { n as ui } from "./ui-D_qf3Gvw.js";
11
- import "./scan-Dwk_lT5q.js";
12
- import "./paths-yRgm5Jpa.js";
13
- import { _ as livePaywallVersion, x as promotePaywallVersion } from "./resources-BTnczJCA.js";
14
- import "./lookup-flTi0at0.js";
15
- import "./login-ONZdK8vN.js";
16
- import "./skills-zebMTZyr.js";
17
- import "./assets-DXXegdDt.js";
18
- import { a as resolveProjectDir, g as transition, k as readLock, s as selectSurfaces, y as collectProjectDeclarations, z as resolveFramework } from "./selection-u2KiKu_d.js";
19
- import { f as parsePlatformFlags, h as wantedPlatforms, m as targetLabel, n as requireApi, p as planTargets, v as resolveApps } from "./session-BDLQUJyV.js";
20
- import { l as resolveBinding } from "./source-push-DxuJuwEf.js";
21
- import { a as pickApplicationOption, i as timed, o as pickAdoptOption, t as group } from "./push-gSBxGDik.js";
22
- import "./login-p9GVEKzD.js";
11
+ import "./scan-Bj5y0zTZ.js";
12
+ import "./paths-REb-GrbX.js";
13
+ import "./orgs-D6Kk96mG.js";
14
+ import { _ as livePaywallVersion, x as promotePaywallVersion } from "./resources-BaP3p_LY.js";
15
+ import "./lookup-gjcKIZvh.js";
16
+ import "./login-PMoXUGqq.js";
17
+ import "./skills-2qYaUXGE.js";
18
+ import "./browser-Bp3yRKlU.js";
19
+ import "./assets-BrB9jQPQ.js";
20
+ import { a as resolveProjectDir, g as transition, s as selectSurfaces, y as resolveFramework } from "./selection-BltBpyp5.js";
21
+ import { f as readLock, n as collectProjectDeclarations } from "./types-JdxmnCko.js";
22
+ import { c as planTargets, l as targetLabel, n as requireApi, p as resolveApps, s as parsePlatformFlags, u as wantedPlatforms } from "./session-D3fgXQBt.js";
23
+ import { l as resolveBinding } from "./source-push-kAep4gPe.js";
24
+ import { a as pickApplicationOption, i as timed, o as pickAdoptOption, t as group } from "./push-BIFLhAiO.js";
25
+ import "./git-D7AVdugb.js";
26
+ import "./scope-CCb_7UvN.js";
27
+ import "./login-COmGHrU5.js";
23
28
  import pc from "picocolors";
24
29
 
25
30
  //#region src/core/paywalls/promote.ts
@@ -0,0 +1,36 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-CXN6f-ZX.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-BANVLncC.js";
10
+ import "./ui-D_qf3Gvw.js";
11
+ import "./theme-DUsCh-Vd.js";
12
+ import "./log-C0MDCfA2.js";
13
+ import "./scan-Bj5y0zTZ.js";
14
+ import "./existing-b0GxFcnc.js";
15
+ import "./paths-REb-GrbX.js";
16
+ import "./orgs-D6Kk96mG.js";
17
+ import "./resources-BaP3p_LY.js";
18
+ import "./org-C04eAO-j.js";
19
+ import "./lookup-gjcKIZvh.js";
20
+ import "./bind-B3eEcRyp.js";
21
+ import "./login-PMoXUGqq.js";
22
+ import "./skills-2qYaUXGE.js";
23
+ import "./browser-Bp3yRKlU.js";
24
+ import "./selection-BltBpyp5.js";
25
+ import "./types-JdxmnCko.js";
26
+ import "./session-D3fgXQBt.js";
27
+ import "./git-D7AVdugb.js";
28
+ import "./scope-CCb_7UvN.js";
29
+ import "./login-COmGHrU5.js";
30
+ import "./run-C5OPwhvS.js";
31
+ import "./drivers-CMEL13gp.js";
32
+ import "./migration-DS44-3Zr.js";
33
+ import "./setup-zzjtTy8k.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-F6pvO4To.js";
35
+
36
+ export { PullPathError, applyPulledChanges, appsToPull, boundPaywall, cloneInto, cloneTarget, mergePulledLock, pullInto, runPull };
@@ -1,31 +1,12 @@
1
- import "./token-lUUOkTJA.js";
2
- import "./output-Ggzq5_-t.js";
3
- import { v as VERSION } from "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import "./client-DOgk9gAS.js";
6
- import "./config-BO1Y87kV.js";
7
- import "./telemetry-CM0BDwCK.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-BN3U1CVB.js";
1
+ import { x as VERSION } from "./environment-BWT2S4qC.js";
10
2
  import { n as ui } from "./ui-D_qf3Gvw.js";
11
- import "./theme-DUsCh-Vd.js";
12
- import "./log-NVhVe_oe.js";
13
- import "./scan-Dwk_lT5q.js";
14
- import "./existing-BPOG5zLO.js";
15
- import "./paths-yRgm5Jpa.js";
16
- import { f as listAppPaywalls, v as mintSourceAccess } from "./resources-BTnczJCA.js";
17
- import "./org-BiFPjoHD.js";
18
- import { n as findApplication, t as appNotFound } from "./lookup-flTi0at0.js";
19
- import "./bind-Bx9K6LwP.js";
20
- import "./login-ONZdK8vN.js";
21
- import "./skills-zebMTZyr.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-u2KiKu_d.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-BDLQUJyV.js";
24
- import "./login-p9GVEKzD.js";
25
- import "./run-C1SoizcJ.js";
26
- import "./drivers-DqLgQxkC.js";
27
- import "./migration-DJ1uNKhk.js";
28
- import { a as devCommand, i as detectPackageManager } from "./setup-BLahHpgy.js";
3
+ import { f as listAppPaywalls, v as mintSourceAccess } from "./resources-BaP3p_LY.js";
4
+ import { n as findApplication, t as appNotFound } from "./lookup-gjcKIZvh.js";
5
+ import { a as resolveProjectDir, i as requireProject, y as resolveFramework } from "./selection-BltBpyp5.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-JdxmnCko.js";
7
+ import { d as PLATFORMS, f as requirePlatform, i as writeSourceBase, n as requireApi, r as readSourceBase, s as parsePlatformFlags } from "./session-D3fgXQBt.js";
8
+ import { a as collectSourceFiles, i as statIfPresent, n as pullSourceTree } from "./git-D7AVdugb.js";
9
+ import { a as devCommand, i as detectPackageManager } from "./setup-zzjtTy8k.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,106 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-CXN6f-ZX.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-BANVLncC.js";
10
+ import "./ui-D_qf3Gvw.js";
11
+ import "./theme-DUsCh-Vd.js";
12
+ import "./log-C0MDCfA2.js";
13
+ import "./scan-Bj5y0zTZ.js";
14
+ import "./existing-b0GxFcnc.js";
15
+ import "./paths-REb-GrbX.js";
16
+ import "./orgs-D6Kk96mG.js";
17
+ import "./resources-BaP3p_LY.js";
18
+ import "./org-C04eAO-j.js";
19
+ import "./lookup-gjcKIZvh.js";
20
+ import "./bind-B3eEcRyp.js";
21
+ import "./login-PMoXUGqq.js";
22
+ import "./skills-2qYaUXGE.js";
23
+ import "./browser-Bp3yRKlU.js";
24
+ import "./selection-BltBpyp5.js";
25
+ import "./types-JdxmnCko.js";
26
+ import "./session-D3fgXQBt.js";
27
+ import { a as collectSourceFiles, n as pullSourceTree } from "./git-D7AVdugb.js";
28
+ import { r as WORKSPACE_DERIVED_FILES } from "./scope-CCb_7UvN.js";
29
+ import "./login-COmGHrU5.js";
30
+ import "./run-C5OPwhvS.js";
31
+ import "./drivers-CMEL13gp.js";
32
+ import "./migration-DS44-3Zr.js";
33
+ import "./download-2Zu2I_Og.js";
34
+ import "./setup-zzjtTy8k.js";
35
+ import { n as applyPulledChanges } from "./pull-F6pvO4To.js";
36
+ import { C as mintSourceAccess, c as resolveWorkspace, d as readBinding, f as readSourceFile, p as writeBinding, s as projectRoot } from "./resolve--GsHj0Q1.js";
37
+ import { r as WorkspaceError } from "./project-CP6hiHra.js";
38
+ import "./organization-BOECL3vZ.js";
39
+ import "./sdk-TvT0p_nO.js";
40
+ import { a as toSourceAccess } from "./push-D_l9KJZN.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,12 +1,14 @@
1
- import { v as VERSION } from "./environment-i8BhiBDB.js";
1
+ import { x as VERSION } from "./environment-BWT2S4qC.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-BTnczJCA.js";
4
- import { n as requireAssets, r as syncAssets, t as assetBaseUrl } from "./assets-DXXegdDt.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-u2KiKu_d.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-BDLQUJyV.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-DxuJuwEf.js";
8
- import pc from "picocolors";
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-BaP3p_LY.js";
4
+ import { n as requireAssets, r as syncAssets, t as assetBaseUrl } from "./assets-BrB9jQPQ.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-BltBpyp5.js";
6
+ import { a as describeBindings, f as readLock, g as writeBindings, n as collectProjectDeclarations, p as removeBinding, r as writeProjectTypes, y as writeSnapshot } from "./types-JdxmnCko.js";
7
+ import { c as planTargets, l as targetLabel, n as requireApi, o as writeProjectScaffold, p as resolveApps, s as parsePlatformFlags, u as wantedPlatforms } from "./session-D3fgXQBt.js";
8
+ 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-kAep4gPe.js";
9
+ import { a as collectSourceFiles } from "./git-D7AVdugb.js";
9
10
  import { cpus } from "node:os";
11
+ import pc from "picocolors";
10
12
 
11
13
  //#region src/core/paywalls/binding/renames.ts
12
14
  var RenameError = class extends Error {};
@@ -0,0 +1,29 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-CXN6f-ZX.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-BANVLncC.js";
10
+ import "./ui-D_qf3Gvw.js";
11
+ import "./scan-Bj5y0zTZ.js";
12
+ import "./paths-REb-GrbX.js";
13
+ import "./orgs-D6Kk96mG.js";
14
+ import "./resources-BaP3p_LY.js";
15
+ import "./lookup-gjcKIZvh.js";
16
+ import "./login-PMoXUGqq.js";
17
+ import "./skills-2qYaUXGE.js";
18
+ import "./browser-Bp3yRKlU.js";
19
+ import "./assets-BrB9jQPQ.js";
20
+ import "./selection-BltBpyp5.js";
21
+ import "./types-JdxmnCko.js";
22
+ import "./session-D3fgXQBt.js";
23
+ import "./source-push-kAep4gPe.js";
24
+ import { i as timed, n as runPush, r as runPushPipeline, t as group } from "./push-BIFLhAiO.js";
25
+ import "./git-D7AVdugb.js";
26
+ import "./scope-CCb_7UvN.js";
27
+ import "./login-COmGHrU5.js";
28
+
29
+ export { group, runPush, runPushPipeline, timed };
@@ -0,0 +1,290 @@
1
+ import { x as VERSION } from "./environment-BWT2S4qC.js";
2
+ import { n as ApiUnreachableError, t as ApiError } from "./client-AI9H4GGB.js";
3
+ import { a as collectSourceFiles, r as pushSourceTree, t as gitAvailable } from "./git-D7AVdugb.js";
4
+ import { C as mintSourceAccess, E as startBuild, S as listWorkspaces, _ as getBuild, a as openLink, d as readBinding, f as readSourceFile, h as createWorkspace, p as writeBinding, u as visibilityOf, v as getMe } from "./resolve--GsHj0Q1.js";
5
+ import { r as WorkspaceError, s as readProject } from "./project-CP6hiHra.js";
6
+ import { n as resolveOrganization } from "./organization-BOECL3vZ.js";
7
+ import { i as warnIfSdkBehind, r as vendoredVersion } from "./sdk-TvT0p_nO.js";
8
+ import { setTimeout } from "node:timers/promises";
9
+
10
+ //#region src/core/workspaces/push.ts
11
+ const PUSH_ATTEMPTS = 3;
12
+ const POLL_INTERVAL_MS = 2e3;
13
+ const POLL_TIMEOUT_MS = 1200 * 1e3;
14
+ const POLL_FAILURES_ALLOWED = 5;
15
+ const LONGEST_WAIT_SECONDS = 300;
16
+ const DEFAULT_RETRY_AFTER_SECONDS = 60;
17
+ const RETRY_LATER_CODES = new Set(["busy", "unavailable"]);
18
+ const toSourceAccess = (access) => ({
19
+ repo: access.repo,
20
+ remote: access.remote,
21
+ branch: access.branch,
22
+ token: access.token,
23
+ tokenId: access.token_id
24
+ });
25
+ function slugOfName(name) {
26
+ const slug = name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63).replace(/-+$/, "");
27
+ if (/^[a-z][a-z0-9-]+$/.test(slug)) return slug;
28
+ return `ws-${slug || "workspace"}`.slice(0, 63).replace(/-+$/, "");
29
+ }
30
+ const isConflict = (error) => error instanceof ApiError && error.status === 409;
31
+ async function linkedWorkspace(ctx, project, org) {
32
+ const existing = readBinding(project.root);
33
+ if (existing) return existing;
34
+ const organizationId = await resolveOrganization(ctx, org);
35
+ const slug = slugOfName(project.manifest.name);
36
+ const find = async () => (await listWorkspaces(ctx.api, organizationId, slug))[0];
37
+ let workspace = await find();
38
+ if (workspace) ctx.ui.info(`Using the existing workspace \`${workspace.slug}\` in organization ${organizationId}.`);
39
+ else try {
40
+ workspace = await createWorkspace(ctx.api, organizationId, project.manifest.name, slug);
41
+ ctx.ui.success(`Created the workspace \`${workspace.slug}\`.`);
42
+ } catch (error) {
43
+ workspace = isConflict(error) ? await find() : void 0;
44
+ if (!workspace) throw error;
45
+ }
46
+ const binding = {
47
+ workspaceId: String(workspace.id),
48
+ organizationId: String(workspace.organization_id),
49
+ slug: workspace.slug
50
+ };
51
+ writeBinding(project.root, binding);
52
+ return binding;
53
+ }
54
+ var IncomingCommitsRefused = class extends Error {
55
+ constructor(commits, reason) {
56
+ super("The source repo has commits this project doesn't.");
57
+ this.commits = commits;
58
+ this.reason = reason;
59
+ }
60
+ };
61
+ const COMMITS_SHOWN = 10;
62
+ function namesOf(commits) {
63
+ const names = /* @__PURE__ */ new Map();
64
+ for (const { author, email } of commits) names.set(email || author, author || email);
65
+ const list = [...names.values()];
66
+ const last = list.pop() ?? "someone";
67
+ return list.length === 0 ? last : `${list.join(", ")} and ${last}`;
68
+ }
69
+ function incomingLines(commits) {
70
+ const shown = commits.slice(0, COMMITS_SHOWN).map((commit) => ` ${commit.sha.slice(0, 12)} ${commit.author}: ${commit.subject}`);
71
+ const more = commits.length - shown.length;
72
+ return [
73
+ "The source repo has commits this project doesn't, and this push merges them in:",
74
+ ...shown,
75
+ ...more > 0 ? [` and ${more} more`] : [],
76
+ "Their names come from the commits, which whoever pushed them could set."
77
+ ].join("\n");
78
+ }
79
+ const confirmIncoming = (ctx, input) => async (commits) => {
80
+ if (!ctx.json) ctx.ui.report(incomingLines(commits));
81
+ if (input.acceptMergedCommits) return;
82
+ if (!ctx.interactive) throw new IncomingCommitsRefused(commits, "needs_accept_merged_commits");
83
+ if (!await ctx.ui.confirm({
84
+ message: `Your copy will run commits from ${namesOf(commits)} with your reads. Push anyway?`,
85
+ initial: false
86
+ })) throw new IncomingCommitsRefused(commits, "declined");
87
+ };
88
+ async function signedInAuthor(api) {
89
+ const me = await getMe(api).catch(() => void 0);
90
+ if (!me?.email) return void 0;
91
+ return {
92
+ name: me.name || me.email,
93
+ email: me.email
94
+ };
95
+ }
96
+ function retryAfterOf(error) {
97
+ if (!(error instanceof ApiError) || error.status !== 429) return void 0;
98
+ try {
99
+ const seconds = JSON.parse(error.body ?? "{}").retry_after;
100
+ return typeof seconds === "number" && seconds > 0 ? seconds : DEFAULT_RETRY_AFTER_SECONDS;
101
+ } catch {
102
+ return DEFAULT_RETRY_AFTER_SECONDS;
103
+ }
104
+ }
105
+ async function startBuildWhenThereIsRoom(ctx, workspaceId, commitSha, tokenId, seams) {
106
+ const wait = seams.sleep ?? setTimeout;
107
+ const now = seams.now ?? Date.now;
108
+ const deadline = now() + POLL_TIMEOUT_MS;
109
+ let told = false;
110
+ for (;;) try {
111
+ return await startBuild(ctx.api, workspaceId, commitSha, tokenId);
112
+ } catch (error) {
113
+ const seconds = retryAfterOf(error);
114
+ if (seconds === void 0) throw error;
115
+ const { message } = error;
116
+ if (seconds > LONGEST_WAIT_SECONDS) throw new WorkspaceError(`${message} Trying again soon won't help, because the limit covers the last day. Your source is pushed, so run \`superwall workspaces push\` again later.`);
117
+ if (now() >= deadline) throw new WorkspaceError(`${message} There's still no room after 20 minutes. Your source is pushed, so run \`superwall workspaces push\` again later.`);
118
+ if (!told) ctx.ui.info(`${message} This will keep trying on its own, with nothing to push again.`);
119
+ told = true;
120
+ await wait(seconds * 1e3);
121
+ }
122
+ }
123
+ const isTransient = (error) => error instanceof ApiUnreachableError || error instanceof ApiError && error.status >= 500;
124
+ async function pushAndBuild(ctx, root, binding, files, input, seams) {
125
+ let current = binding;
126
+ const incoming = [];
127
+ const author = await signedInAuthor(ctx.api);
128
+ for (let attempt = 1;; attempt++) {
129
+ const access = await mintSourceAccess(ctx.api, current.workspaceId);
130
+ const pushed = await pushSourceTree({
131
+ access: toSourceAccess(access),
132
+ base: current.syncedCommit,
133
+ reviewed: current.reviewedCommit,
134
+ overwrite: input.overwriteSource,
135
+ confirmIncoming: confirmIncoming(ctx, input),
136
+ ...author ? { author } : {},
137
+ files,
138
+ message: {
139
+ kind: "workspace",
140
+ surface: current.slug,
141
+ workspaceId: current.workspaceId,
142
+ sdk: vendoredVersion(root),
143
+ cli: VERSION,
144
+ note: input.m
145
+ }
146
+ });
147
+ incoming.push(...pushed.incoming ?? []);
148
+ current = {
149
+ ...current,
150
+ ...pushed.syncedTo ? { syncedCommit: pushed.syncedTo } : {},
151
+ ...pushed.commitSha ? { reviewedCommit: pushed.commitSha } : {}
152
+ };
153
+ writeBinding(root, current);
154
+ try {
155
+ const build = await startBuildWhenThereIsRoom(ctx, current.workspaceId, pushed.commitSha, access.token_id, seams);
156
+ return {
157
+ pushed: {
158
+ ...pushed,
159
+ incoming
160
+ },
161
+ build,
162
+ binding: current
163
+ };
164
+ } catch (error) {
165
+ if (attempt >= PUSH_ATTEMPTS || !isConflict(error)) throw error;
166
+ ctx.ui.info(/token/i.test(error.message) ? "This push's token ran out. Pushing again." : "Someone pushed at the same moment. Pushing again on top of them.");
167
+ }
168
+ }
169
+ }
170
+ async function waitForBuild(api, first, seams, onProgress) {
171
+ const wait = seams.sleep ?? setTimeout;
172
+ const now = seams.now ?? Date.now;
173
+ const deadline = now() + POLL_TIMEOUT_MS;
174
+ let build = first;
175
+ let failures = 0;
176
+ for (;;) {
177
+ await wait(POLL_INTERVAL_MS);
178
+ try {
179
+ build = await getBuild(api, build.workspace_id, build.version_id);
180
+ failures = 0;
181
+ } catch (error) {
182
+ failures += 1;
183
+ if (!isTransient(error) || failures > POLL_FAILURES_ALLOWED) throw error;
184
+ }
185
+ onProgress(build);
186
+ if (build.status === "succeeded" || build.status === "failed") return {
187
+ finished: true,
188
+ build
189
+ };
190
+ if (now() >= deadline) return {
191
+ finished: false,
192
+ build
193
+ };
194
+ }
195
+ }
196
+ const buildSummary = (workspace, pushed, build, url) => ({
197
+ workspace_id: Number(workspace.workspaceId),
198
+ slug: workspace.slug,
199
+ version_id: build.version_id,
200
+ commit_sha: build.commit_sha,
201
+ source: pushed.status,
202
+ status: build.status,
203
+ step: build.step,
204
+ failure: build.failure,
205
+ steps: build.steps,
206
+ merged_commits: pushed.incoming ?? [],
207
+ url
208
+ });
209
+ function refusedPush(ctx, { commits, reason }) {
210
+ if (ctx.json) ctx.output.data({
211
+ pushed: false,
212
+ reason,
213
+ merged_commits: commits
214
+ });
215
+ else if (reason === "declined") {
216
+ ctx.ui.outro("Nothing was pushed. Run `superwall workspaces pull` to read them first.");
217
+ return;
218
+ } else ctx.ui.error(`Nothing was pushed. Your copy would run commits from ${namesOf(commits)} with your reads. Run \`superwall workspaces pull\` to read them first, or pass --accept-merged-commits.`);
219
+ ctx.fail();
220
+ }
221
+ async function runWorkspacePush(ctx, input, seams = {}) {
222
+ const project = readProject(input.dir);
223
+ await warnIfSdkBehind(ctx.ui, project.root, seams.fetchVersion);
224
+ if (!await (seams.hasGit ?? gitAvailable)()) throw new WorkspaceError("`superwall workspaces push` uses git to send your source. Install git, then try again.");
225
+ const checked = await collectSourceFiles(project.root, readSourceFile);
226
+ if (!checked.ok) throw new WorkspaceError(checked.reason);
227
+ const linked = await linkedWorkspace(ctx, project, input.org);
228
+ const collected = await collectSourceFiles(project.root, readSourceFile);
229
+ if (!collected.ok) throw new WorkspaceError(collected.reason);
230
+ let result;
231
+ try {
232
+ result = await pushAndBuild(ctx, project.root, linked, collected.files, input, seams);
233
+ } catch (error) {
234
+ if (!(error instanceof IncomingCommitsRefused)) throw error;
235
+ refusedPush(ctx, error);
236
+ return;
237
+ }
238
+ const { pushed, build: started, binding } = result;
239
+ const link = await openLink(ctx, {
240
+ id: Number(binding.workspaceId),
241
+ organization_id: Number(binding.organizationId),
242
+ slug: binding.slug
243
+ }, project.manifest);
244
+ const { url } = link;
245
+ const spin = ctx.ui.spinner();
246
+ spin.start(`Building version ${started.version_id}`);
247
+ const wait = started.status === "succeeded" || started.status === "failed" ? await waitForBuild(ctx.api, started, {
248
+ ...seams,
249
+ sleep: async () => void 0
250
+ }, () => {}) : await waitForBuild(ctx.api, started, seams, (build$1) => {
251
+ if (build$1.step) spin.message(`Building version ${build$1.version_id}: ${build$1.step}`);
252
+ });
253
+ const { build } = wait;
254
+ const summary = buildSummary(binding, pushed, build, url);
255
+ if (!wait.finished) {
256
+ spin.stop(`Version ${build.version_id} is still building`);
257
+ if (ctx.json) ctx.output.data(summary);
258
+ else ctx.ui.warn("It's taking longer than expected. Check it with `superwall workspaces status`.");
259
+ ctx.fail();
260
+ return;
261
+ }
262
+ if (build.status === "failed") {
263
+ spin.stop(`Version ${build.version_id} didn't build`);
264
+ if (ctx.json) ctx.output.data(summary);
265
+ else {
266
+ const where = build.step ? ` at ${build.step}` : "";
267
+ ctx.ui.error(`The build failed${where}: ${build.failure?.message ?? "the builder gave no reason."}`);
268
+ ctx.ui.info(build.failure && RETRY_LATER_CODES.has(build.failure.code) ? "It isn't your code. Run `superwall workspaces push` again in a few minutes, and it retries this version." : "See its log with `superwall workspaces logs`.");
269
+ }
270
+ ctx.fail();
271
+ return;
272
+ }
273
+ spin.stop(`Built version ${build.version_id}`);
274
+ const { visibleTo, sentence } = await visibilityOf(ctx, binding.workspaceId, build.version_id);
275
+ if (ctx.json) {
276
+ ctx.output.data({
277
+ ...summary,
278
+ visible_to: visibleTo
279
+ });
280
+ return;
281
+ }
282
+ ctx.ui.success(sentence);
283
+ if (pushed.incoming?.length) ctx.ui.warn(`It runs commits from ${namesOf(pushed.incoming)} with your reads, and they aren't in this project yet. Run \`superwall workspaces pull\` to get them.`);
284
+ ctx.ui.info(link.app ? `Open ${url} (in ${link.app})` : `Open ${url}`);
285
+ if (link.otherApps) ctx.ui.info(`For another app, run \`superwall workspaces open ${link.entrypoint} --app <id>\`.`);
286
+ ctx.ui.info("To ask for review, run `superwall workspaces share`.");
287
+ }
288
+
289
+ //#endregion
290
+ export { toSourceAccess as a, slugOfName as i, namesOf as n, waitForBuild as o, runWorkspacePush as r, IncomingCommitsRefused as t };
@@ -0,0 +1,22 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./spinner-BANVLncC.js";
8
+ import "./ui-D_qf3Gvw.js";
9
+ import "./orgs-D6Kk96mG.js";
10
+ import "./resources-BaP3p_LY.js";
11
+ import "./lookup-gjcKIZvh.js";
12
+ import "./types-JdxmnCko.js";
13
+ import "./git-D7AVdugb.js";
14
+ import "./scope-CCb_7UvN.js";
15
+ import "./download-2Zu2I_Og.js";
16
+ import "./resolve--GsHj0Q1.js";
17
+ import "./project-CP6hiHra.js";
18
+ import "./organization-BOECL3vZ.js";
19
+ import "./sdk-TvT0p_nO.js";
20
+ import { a as toSourceAccess, i as slugOfName, n as namesOf, o as waitForBuild, r as runWorkspacePush, t as IncomingCommitsRefused } from "./push-D_l9KJZN.js";
21
+
22
+ export { IncomingCommitsRefused, namesOf, runWorkspacePush, slugOfName, toSourceAccess, waitForBuild };