@superwall/cli 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/{apple-Bx_fm5M-.js → apple-Dyr7OFBx.js} +16 -15
  2. package/dist/approve-Czs1-JO9.js +186 -0
  3. package/dist/{assets-W5yvyf0V.js → assets-BrB9jQPQ.js} +3 -3
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/auth.js +3 -3
  6. package/dist/{billing-C4lXR0xG.js → billing-D5qqIlVb.js} +3 -3
  7. package/dist/{bind-82oTpHZ3.js → bind-B3eEcRyp.js} +4 -4
  8. package/dist/browser-Bp3yRKlU.js +36 -0
  9. package/dist/{build-7_8cBgBm.js → build-DD9pSwHX.js} +9 -7
  10. package/dist/{client-ltxxHuxn.js → client-AI9H4GGB.js} +3 -3
  11. package/dist/{create-Dk8U_B49.js → create-B4m-IKlr.js} +8 -8
  12. package/dist/create-CJljlkJK.js +20 -0
  13. package/dist/{create-DEyveHS6.js → create-ChfgWpiM.js} +39 -67
  14. package/dist/{doctor-Df2GwS4K.js → doctor-XtXW6tKE.js} +6 -6
  15. package/dist/download-2Zu2I_Og.js +58 -0
  16. package/dist/{drivers-CTyYdBL7.js → drivers-CMEL13gp.js} +3 -3
  17. package/dist/entry.js +25 -24
  18. package/dist/{environment-djS0ik60.js → environment-BWT2S4qC.js} +3 -2
  19. package/dist/{existing-Das3PHGG.js → existing-b0GxFcnc.js} +2 -2
  20. package/dist/{session-CV0P8BjK.js → git-D7AVdugb.js} +96 -334
  21. package/dist/held-CX7Zf8u-.js +17 -0
  22. package/dist/{held-B8EFWDEc.js → held-D3PUNky2.js} +7 -7
  23. package/dist/install-CVUXsx8c.js +103 -0
  24. package/dist/{integrate-Cz48dm_h.js → integrate-qvKd9pVW.js} +27 -25
  25. package/dist/{login-girc324T.js → login-COmGHrU5.js} +2 -1
  26. package/dist/login-ClnJi1Ea.js +17 -0
  27. package/dist/{login-CiK5T4w8.js → login-PMoXUGqq.js} +8 -41
  28. package/dist/{lookup-us5vu5od.js → lookup-gjcKIZvh.js} +3 -2
  29. package/dist/{migrate-DaVwhdov.js → migrate-SkkLLdmr.js} +30 -25
  30. package/dist/{migration-cS6UGeUj.js → migration-DS44-3Zr.js} +9 -9
  31. package/dist/{notification-url-Hg42tAbW.js → notification-url-BjQPLf4-.js} +4 -4
  32. package/dist/{open-BIuOZ9ka.js → open-DQpm2yVs.js} +2 -2
  33. package/dist/{org-BrR4HGvl.js → org-C04eAO-j.js} +3 -2
  34. package/dist/organization-BOECL3vZ.js +39 -0
  35. package/dist/orgs-D6Kk96mG.js +81 -0
  36. package/dist/{paths-CdwjySxK.js → paths-REb-GrbX.js} +1 -1
  37. package/dist/{playbook-BJ3opYIS.js → playbook-Du4Oydbf.js} +10 -10
  38. package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
  39. package/dist/project-CP6hiHra.js +47 -0
  40. package/dist/{promote-BQO-1ScY.js → promote-Dm2_b1WK.js} +23 -18
  41. package/dist/pull-DsdOoG-D.js +36 -0
  42. package/dist/{pull-BhRswq6x.js → pull-F6pvO4To.js} +9 -28
  43. package/dist/pull-zYAbqo9n.js +106 -0
  44. package/dist/{push-CR110qRh.js → push-BIFLhAiO.js} +8 -6
  45. package/dist/push-CJVfvFZq.js +29 -0
  46. package/dist/push-D_l9KJZN.js +290 -0
  47. package/dist/push-SVzv7fzE.js +22 -0
  48. package/dist/{registry-DZsWoWqH.js → registry-DIJB0mJa.js} +687 -64
  49. package/dist/resolve--GsHj0Q1.js +171 -0
  50. package/dist/{resources-BMspgZO1.js → resources-BaP3p_LY.js} +3 -80
  51. package/dist/{run-D4V6mq8_.js → run-C5OPwhvS.js} +2 -2
  52. package/dist/run-CgLmD2vR.js +1345 -0
  53. package/dist/{scan-CRexsHOE.js → scan-Bj5y0zTZ.js} +1 -1
  54. package/dist/scan-v_WTE722.js +4 -0
  55. package/dist/{scope-Ct0_HoNq.js → scope-Bp_zwJOo.js} +5 -4
  56. package/dist/scope-CCb_7UvN.js +89 -0
  57. package/dist/sdk-TvT0p_nO.js +71 -0
  58. package/dist/selection-BltBpyp5.js +179 -0
  59. package/dist/series-TAixFBWW.js +685 -0
  60. package/dist/{server-Dv1VwbNh.js → server-CdVIboQn.js} +10 -8
  61. package/dist/server-CvJVusw3.js +29 -0
  62. package/dist/session-B8JNXkwN.js +6 -0
  63. package/dist/session-D3fgXQBt.js +219 -0
  64. package/dist/{session-UiPlLFn6.js → session-Ywim-P8M.js} +1 -1
  65. package/dist/{setup-UWLhQG3M.js → setup-zzjtTy8k.js} +9 -8
  66. package/dist/skills/index.json +5 -0
  67. package/dist/skills/superwall/SKILL.md +48 -30
  68. package/dist/skills/superwall/references/api.md +3 -2
  69. package/dist/skills/superwall-editor/SKILL.md +7 -5
  70. package/dist/skills/superwall-framework/SKILL.md +7 -5
  71. package/dist/skills/superwall-workspaces/SKILL.md +313 -0
  72. package/dist/skills/superwall-workspaces/references/cli.md +174 -0
  73. package/dist/skills/superwall-workspaces/references/slots.md +103 -0
  74. package/dist/{skills-CiWxt6vS.js → skills-2qYaUXGE.js} +4 -4
  75. package/dist/{skills-DzOvse9L.js → skills-8um2fBPS.js} +8 -8
  76. package/dist/{source-push-CX_k_yZD.js → source-push-kAep4gPe.js} +6 -5
  77. package/dist/{spinner-1uuKKZMc.js → spinner-BANVLncC.js} +16 -4
  78. package/dist/starter-CiLrp1cN.js +190 -0
  79. package/dist/status-CoYMK7QL.js +139 -0
  80. package/dist/{storage-CrXGgIbS.js → storage-DzP22xKn.js} +1 -1
  81. package/dist/storekit-D5eopLM0.js +17 -0
  82. package/dist/{storekit-CptdG4RJ.js → storekit-n1x0bWkQ.js} +4 -4
  83. package/dist/{telemetry-BqaPbM0k.js → telemetry-CXN6f-ZX.js} +1 -1
  84. package/dist/{token-zjjlkNDF.js → token-FmeHywYt.js} +1 -1
  85. package/dist/tools-skills/superwall/SKILL.md +49 -31
  86. package/dist/tools-skills/superwall/references/api.md +3 -2
  87. package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
  88. package/dist/tools.d.ts +1 -1
  89. package/dist/tools.js +452 -27
  90. package/dist/try-BWbzgelb.js +120 -0
  91. package/dist/{selection-CgZJJ3FD.js → types-JdxmnCko.js} +1 -178
  92. package/dist/{upgrade-BBnmcyY2.js → upgrade-Bk5boOgW.js} +2 -2
  93. package/dist/{upgrade-AdyF7wXk.js → upgrade-CoWCEnoi.js} +2 -2
  94. package/package.json +5 -3
  95. package/dist/create-CBCDWuyo.js +0 -19
  96. package/dist/held-BL4oizD6.js +0 -16
  97. package/dist/login-DdrOmi6m.js +0 -16
  98. package/dist/push-B3Onn_mL.js +0 -24
  99. package/dist/scan-DUQjxOZf.js +0 -4
  100. package/dist/server-Cv-Ug9JF.js +0 -24
  101. package/dist/session-BCQuMcQ0.js +0 -6
  102. package/dist/storekit-B675ZNiA.js +0 -16
  103. /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
  104. /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
  105. /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
  106. /package/dist/{reports-CwwKLUh0.js → reports-CuhB1_ub.js} +0 -0
  107. /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
  108. /package/dist/{storage-gRyQetN9.d.ts → storage-BjQCiTuz.d.ts} +0 -0
  109. /package/dist/{timing-BVxPrYq3.js → timing-Ca0TXY-A.js} +0 -0
@@ -0,0 +1,103 @@
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 { n as openBrowser } from "./browser-Bp3yRKlU.js";
13
+ import "./types-JdxmnCko.js";
14
+ import "./scope-CCb_7UvN.js";
15
+ import { S as listWorkspaces, T as setInstallation, a as openLink, c as resolveWorkspace, d as readBinding, g as deleteInstallation, r as latestManifest, s as projectRoot, t as appEntrypointUrl, x as listVersions, y as listInstallations } from "./resolve--GsHj0Q1.js";
16
+ import { r as WorkspaceError } from "./project-CP6hiHra.js";
17
+ import { n as resolveOrganization, t as resolveAppScope } from "./organization-BOECL3vZ.js";
18
+
19
+ //#region src/core/workspaces/install.ts
20
+ const whereLabel = (application) => application === null || application === void 0 ? "the whole organization" : `app ${application}`;
21
+ const installationItem = (installation) => ({
22
+ label: installation.entrypoint_id,
23
+ meta: [
24
+ installation.slot,
25
+ whereLabel(installation.application_id),
26
+ installation.enabled ? "on" : "off",
27
+ `position ${installation.position}`
28
+ ].join(", ")
29
+ });
30
+ async function runWorkspaceInstall(ctx, input) {
31
+ const workspace = await resolveWorkspace(ctx, input);
32
+ if (input.entrypoint === void 0) {
33
+ if (input.remove || input.disable || input.app !== void 0 || input.position !== void 0) throw new WorkspaceError("Say which entrypoint: `superwall workspaces install <entrypoint>`.");
34
+ const installations = await listInstallations(ctx.api, workspace.id);
35
+ if (ctx.json) ctx.output.data({ data: installations });
36
+ else ctx.ui.list({
37
+ empty: "Nothing is installed yet.",
38
+ items: installations.map(installationItem)
39
+ });
40
+ return;
41
+ }
42
+ const applicationId = input.app === void 0 ? void 0 : (await resolveAppScope(ctx.api, input.app, String(workspace.organization_id))).applicationId;
43
+ if (input.remove) {
44
+ if (!input.yes) {
45
+ if (!ctx.interactive) throw new WorkspaceError("Removing an installation ends sessions that are open. Pass --yes to go ahead.");
46
+ if (!await ctx.ui.confirm({
47
+ message: `Remove \`${input.entrypoint}\` from ${whereLabel(applicationId)}? Sessions that are open will end.`,
48
+ initial: false
49
+ })) {
50
+ ctx.ui.outro("Nothing was removed.");
51
+ return;
52
+ }
53
+ }
54
+ const left = await deleteInstallation(ctx.api, workspace.id, input.entrypoint, applicationId);
55
+ if (ctx.json) ctx.output.data(left);
56
+ else ctx.ui.success(`Removed \`${input.entrypoint}\` from ${whereLabel(applicationId)}.`);
57
+ return;
58
+ }
59
+ const installation = await setInstallation(ctx.api, workspace.id, {
60
+ entrypoint_id: input.entrypoint,
61
+ application_id: applicationId === void 0 ? null : Number(applicationId),
62
+ enabled: !input.disable,
63
+ ...input.position === void 0 ? {} : { position: input.position }
64
+ });
65
+ if (ctx.json) {
66
+ ctx.output.data(installation);
67
+ return;
68
+ }
69
+ ctx.ui.success(input.disable ? `Turned \`${input.entrypoint}\` off for ${whereLabel(applicationId)}.` : `Installed \`${input.entrypoint}\` for ${whereLabel(applicationId)}.`);
70
+ }
71
+ async function runWorkspaceList(ctx, input) {
72
+ const organizationId = await resolveOrganization(ctx, input.org ?? readBinding(projectRoot(input.dir))?.organizationId);
73
+ const workspaces = await listWorkspaces(ctx.api, organizationId);
74
+ if (ctx.json) {
75
+ ctx.output.data({ data: workspaces });
76
+ return;
77
+ }
78
+ ctx.ui.list({
79
+ empty: `No workspaces in organization ${organizationId} yet.`,
80
+ items: workspaces.map((workspace) => ({
81
+ label: workspace.name,
82
+ meta: `${workspace.slug}, id ${workspace.id}, ${workspace.state.replaceAll("_", " ")}`
83
+ }))
84
+ });
85
+ }
86
+ async function runWorkspaceOpen(ctx, input, seams = {}) {
87
+ const workspace = await resolveWorkspace(ctx, input);
88
+ if (input.entrypoint !== void 0 && input.app === void 0) throw new WorkspaceError("An entrypoint opens inside an app. Say which with --app <id>.");
89
+ let url;
90
+ if (input.entrypoint !== void 0 && input.app !== void 0) {
91
+ const { applicationId } = await resolveAppScope(ctx.api, input.app, String(workspace.organization_id));
92
+ url = appEntrypointUrl(ctx.api.host, workspace, String(applicationId), input.entrypoint);
93
+ } else url = (await openLink(ctx, workspace, latestManifest(await listVersions(ctx.api, workspace.id).catch(() => [])))).url;
94
+ if (ctx.json) {
95
+ ctx.output.data({ url });
96
+ return;
97
+ }
98
+ ctx.ui.info(`Open ${url}`);
99
+ if (input.open && ctx.outputMode === "rich") await (seams.open ?? openBrowser)(url);
100
+ }
101
+
102
+ //#endregion
103
+ export { runWorkspaceInstall, runWorkspaceList, runWorkspaceOpen };
@@ -1,34 +1,36 @@
1
- import "./token-zjjlkNDF.js";
1
+ import "./token-FmeHywYt.js";
2
2
  import { r as formatJson, t as blocks } from "./output-Ggzq5_-t.js";
3
- import { b as VERSION, u as DASHBOARD_URL } from "./environment-djS0ik60.js";
4
- import { i as removeSession, n as readSession, s as sessionOrgName } from "./storage-CrXGgIbS.js";
5
- import { i as superwallApi } from "./client-ltxxHuxn.js";
3
+ import { d as DASHBOARD_URL, x as VERSION } from "./environment-BWT2S4qC.js";
4
+ import { i as removeSession, n as readSession, s as sessionOrgName } from "./storage-DzP22xKn.js";
5
+ import { i as superwallApi } from "./client-AI9H4GGB.js";
6
6
  import { i as readOnboardedApp } from "./config-CGcG7GOt.js";
7
- import { i as updateTelemetryTags } from "./telemetry-BqaPbM0k.js";
7
+ import { i as updateTelemetryTags } from "./telemetry-CXN6f-ZX.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import { n as withSpinner } from "./spinner-1uuKKZMc.js";
9
+ import { n as withSpinner } from "./spinner-BANVLncC.js";
10
10
  import { n as ui } from "./ui-D_qf3Gvw.js";
11
11
  import "./theme-DUsCh-Vd.js";
12
12
  import { t as stripReport } from "./log-C0MDCfA2.js";
13
- import { n as SUPPORTED_LABEL, t as scanProject } from "./scan-CRexsHOE.js";
14
- import { t as detectExisting } from "./existing-Das3PHGG.js";
15
- import { r as expandHome } from "./paths-CdwjySxK.js";
16
- import { A as listField, O as field, T as rowName, h as listResource, p as listApplications, s as createProduct, y as platformLabel } from "./resources-BMspgZO1.js";
17
- import "./org-BrR4HGvl.js";
18
- import "./lookup-us5vu5od.js";
19
- import "./scope-Ct0_HoNq.js";
20
- import { a as listAscConfigs, r as createAscConfig } from "./client-BZ1UbpXz.js";
21
- import { i as listUnimportedAscProducts, n as findAscAppId, r as listAscApps, t as ascTypeDisplay } from "./products-DH_fK9tY.js";
22
- import "./input-vi0bou04.js";
23
- import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-82oTpHZ3.js";
24
- import "./login-CiK5T4w8.js";
25
- import { s as ensureSkillsCurrent } from "./skills-CiWxt6vS.js";
26
- import { t as generateStoreKit } from "./storekit-CptdG4RJ.js";
27
- import { n as performLoginWithUi, t as createLoginGate } from "./login-girc324T.js";
28
- import { a as copyToClipboard, r as buildCopyPrompt, t as runAction } from "./run-D4V6mq8_.js";
29
- import { n as selectHostedStatus, t as detectDrivers } from "./drivers-CTyYdBL7.js";
30
- import { r as actionById, t as detectBilling } from "./billing-C4lXR0xG.js";
31
- import { n as writeReport, t as readReport } from "./reports-CwwKLUh0.js";
13
+ import { n as SUPPORTED_LABEL, t as scanProject } from "./scan-Bj5y0zTZ.js";
14
+ import { t as detectExisting } from "./existing-b0GxFcnc.js";
15
+ import { r as expandHome } from "./paths-REb-GrbX.js";
16
+ import "./orgs-D6Kk96mG.js";
17
+ import { A as listField, O as field, T as rowName, h as listResource, p as listApplications, s as createProduct, y as platformLabel } from "./resources-BaP3p_LY.js";
18
+ import "./org-C04eAO-j.js";
19
+ import "./lookup-gjcKIZvh.js";
20
+ import "./scope-Bp_zwJOo.js";
21
+ import { a as listAscConfigs, r as createAscConfig } from "./client-BJQXl62Q.js";
22
+ import { i as listUnimportedAscProducts, n as findAscAppId, r as listAscApps, t as ascTypeDisplay } from "./products-Cqq59DBQ.js";
23
+ import "./input-MDd67UIp.js";
24
+ import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-B3eEcRyp.js";
25
+ import "./login-PMoXUGqq.js";
26
+ import { s as ensureSkillsCurrent } from "./skills-2qYaUXGE.js";
27
+ import "./browser-Bp3yRKlU.js";
28
+ import { t as generateStoreKit } from "./storekit-n1x0bWkQ.js";
29
+ import { n as performLoginWithUi, t as createLoginGate } from "./login-COmGHrU5.js";
30
+ import { a as copyToClipboard, r as buildCopyPrompt, t as runAction } from "./run-C5OPwhvS.js";
31
+ import { n as selectHostedStatus, t as detectDrivers } from "./drivers-CMEL13gp.js";
32
+ import { r as actionById, t as detectBilling } from "./billing-D5qqIlVb.js";
33
+ import { n as writeReport, t as readReport } from "./reports-CuhB1_ub.js";
32
34
  import { readFileSync, writeFileSync } from "node:fs";
33
35
  import { basename } from "node:path";
34
36
  import fg from "fast-glob";
@@ -1,5 +1,6 @@
1
1
  import { n as ui } from "./ui-D_qf3Gvw.js";
2
- import { a as BROWSER_UNAVAILABLE, s as onboardingHooks, t as performLogin } from "./login-CiK5T4w8.js";
2
+ import { a as onboardingHooks, t as performLogin } from "./login-PMoXUGqq.js";
3
+ import { t as BROWSER_UNAVAILABLE } from "./browser-Bp3yRKlU.js";
3
4
 
4
5
  //#region src/core/workflows/login.ts
5
6
  async function performLoginWithUi(app, onProvisioned) {
@@ -0,0 +1,17 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
+ import "./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 { i as startLogin, n as pollLogin, r as runLogin, t as performLogin } from "./login-PMoXUGqq.js";
14
+ import "./skills-2qYaUXGE.js";
15
+ import "./browser-Bp3yRKlU.js";
16
+
17
+ export { performLogin, pollLogin, runLogin, startLogin };
@@ -1,12 +1,12 @@
1
- import { h as OAUTH_SCOPE, i as AUTH_HOST, l as CLI_CLIENT_ID, m as Integration, t as API_HOST } from "./environment-djS0ik60.js";
2
- import { c as writePendingLogin, l as writeSession, o as serializeSession, r as removePendingLogin, t as readPendingLogin } from "./storage-CrXGgIbS.js";
1
+ import { g as OAUTH_SCOPE, h as Integration, i as AUTH_HOST, l as CLI_CLIENT_ID, t as API_HOST } from "./environment-BWT2S4qC.js";
2
+ import { c as writePendingLogin, l as writeSession, o as serializeSession, r as removePendingLogin, t as readPendingLogin } from "./storage-DzP22xKn.js";
3
3
  import { a as readOnboardedOrg, m as writeOnboardedOrg, o as readOnboardingIdempotencyKey, p as writeOnboardedApp } from "./config-CGcG7GOt.js";
4
- import { r as track } from "./telemetry-BqaPbM0k.js";
5
- import { r as UsageError } from "./spinner-1uuKKZMc.js";
4
+ import { r as track } from "./telemetry-CXN6f-ZX.js";
5
+ import { r as UsageError } from "./spinner-BANVLncC.js";
6
6
  import { n as ui } from "./ui-D_qf3Gvw.js";
7
- import { t as scanProject } from "./scan-CRexsHOE.js";
8
- import { s as ensureSkillsCurrent } from "./skills-CiWxt6vS.js";
9
- import { spawn } from "node:child_process";
7
+ import { t as scanProject } from "./scan-Bj5y0zTZ.js";
8
+ import { s as ensureSkillsCurrent } from "./skills-2qYaUXGE.js";
9
+ import { n as openBrowser, t as BROWSER_UNAVAILABLE } from "./browser-Bp3yRKlU.js";
10
10
  import { setTimeout } from "node:timers/promises";
11
11
 
12
12
  //#region src/core/account/onboarding.ts
@@ -57,39 +57,6 @@ function onboardingHooks(app) {
57
57
  };
58
58
  }
59
59
 
60
- //#endregion
61
- //#region src/core/account/browser.ts
62
- const BROWSER_UNAVAILABLE = "Couldn't open a browser here. Open the URL above to approve the login.";
63
- function hasDisplay(env, platform) {
64
- if (platform !== "linux") return true;
65
- return Boolean(env.DISPLAY || env.WAYLAND_DISPLAY || env.WSL_DISTRO_NAME);
66
- }
67
- function openBrowser(url, deps = {}) {
68
- const platform = deps.platform ?? process.platform;
69
- const env = deps.env ?? process.env;
70
- if (env.BROWSER === "none" || !hasDisplay(env, platform)) return Promise.resolve(false);
71
- const cmd = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
72
- const args = platform === "win32" ? [
73
- "/c",
74
- "start",
75
- "",
76
- url
77
- ] : [url];
78
- return new Promise((resolve) => {
79
- try {
80
- const child = (deps.spawn ?? spawn)(cmd, args, {
81
- stdio: "ignore",
82
- detached: true
83
- });
84
- child.once("error", () => resolve(false));
85
- child.once("spawn", () => resolve(true));
86
- child.unref();
87
- } catch {
88
- resolve(false);
89
- }
90
- });
91
- }
92
-
93
60
  //#endregion
94
61
  //#region src/core/account/login.ts
95
62
  const DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
@@ -589,4 +556,4 @@ async function runLogin(ctx, { flags, openBrowser: openBrowser$1 }) {
589
556
  }
590
557
 
591
558
  //#endregion
592
- export { BROWSER_UNAVAILABLE as a, startLogin as i, pollLogin as n, openBrowser as o, runLogin as r, onboardingHooks as s, performLogin as t };
559
+ export { onboardingHooks as a, startLogin as i, pollLogin as n, runLogin as r, performLogin as t };
@@ -1,5 +1,6 @@
1
- import { t as ApiError } from "./client-ltxxHuxn.js";
2
- import { I as orgProjects, R as rememberOrg, m as listProjects } from "./resources-BMspgZO1.js";
1
+ import { t as ApiError } from "./client-AI9H4GGB.js";
2
+ import { a as orgProjects, s as rememberOrg } from "./orgs-D6Kk96mG.js";
3
+ import { m as listProjects } from "./resources-BaP3p_LY.js";
3
4
 
4
5
  //#region src/core/api/lookup.ts
5
6
  const DASHBOARD_PATH = /^\/(\d+)(?:\/(\d+))?(?:\/|$)/;
@@ -1,34 +1,39 @@
1
- import "./token-zjjlkNDF.js";
1
+ import "./token-FmeHywYt.js";
2
2
  import { t as blocks } from "./output-Ggzq5_-t.js";
3
- import { b as VERSION, u as DASHBOARD_URL } from "./environment-djS0ik60.js";
4
- import { n as readSession, s as sessionOrgName } from "./storage-CrXGgIbS.js";
5
- import "./client-ltxxHuxn.js";
3
+ import { d as DASHBOARD_URL, x as VERSION } from "./environment-BWT2S4qC.js";
4
+ import { n as readSession, s as sessionOrgName } from "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import "./telemetry-BqaPbM0k.js";
7
+ import "./telemetry-CXN6f-ZX.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-1uuKKZMc.js";
9
+ import "./spinner-BANVLncC.js";
10
10
  import { n as ui } from "./ui-D_qf3Gvw.js";
11
11
  import "./theme-DUsCh-Vd.js";
12
12
  import { t as stripReport } from "./log-C0MDCfA2.js";
13
- import { t as scanProject } from "./scan-CRexsHOE.js";
14
- import { t as detectExisting } from "./existing-Das3PHGG.js";
15
- import "./paths-CdwjySxK.js";
16
- import "./resources-BMspgZO1.js";
17
- import "./lookup-us5vu5od.js";
18
- import "./login-CiK5T4w8.js";
19
- import "./skills-CiWxt6vS.js";
20
- import "./assets-W5yvyf0V.js";
21
- import "./selection-CgZJJ3FD.js";
22
- import { n as requireApi } from "./session-CV0P8BjK.js";
23
- import "./source-push-CX_k_yZD.js";
24
- import { n as performLoginWithUi } from "./login-girc324T.js";
25
- import { t as runAction } from "./run-D4V6mq8_.js";
26
- import { t as detectDrivers } from "./drivers-CTyYdBL7.js";
27
- import { a as migrationSource, c as scaffoldFromPaywall, d as findScreenCandidates, f as placementOfName, i as migrationFor, l as scaffoldFromScreen, n as hasOriginal, o as offerMigration, p as screenNameOf, s as projectDirOf, t as buildMigrationCopyPrompt, u as screenMigrationFor } from "./migration-cS6UGeUj.js";
28
- import "./server-Dv1VwbNh.js";
29
- import { i as startStudio, n as migrationNextSteps, r as screenNextSteps, t as askStudio } from "./open-BIuOZ9ka.js";
30
- import { r as actionById, t as detectBilling } from "./billing-C4lXR0xG.js";
31
- import { n as writeReport } from "./reports-CwwKLUh0.js";
13
+ import { t as scanProject } from "./scan-Bj5y0zTZ.js";
14
+ import { t as detectExisting } from "./existing-b0GxFcnc.js";
15
+ import "./paths-REb-GrbX.js";
16
+ import "./orgs-D6Kk96mG.js";
17
+ import "./resources-BaP3p_LY.js";
18
+ import "./lookup-gjcKIZvh.js";
19
+ import "./login-PMoXUGqq.js";
20
+ import "./skills-2qYaUXGE.js";
21
+ import "./browser-Bp3yRKlU.js";
22
+ import "./assets-BrB9jQPQ.js";
23
+ import "./selection-BltBpyp5.js";
24
+ import "./types-JdxmnCko.js";
25
+ import { n as requireApi } from "./session-D3fgXQBt.js";
26
+ import "./source-push-kAep4gPe.js";
27
+ import "./git-D7AVdugb.js";
28
+ import "./scope-CCb_7UvN.js";
29
+ import { n as performLoginWithUi } from "./login-COmGHrU5.js";
30
+ import { t as runAction } from "./run-C5OPwhvS.js";
31
+ import { t as detectDrivers } from "./drivers-CMEL13gp.js";
32
+ import { a as migrationSource, c as scaffoldFromPaywall, d as findScreenCandidates, f as placementOfName, i as migrationFor, l as scaffoldFromScreen, n as hasOriginal, o as offerMigration, p as screenNameOf, s as projectDirOf, t as buildMigrationCopyPrompt, u as screenMigrationFor } from "./migration-DS44-3Zr.js";
33
+ import "./server-CdVIboQn.js";
34
+ import { i as startStudio, n as migrationNextSteps, r as screenNextSteps, t as askStudio } from "./open-DQpm2yVs.js";
35
+ import { r as actionById, t as detectBilling } from "./billing-D5qqIlVb.js";
36
+ import { n as writeReport } from "./reports-CuhB1_ub.js";
32
37
  import { execFile } from "node:child_process";
33
38
  import * as fs from "node:fs";
34
39
  import * as os$1 from "node:os";
@@ -1,13 +1,13 @@
1
- import { u as DASHBOARD_URL } from "./environment-djS0ik60.js";
2
- import { t as ApiError } from "./client-ltxxHuxn.js";
1
+ import { d as DASHBOARD_URL } from "./environment-BWT2S4qC.js";
2
+ import { t as ApiError } from "./client-AI9H4GGB.js";
3
3
  import { t as stripReport } from "./log-C0MDCfA2.js";
4
- import { i as readPackageJson, r as allDeps } from "./scan-CRexsHOE.js";
5
- import { l as findPaywall, p as listApplications } from "./resources-BMspgZO1.js";
6
- import { d as readBundledSkill } from "./skills-CiWxt6vS.js";
7
- import { F as writeOrigin, T as isScreenOrigin, j as writeApp, k as readLock } from "./selection-CgZJJ3FD.js";
8
- import { u as projectPackageName } from "./session-CV0P8BjK.js";
9
- import { a as copyToClipboard, i as readPrompt, n as runWithDriverFallback } from "./run-D4V6mq8_.js";
10
- import { t as detectDrivers } from "./drivers-CTyYdBL7.js";
4
+ import { i as readPackageJson, r as allDeps } from "./scan-Bj5y0zTZ.js";
5
+ import { l as findPaywall, p as listApplications } from "./resources-BaP3p_LY.js";
6
+ import { d as readBundledSkill } from "./skills-2qYaUXGE.js";
7
+ import { c as isScreenOrigin, f as readLock, m as writeApp, v as writeOrigin } from "./types-JdxmnCko.js";
8
+ import { a as projectPackageName } from "./session-D3fgXQBt.js";
9
+ import { a as copyToClipboard, i as readPrompt, n as runWithDriverFallback } from "./run-C5OPwhvS.js";
10
+ import { t as detectDrivers } from "./drivers-CMEL13gp.js";
11
11
  import * as fs from "node:fs";
12
12
  import * as path from "node:path";
13
13
  import fg from "fast-glob";
@@ -1,7 +1,7 @@
1
- import { D as updateServerNotifications, r as chooseKeyApp } from "./held-B8EFWDEc.js";
2
- import { t as apiCall } from "./spinner-1uuKKZMc.js";
3
- import { i as findAppNotificationUrl } from "./client-BZ1UbpXz.js";
4
- import { t as timing } from "./timing-BVxPrYq3.js";
1
+ import { D as updateServerNotifications, r as chooseKeyApp } from "./held-D3PUNky2.js";
2
+ import { t as apiCall } from "./spinner-BANVLncC.js";
3
+ import { i as findAppNotificationUrl } from "./client-BJQXl62Q.js";
4
+ import { t as timing } from "./timing-Ca0TXY-A.js";
5
5
 
6
6
  //#region src/core/app-store-connect/notification-url.ts
7
7
  const RETRY_DELAYS = [
@@ -1,5 +1,5 @@
1
- import { w as isNonInteractive } from "./environment-djS0ik60.js";
2
- import { t as runStudio } from "./server-Dv1VwbNh.js";
1
+ import { T as isNonInteractive } from "./environment-BWT2S4qC.js";
2
+ import { t as runStudio } from "./server-CdVIboQn.js";
3
3
 
4
4
  //#region src/core/paywalls/studio/open.ts
5
5
  async function askStudio(ui, interactive, surfaceId, original = true) {
@@ -1,6 +1,7 @@
1
- import { n as withSpinner } from "./spinner-1uuKKZMc.js";
1
+ import { n as withSpinner } from "./spinner-BANVLncC.js";
2
2
  import { n as ui } from "./ui-D_qf3Gvw.js";
3
- import { E as titleCase, N as listOrgGroups, P as listOrganizations, T as rowName } from "./resources-BMspgZO1.js";
3
+ import { n as listOrganizations, t as listOrgGroups } from "./orgs-D6Kk96mG.js";
4
+ import { E as titleCase, T as rowName } from "./resources-BaP3p_LY.js";
4
5
 
5
6
  //#region src/core/account/org.ts
6
7
  async function orgForNewProject(api, interactive) {
@@ -0,0 +1,39 @@
1
+ import { t as apiCall } from "./spinner-BANVLncC.js";
2
+ import { a as orgProjects, i as orgIdOf, n as listOrganizations } from "./orgs-D6Kk96mG.js";
3
+ import { n as findApplication, t as appNotFound } from "./lookup-gjcKIZvh.js";
4
+ import { r as WorkspaceError } from "./project-CP6hiHra.js";
5
+
6
+ //#region src/core/workspaces/organization.ts
7
+ async function resolveAppScope(api, app, org) {
8
+ if (/^\d+$/.test(app) && org !== void 0) return {
9
+ organizationId: org,
10
+ applicationId: app
11
+ };
12
+ const found = await findApplication(api, app, org === void 0 ? void 0 : await orgProjects(api, org));
13
+ if (!found) throw appNotFound(app);
14
+ const home = orgIdOf(found.project);
15
+ if (org !== void 0 && home !== org) throw new WorkspaceError(`App ${app} is in organization ${home ?? "unknown"}, not ${org}.`);
16
+ return {
17
+ organizationId: org ?? home,
18
+ applicationId: String(found.app.id)
19
+ };
20
+ }
21
+ async function resolveOrganization(ctx, org) {
22
+ if (org !== void 0) return org;
23
+ const organizations = await apiCall(ctx, "Loading your organizations", () => listOrganizations(ctx.api));
24
+ const [only] = organizations;
25
+ if (only !== void 0 && organizations.length === 1) return String(only.id);
26
+ if (!ctx.interactive || organizations.length === 0) throw new WorkspaceError("Say which organization with --org <id>.");
27
+ const picked = await ctx.ui.select({
28
+ message: "Which organization?",
29
+ options: organizations.map((organization) => ({
30
+ value: String(organization.id),
31
+ label: String(organization.name ?? organization.id)
32
+ }))
33
+ });
34
+ if (picked === null) throw new WorkspaceError("No organization picked.");
35
+ return picked;
36
+ }
37
+
38
+ //#endregion
39
+ export { resolveOrganization as n, resolveAppScope as t };
@@ -0,0 +1,81 @@
1
+ import { t as ApiError } from "./client-AI9H4GGB.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-BWT2S4qC.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-FmeHywYt.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-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.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-CXN6f-ZX.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-1uuKKZMc.js";
9
+ import "./spinner-BANVLncC.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-Bj5y0zTZ.js";
12
+ import "./paths-REb-GrbX.js";
13
+ import { d as readBundledSkill } from "./skills-2qYaUXGE.js";
14
+ import { n as FRAMEWORK_REF, t as detectBilling } from "./billing-D5qqIlVb.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 };