@superwall/cli 1.2.0 → 1.3.0-beta.4

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 (50) hide show
  1. package/README.md +6 -4
  2. package/dist/{actions-DYQTxMXS.js → actions-C0sUjLGZ.js} +2 -2
  3. package/dist/{api-B2Zsf08U.js → api-NEcc9ESi.js} +9 -9
  4. package/dist/{api-output-B5hh0q4V.js → api-output-D9ggXQIr.js} +1 -1
  5. package/dist/{app-rYAP19Jo.js → app-vECLIkWi.js} +11 -11
  6. package/dist/{asa-DlM6dlPD.js → asa-CZcmgOho.js} +11 -11
  7. package/dist/{asc-D6qBCfuj.js → asc-mJv5I7lW.js} +12 -12
  8. package/dist/{auth-BEnVvJlK.js → auth-BCsxGMUQ.js} +10 -10
  9. package/dist/auth.js +2 -2
  10. package/dist/{billing-DO-gNWvW.js → billing-KoxHLZzm.js} +1 -1
  11. package/dist/{bind-KZhPLTdC.js → bind-CBLvcdzo.js} +4 -4
  12. package/dist/{command-B12qooZb.js → command-Bav1fWvv.js} +93 -102
  13. package/dist/{create-BTEvRC1X.js → create-CA_s5fN9.js} +18 -18
  14. package/dist/{dev-CwfCGm36.js → dev-B1o8OCRT.js} +37 -19
  15. package/dist/{doctor-DIxs8i8A.js → doctor-CyiygODt.js} +10 -10
  16. package/dist/{drivers-D6Ka26e2.js → drivers-DSkM9kMJ.js} +2 -2
  17. package/dist/entry.js +523 -467
  18. package/dist/{existing-CECenoHS.js → existing-D7p2hnhq.js} +2 -2
  19. package/dist/{feedback-CV2coV73.js → feedback-BBIkn1Yp.js} +9 -9
  20. package/dist/{git-CCJwXufi.js → git-C0x00Urq.js} +10 -10
  21. package/dist/{hosted-BCwzTTEw.js → hosted-q7_n5udj.js} +3 -3
  22. package/dist/{integrate-Bhq0wkU0.js → integrate-DstRn_NP.js} +28 -27
  23. package/dist/{login-D5TjqsXJ.js → login-DGc6GQqT.js} +8 -7
  24. package/dist/{migrate-Cz7VqQNj.js → migrate-CcwiRU6G.js} +20 -20
  25. package/dist/{org-B2gy9Pmu.js → org-Cg25bcsj.js} +3 -3
  26. package/dist/output-DmEUd7Xa.js +123 -0
  27. package/dist/{params-Bvq0iqQK.js → params-B1zeElGa.js} +1 -2
  28. package/dist/{pipeline-ChRDxU9b.js → pipeline-B3c4tjfA.js} +105 -98
  29. package/dist/{print-skill-BPePCjy4.js → print-skill-DBEmY01G.js} +7 -7
  30. package/dist/{promote-C54bfsg3.js → promote-bg_Li4za.js} +18 -18
  31. package/dist/publish-lviGUOF8.js +35 -0
  32. package/dist/push-C8vuasQL.js +35 -0
  33. package/dist/{query-CXjrBFow.js → query-dO6QUMTQ.js} +10 -10
  34. package/dist/{resource-CM2bIB5v.js → resource-BZvGoZlY.js} +13 -13
  35. package/dist/{resources-CVrWwA1K.js → resources-s64mBHaC.js} +1 -0
  36. package/dist/{run-CAIDPbwe.js → run-BfI8NVh4.js} +2 -2
  37. package/dist/{scan-BrikLKx5.js → scan-HfLbAkLc.js} +2 -2
  38. package/dist/{skills-BwXcAVIf.js → skills-BDMwScz3.js} +4 -3
  39. package/dist/{skills-_TULXe09.js → skills-DuI61I8U.js} +8 -8
  40. package/dist/{spinner-gOxIMz-V.js → spinner-B9dT3DBY.js} +1 -1
  41. package/dist/{telemetry-CpIXSAbQ.js → telemetry-vvgwHwjA.js} +6 -41
  42. package/dist/{token-DHRH8cxi.js → token-CwKfB5Ic.js} +2 -2
  43. package/dist/{ui-C4ncRJqd.js → ui-Lqt_zFOr.js} +5 -1
  44. package/dist/update-DeK9OQ5x.js +59 -0
  45. package/dist/{upgrade-BNPbzr5V.js → upgrade-Dyxk8mwJ.js} +6 -6
  46. package/package.json +4 -4
  47. package/dist/json-C3hPIMkI.js +0 -7
  48. package/dist/publish-NUNSIKri.js +0 -35
  49. package/dist/push-BjEpY9-h.js +0 -35
  50. package/dist/update-BdcpwRu_.js +0 -137
package/README.md CHANGED
@@ -152,7 +152,7 @@ export default function PlusUpgrade() {
152
152
 
153
153
  One concern each: `useProducts`, `usePurchase` (resolves `completed |
154
154
  abandoned | failed`, never throws for flow outcomes), `useActions`,
155
- `useHaptics`, `useColorScheme`, `useTranslation`, `useTrialEligibility`,
155
+ `useHaptics`, `useColorScheme`, `useTranslation`, `useIntroductoryOffer`,
156
156
  `useDevice` / `useUser` / `useVariables`, `useLocalResource`,
157
157
  `useSuperwallEvent`, `useGameController`.
158
158
 
@@ -179,9 +179,11 @@ checkout and in-app browsers hand a flow back where it left off.
179
179
  and funnel as a live card, and an editor with a device-frame preview (nine
180
180
  devices, iPhone SE to Desktop), light/dark, locale switching, and live
181
181
  controls for the user, device, params, and product variables the SDK
182
- reports. Previews run against a stand-in SDK host — purchases resolve, trials
183
- start — while product data is read from Superwall, never invented. The same
184
- build runs unchanged inside a real SDK webview.
182
+ reports. The studio hosts each preview the way the native SDK hosts a
183
+ webview: it answers the paywall's `ping` over the SDK protocol with products,
184
+ device, user and eligibility, and asks you for every purchase, restore,
185
+ permission and callback outcome. Product data is read from Superwall, never
186
+ invented, and the same build runs unchanged inside a real SDK webview.
185
187
 
186
188
  ### Push, promote, publish
187
189
 
@@ -1,5 +1,5 @@
1
- import { T as Integration } from "./telemetry-CpIXSAbQ.js";
2
- import { i as loadBundledSkill } from "./skills-BwXcAVIf.js";
1
+ import { d as Integration } from "./output-DmEUd7Xa.js";
2
+ import { i as loadBundledSkill } from "./skills-BDMwScz3.js";
3
3
 
4
4
  //#region src/core/agent/actions.ts
5
5
  /** Skill reference file per framework, so an agent only sees its own platform's docs. */
@@ -1,12 +1,12 @@
1
- import "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import "./token-DHRH8cxi.js";
5
- import { t as defineCommand } from "./command-B12qooZb.js";
6
- import "./ui-C4ncRJqd.js";
7
- import { C as rowName, h as listResource, m as listProjects, p as listOrganizations, w as titleCase, y as platformLabel } from "./resources-CVrWwA1K.js";
8
- import { t as parseParams } from "./params-Bvq0iqQK.js";
9
- import { n as emitJson, t as apiCall } from "./api-output-B5hh0q4V.js";
1
+ import "./output-DmEUd7Xa.js";
2
+ import "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import "./token-CwKfB5Ic.js";
5
+ import { t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import "./ui-Lqt_zFOr.js";
7
+ import { C as rowName, h as listResource, m as listProjects, p as listOrganizations, w as titleCase, y as platformLabel } from "./resources-s64mBHaC.js";
8
+ import { t as parseParams } from "./params-B1zeElGa.js";
9
+ import { n as emitJson, t as apiCall } from "./api-output-D9ggXQIr.js";
10
10
  import pc from "picocolors";
11
11
 
12
12
  //#region src/commands/platform/api.ts
@@ -1,4 +1,4 @@
1
- //#region src/util/api-output.ts
1
+ //#region src/commands/api-output.ts
2
2
  function emitJson(ctx, data) {
3
3
  ctx.output.data(data);
4
4
  }
@@ -1,12 +1,12 @@
1
- import { i as loadSession, r as clearSession } from "./token-DHRH8cxi.js";
2
- import { r as SuperwallApi } from "./command-B12qooZb.js";
3
- import { n as ui } from "./ui-C4ncRJqd.js";
4
- import { n as performLogin, r as onboardingHooks } from "./login-D5TjqsXJ.js";
5
- import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-BrikLKx5.js";
6
- import { r as getHostedStatus } from "./hosted-BCwzTTEw.js";
7
- import { t as withSpinner } from "./spinner-gOxIMz-V.js";
8
- import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-KZhPLTdC.js";
9
- import { t as ACTIONS } from "./actions-DYQTxMXS.js";
1
+ import { i as loadSession, r as clearSession } from "./token-CwKfB5Ic.js";
2
+ import { i as superwallApi } from "./command-Bav1fWvv.js";
3
+ import { n as ui } from "./ui-Lqt_zFOr.js";
4
+ import { n as performLogin, r as onboardingHooks } from "./login-DGc6GQqT.js";
5
+ import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-HfLbAkLc.js";
6
+ import { r as getHostedStatus } from "./hosted-q7_n5udj.js";
7
+ import { t as withSpinner } from "./spinner-B9dT3DBY.js";
8
+ import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-CBLvcdzo.js";
9
+ import { t as ACTIONS } from "./actions-C0sUjLGZ.js";
10
10
 
11
11
  //#region src/commands/workflow/integrate/app.ts
12
12
  async function performLoginWithUi(app, onProvisioned) {
@@ -69,7 +69,7 @@ async function recoverUnmatchedScope(app, apiKey) {
69
69
  if (choice === "relogin") {
70
70
  clearSession();
71
71
  if (!await performLoginWithUi(app)) return null;
72
- const resolved = await withSpinner("Finding this app in Superwall", () => resolveScopeFromKey(SuperwallApi.fromSession(), apiKey).catch(() => null));
72
+ const resolved = await withSpinner("Finding this app in Superwall", () => resolveScopeFromKey(superwallApi(), apiKey).catch(() => null));
73
73
  if (resolved) {
74
74
  ui.success(`Found \`${resolved.appName ?? app.name}\``);
75
75
  return {
@@ -84,7 +84,7 @@ async function recoverUnmatchedScope(app, apiKey) {
84
84
  continue;
85
85
  }
86
86
  try {
87
- const bound = await resolveAppBinding(SuperwallApi.fromSession(), {
87
+ const bound = await resolveAppBinding(superwallApi(), {
88
88
  platform: platformForIntegration(app.integration),
89
89
  appName: app.name
90
90
  });
@@ -1,14 +1,14 @@
1
- import "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import "./token-DHRH8cxi.js";
5
- import { n as ApiError, t as defineCommand } from "./command-B12qooZb.js";
6
- import "./ui-C4ncRJqd.js";
7
- import "./spinner-gOxIMz-V.js";
8
- import { m as listProjects } from "./resources-CVrWwA1K.js";
9
- import { t as requireOrg } from "./org-B2gy9Pmu.js";
10
- import { t as parseParams } from "./params-Bvq0iqQK.js";
11
- import { n as emitJson, t as apiCall } from "./api-output-B5hh0q4V.js";
1
+ import "./output-DmEUd7Xa.js";
2
+ import "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import "./token-CwKfB5Ic.js";
5
+ import { n as ApiError, t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import "./ui-Lqt_zFOr.js";
7
+ import "./spinner-B9dT3DBY.js";
8
+ import { m as listProjects } from "./resources-s64mBHaC.js";
9
+ import { t as requireOrg } from "./org-Cg25bcsj.js";
10
+ import { t as parseParams } from "./params-B1zeElGa.js";
11
+ import { n as emitJson, t as apiCall } from "./api-output-D9ggXQIr.js";
12
12
  import { readFileSync } from "node:fs";
13
13
 
14
14
  //#region src/core/api/asa.ts
@@ -1,14 +1,14 @@
1
- import "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import "./token-DHRH8cxi.js";
5
- import { t as defineCommand } from "./command-B12qooZb.js";
6
- import "./ui-C4ncRJqd.js";
7
- import "./spinner-gOxIMz-V.js";
8
- import { C as rowName } from "./resources-CVrWwA1K.js";
9
- import { t as requireOrg } from "./org-B2gy9Pmu.js";
10
- import { t as parseParams } from "./params-Bvq0iqQK.js";
11
- import { n as emitJson, t as apiCall } from "./api-output-B5hh0q4V.js";
1
+ import { p as SUPERWALL_HOME } from "./output-DmEUd7Xa.js";
2
+ import "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import "./token-CwKfB5Ic.js";
5
+ import { t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import "./ui-Lqt_zFOr.js";
7
+ import "./spinner-B9dT3DBY.js";
8
+ import { C as rowName } from "./resources-s64mBHaC.js";
9
+ import { t as requireOrg } from "./org-Cg25bcsj.js";
10
+ import { t as parseParams } from "./params-B1zeElGa.js";
11
+ import { n as emitJson, t as apiCall } from "./api-output-D9ggXQIr.js";
12
12
  import { a as ascProxy, c as listAscConfigs, i as listAscApps, n as fetchUnimportedAscProducts, o as createAscConfig, r as findAscAppId, s as deleteAscConfig, t as ascTypeDisplay } from "./asc-products-C6MvSy8H.js";
13
13
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
14
14
  import { homedir } from "node:os";
@@ -20,7 +20,7 @@ import { inflateRawSync } from "node:zlib";
20
20
  const SPEC_URL = "https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip";
21
21
  const REFRESH_TTL_MS = 10080 * 60 * 1e3;
22
22
  function cachePath() {
23
- return process.env.SUPERWALL_ASC_INDEX_PATH ?? join(homedir(), ".superwall", "asc-index.json");
23
+ return process.env.SUPERWALL_ASC_INDEX_PATH ?? join(SUPERWALL_HOME() ?? join(homedir(), ".superwall"), "asc-index.json");
24
24
  }
25
25
  let mem;
26
26
  function readCachedIndex() {
@@ -1,13 +1,13 @@
1
- import { i as track, y as API_HOST } from "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import { i as loadSession, r as clearSession } from "./token-DHRH8cxi.js";
5
- import { t as defineCommand } from "./command-B12qooZb.js";
6
- import "./ui-C4ncRJqd.js";
7
- import { n as ensureSkillsCurrent } from "./skills-BwXcAVIf.js";
1
+ import { a as API_HOST } from "./output-DmEUd7Xa.js";
2
+ import { i as track } from "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import { i as loadSession, r as clearSession } from "./token-CwKfB5Ic.js";
5
+ import { t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import "./ui-Lqt_zFOr.js";
7
+ import { n as ensureSkillsCurrent } from "./skills-BDMwScz3.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import { n as performLogin, r as onboardingHooks, t as loginWithApiKey } from "./login-D5TjqsXJ.js";
10
- import { t as scanProject } from "./scan-BrikLKx5.js";
9
+ import { n as performLogin, r as onboardingHooks, t as loginWithApiKey } from "./login-DGc6GQqT.js";
10
+ import { t as scanProject } from "./scan-HfLbAkLc.js";
11
11
 
12
12
  //#region src/commands/account/auth.ts
13
13
  const runLogin = defineCommand({
@@ -119,7 +119,7 @@ const runWhoami = defineCommand({
119
119
  }
120
120
  });
121
121
  function effectiveHost(session) {
122
- return process.env.SUPERWALL_API_HOST ?? session.host ?? API_HOST;
122
+ return process.env.SUPERWALL_API_HOST ?? session.host ?? API_HOST();
123
123
  }
124
124
  function sessionOutput(session) {
125
125
  return {
package/dist/auth.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./json-C3hPIMkI.js";
2
- import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-DHRH8cxi.js";
1
+ import "./output-DmEUd7Xa.js";
2
+ import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-CwKfB5Ic.js";
3
3
 
4
4
  export { NotLoggedInError, getOAuthAccessToken, resolveAuthToken };
@@ -1,4 +1,4 @@
1
- import { n as allDeps, r as readPackageJson } from "./scan-BrikLKx5.js";
1
+ import { n as allDeps, r as readPackageJson } from "./scan-HfLbAkLc.js";
2
2
  import { readFileSync } from "node:fs";
3
3
  import fg from "fast-glob";
4
4
 
@@ -1,7 +1,7 @@
1
- import { T as Integration } from "./telemetry-CpIXSAbQ.js";
2
- import { n as ui } from "./ui-C4ncRJqd.js";
3
- import { m as listProjects, n as createApplication, s as createProject, y as platformLabel } from "./resources-CVrWwA1K.js";
4
- import { t as requireOrg } from "./org-B2gy9Pmu.js";
1
+ import { d as Integration } from "./output-DmEUd7Xa.js";
2
+ import { n as ui } from "./ui-Lqt_zFOr.js";
3
+ import { m as listProjects, n as createApplication, s as createProject, y as platformLabel } from "./resources-s64mBHaC.js";
4
+ import { t as requireOrg } from "./org-Cg25bcsj.js";
5
5
 
6
6
  //#region src/core/account/bind.ts
7
7
  const NEW = "__new__";
@@ -1,7 +1,8 @@
1
- import { i as track, n as maybeShowTelemetryNotice, o as isNonInteractive, y as API_HOST } from "./telemetry-CpIXSAbQ.js";
2
- import { a as refreshUpdateCheck, c as writeJson, i as maybeNotifyUpdate, s as createCommandOutput } from "./update-BdcpwRu_.js";
3
- import { a as saveSession, i as loadSession, n as resolveAuthToken, o as NotLoggedInError } from "./token-DHRH8cxi.js";
4
- import { t as selectRenderer } from "./ui-C4ncRJqd.js";
1
+ import { a as API_HOST, i as writeJson, n as createCommandOutput, v as isNonInteractive } from "./output-DmEUd7Xa.js";
2
+ import { i as track, n as maybeShowTelemetryNotice } from "./telemetry-vvgwHwjA.js";
3
+ import { a as refreshUpdateCheck, i as maybeNotifyUpdate } from "./update-DeK9OQ5x.js";
4
+ import { a as saveSession, i as loadSession, n as resolveAuthToken, o as NotLoggedInError } from "./token-CwKfB5Ic.js";
5
+ import { r as useRenderer, t as selectRenderer } from "./ui-Lqt_zFOr.js";
5
6
  import pc from "picocolors";
6
7
  import { resolve } from "node:path";
7
8
 
@@ -57,47 +58,25 @@ var ApiUnreachableError = class extends Error {
57
58
  this.cause = cause;
58
59
  }
59
60
  };
60
- var SuperwallApi = class SuperwallApi {
61
- constructor(session) {
62
- this.session = session;
63
- }
64
- static of(session) {
65
- return new SuperwallApi(session);
66
- }
67
- static fromSession() {
68
- const session = loadSession();
69
- if (!session) throw new NotLoggedInError();
70
- return new SuperwallApi(session);
71
- }
72
- get org() {
73
- const override = process.env.SUPERWALL_ORG_ID;
74
- return {
75
- id: override ?? this.session.orgId,
76
- name: override ? void 0 : this.session.orgName,
77
- count: this.session.orgCount ?? 1
78
- };
79
- }
80
- get userEmail() {
81
- return this.session.userEmail;
82
- }
83
- setOrg(org) {
84
- this.session = {
85
- ...this.session,
86
- orgId: org.id,
87
- orgName: org.name
88
- };
89
- saveSession(this.session);
90
- }
91
- get host() {
92
- return process.env.SUPERWALL_API_HOST ?? this.session.host ?? API_HOST;
93
- }
94
- base() {
95
- return this.host;
96
- }
97
- async request(method, path, body, options = {}) {
98
- const { token, session } = await resolveAuthToken(this.session);
99
- this.session = session;
100
- const res = await this.fetch(`${this.base()}${path}`, {
61
+ const PAGE_LIMIT = 50;
62
+ const createSuperwallApi = (initial) => {
63
+ let session = initial;
64
+ const host = () => process.env.SUPERWALL_API_HOST ?? session.host ?? API_HOST();
65
+ const send = async (url, init) => {
66
+ try {
67
+ return await fetch(url, init);
68
+ } catch (error) {
69
+ throw new ApiUnreachableError(host(), error);
70
+ }
71
+ };
72
+ const authorized = async () => {
73
+ const resolved = await resolveAuthToken(session);
74
+ session = resolved.session;
75
+ return resolved.token;
76
+ };
77
+ const request = async (method, path, body, options = {}) => {
78
+ const token = await authorized();
79
+ const res = await send(`${host()}${path}`, {
101
80
  method,
102
81
  headers: {
103
82
  ...options.headers,
@@ -113,61 +92,73 @@ var SuperwallApi = class SuperwallApi {
113
92
  }
114
93
  if (res.status === 204) return void 0;
115
94
  return await res.json();
116
- }
117
- async fetch(url, init) {
118
- try {
119
- return await fetch(url, init);
120
- } catch (error) {
121
- throw new ApiUnreachableError(this.base(), error);
122
- }
123
- }
124
- get(path, options) {
125
- return this.request("GET", path, void 0, options);
126
- }
127
- post(path, body, options) {
128
- return this.request("POST", path, body, options);
129
- }
130
- put(path, body, options) {
131
- return this.request("PUT", path, body, options);
132
- }
133
- patch(path, body, options) {
134
- return this.request("PATCH", path, body, options);
135
- }
136
- del(path, options) {
137
- return this.request("DELETE", path, void 0, options);
138
- }
139
- async postText(path, body) {
140
- const { token, session } = await resolveAuthToken(this.session);
141
- this.session = session;
142
- const res = await this.fetch(`${this.base()}${path}`, {
143
- method: "POST",
144
- headers: {
145
- authorization: `Bearer ${token}`,
146
- accept: "text/plain",
147
- "content-type": "text/plain; charset=utf-8"
148
- },
149
- body
150
- });
151
- if (!res.ok) {
152
- const text = await res.text().catch(() => "");
153
- throw new ApiError(`POST ${path}`, res.status, text);
154
- }
155
- return res.text();
156
- }
157
- async list(path) {
158
- const out = [];
159
- let after;
160
- for (let i = 0; i < 50; i++) {
161
- const url = `${path}${path.includes("?") ? "&" : "?"}limit=100${after ? `&starting_after=${after}` : ""}`;
162
- const page = await this.get(url);
163
- out.push(...page.data);
164
- if (!page.has_more || page.data.length === 0) break;
165
- const last = page.data[page.data.length - 1];
166
- if (last?.id == null) break;
167
- after = String(last.id);
95
+ };
96
+ const api = {
97
+ get org() {
98
+ const override = process.env.SUPERWALL_ORG_ID;
99
+ return {
100
+ id: override ?? session.orgId,
101
+ name: override ? void 0 : session.orgName,
102
+ count: session.orgCount ?? 1
103
+ };
104
+ },
105
+ get userEmail() {
106
+ return session.userEmail;
107
+ },
108
+ get host() {
109
+ return host();
110
+ },
111
+ setOrg(org) {
112
+ session = {
113
+ ...session,
114
+ orgId: org.id,
115
+ orgName: org.name
116
+ };
117
+ saveSession(session);
118
+ },
119
+ get: (path, options) => request("GET", path, void 0, options),
120
+ post: (path, body, options) => request("POST", path, body, options),
121
+ put: (path, body, options) => request("PUT", path, body, options),
122
+ patch: (path, body, options) => request("PATCH", path, body, options),
123
+ del: (path, options) => request("DELETE", path, void 0, options),
124
+ async postText(path, body) {
125
+ const token = await authorized();
126
+ const res = await send(`${host()}${path}`, {
127
+ method: "POST",
128
+ headers: {
129
+ authorization: `Bearer ${token}`,
130
+ accept: "text/plain",
131
+ "content-type": "text/plain; charset=utf-8"
132
+ },
133
+ body
134
+ });
135
+ if (!res.ok) {
136
+ const text = await res.text().catch(() => "");
137
+ throw new ApiError(`POST ${path}`, res.status, text);
138
+ }
139
+ return res.text();
140
+ },
141
+ async list(path) {
142
+ const out = [];
143
+ let after;
144
+ for (let page = 0; page < PAGE_LIMIT; page++) {
145
+ const url = `${path}${path.includes("?") ? "&" : "?"}limit=100${after ? `&starting_after=${after}` : ""}`;
146
+ const batch = await api.get(url);
147
+ out.push(...batch.data);
148
+ if (!batch.has_more || batch.data.length === 0) break;
149
+ const last = batch.data[batch.data.length - 1];
150
+ if (last?.id == null) break;
151
+ after = String(last.id);
152
+ }
153
+ return out;
168
154
  }
169
- return out;
170
- }
155
+ };
156
+ return api;
157
+ };
158
+ const superwallApi = () => {
159
+ const session = loadSession();
160
+ if (!session) throw new NotLoggedInError();
161
+ return createSuperwallApi(session);
171
162
  };
172
163
 
173
164
  //#endregion
@@ -184,7 +175,7 @@ async function executeCommand(definition, argv, runtime = {}) {
184
175
  const outputMode = json ? "json" : environmentNonInteractive ? "text" : "rich";
185
176
  const interactive = definition.interaction !== "none" && !json && !explicitNonInteractive && !environmentNonInteractive;
186
177
  const installDir = resolve(argv.installDir ?? process.cwd());
187
- const ui = runtime.renderer?.(outputMode) ?? selectRenderer({ mode: outputMode });
178
+ const ui = runtime.renderer ? useRenderer(runtime.renderer(outputMode)) : selectRenderer({ mode: outputMode });
188
179
  const stdout = runtime.stdout ?? process.stdout;
189
180
  const output = createCommandOutput(outputMode, ui, { stdout });
190
181
  if (json && definition.output !== "json" && definition.output !== "both") {
@@ -203,7 +194,7 @@ async function executeCommand(definition, argv, runtime = {}) {
203
194
  track("workflow started", { workflow: definition.name });
204
195
  }
205
196
  try {
206
- const api = resolveApi(definition.auth ?? "none", runtime.api ?? SuperwallApi.fromSession);
197
+ const api = resolveApi(definition.auth ?? "none", runtime.api ?? superwallApi);
207
198
  const context = {
208
199
  argv,
209
200
  ui,
@@ -284,4 +275,4 @@ function normalizeError(error) {
284
275
  }
285
276
 
286
277
  //#endregion
287
- export { ApiError as n, SuperwallApi as r, defineCommand as t };
278
+ export { superwallApi as i, ApiError as n, createSuperwallApi as r, defineCommand as t };
@@ -1,22 +1,22 @@
1
- import "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import "./token-DHRH8cxi.js";
5
- import { t as defineCommand } from "./command-B12qooZb.js";
6
- import "./ui-C4ncRJqd.js";
7
- import "./skills-BwXcAVIf.js";
1
+ import "./output-DmEUd7Xa.js";
2
+ import "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import "./token-CwKfB5Ic.js";
5
+ import { t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import "./ui-Lqt_zFOr.js";
7
+ import "./skills-BDMwScz3.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import "./login-D5TjqsXJ.js";
10
- import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-BrikLKx5.js";
11
- import "./hosted-BCwzTTEw.js";
12
- import { t as detectExisting } from "./existing-CECenoHS.js";
13
- import "./spinner-gOxIMz-V.js";
14
- import { f as listApplications, m as listProjects, n as createApplication, y as platformLabel } from "./resources-CVrWwA1K.js";
15
- import "./org-B2gy9Pmu.js";
16
- import { r as resolveScopeFromKey } from "./bind-KZhPLTdC.js";
17
- import { a as projectPackageName, i as requireApi, l as requirePlatform, m as writeApp, r as LoginRequiredError, t as gitAvailable } from "./git-CCJwXufi.js";
18
- import "./actions-DYQTxMXS.js";
19
- import "./app-rYAP19Jo.js";
9
+ import "./login-DGc6GQqT.js";
10
+ import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-HfLbAkLc.js";
11
+ import "./hosted-q7_n5udj.js";
12
+ import { t as detectExisting } from "./existing-D7p2hnhq.js";
13
+ import "./spinner-B9dT3DBY.js";
14
+ import { f as listApplications, m as listProjects, n as createApplication, y as platformLabel } from "./resources-s64mBHaC.js";
15
+ import "./org-Cg25bcsj.js";
16
+ import { r as resolveScopeFromKey } from "./bind-CBLvcdzo.js";
17
+ import { a as projectPackageName, i as requireApi, l as requirePlatform, m as writeApp, r as LoginRequiredError, t as gitAvailable } from "./git-C0x00Urq.js";
18
+ import "./actions-C0sUjLGZ.js";
19
+ import "./app-vECLIkWi.js";
20
20
  import pc from "picocolors";
21
21
  import { promisify } from "node:util";
22
22
  import * as fs from "node:fs";
@@ -1,22 +1,22 @@
1
- import { k as VERSION } from "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import "./token-DHRH8cxi.js";
5
- import { t as defineCommand } from "./command-B12qooZb.js";
6
- import { n as ui } from "./ui-C4ncRJqd.js";
7
- import "./skills-BwXcAVIf.js";
1
+ import { g as VERSION } from "./output-DmEUd7Xa.js";
2
+ import "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import "./token-CwKfB5Ic.js";
5
+ import { t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import { n as ui } from "./ui-Lqt_zFOr.js";
7
+ import "./skills-BDMwScz3.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import "./login-D5TjqsXJ.js";
10
- import "./scan-BrikLKx5.js";
11
- import "./hosted-BCwzTTEw.js";
12
- import "./spinner-gOxIMz-V.js";
13
- import { S as pushPaywallVersion, T as versionProducts, b as promotePaywallVersion, f as listApplications } from "./resources-CVrWwA1K.js";
14
- import "./org-B2gy9Pmu.js";
15
- import "./bind-KZhPLTdC.js";
16
- import { f as readLock, i as requireApi, o as writeProjectScaffold, u as resolveApps } from "./git-CCJwXufi.js";
17
- import "./actions-DYQTxMXS.js";
18
- import "./app-rYAP19Jo.js";
19
- import { C as syncAssets, D as writeProjectTypes, E as collectProjectDeclarations, S as requireAssets, T as loadFramework, _ as planTargets, a as requireProject, b as resolveBinding, d as pushSource, f as collectSourceFiles, h as projectForApplication, i as projectDirs, m as fetchProducts, p as warnNotPortable, r as projectDir, t as LAYOUT_HINT, w as frameworkVersion, x as assetBaseUrl, y as wantedPlatforms } from "./pipeline-ChRDxU9b.js";
9
+ import "./login-DGc6GQqT.js";
10
+ import "./scan-HfLbAkLc.js";
11
+ import "./hosted-q7_n5udj.js";
12
+ import "./spinner-B9dT3DBY.js";
13
+ import { S as pushPaywallVersion, T as versionProducts, b as promotePaywallVersion, f as listApplications } from "./resources-s64mBHaC.js";
14
+ import "./org-Cg25bcsj.js";
15
+ import "./bind-CBLvcdzo.js";
16
+ import { f as readLock, i as requireApi, o as writeProjectScaffold, u as resolveApps } from "./git-C0x00Urq.js";
17
+ import "./actions-C0sUjLGZ.js";
18
+ import "./app-vECLIkWi.js";
19
+ import { C as syncAssets, D as writeProjectTypes, E as collectProjectDeclarations, S as requireAssets, T as loadFramework, _ as planTargets, a as projectDir, b as resolveBinding, d as pushSource, f as collectSourceFiles, h as projectForApplication, l as LAYOUT_HINT, m as fetchProducts, o as projectDirs, p as warnNotPortable, s as requireProject, w as frameworkVersion, x as assetBaseUrl, y as wantedPlatforms } from "./pipeline-B3c4tjfA.js";
20
20
  import pc from "picocolors";
21
21
  import * as fs from "node:fs";
22
22
  import * as path from "node:path";
@@ -132,11 +132,29 @@ const detectLocalScheme = async (roots) => {
132
132
  }
133
133
  }
134
134
  };
135
+ const APP_MARKERS = [
136
+ "package.json",
137
+ "app.json",
138
+ "app.config.json",
139
+ "Podfile",
140
+ "ios",
141
+ "android",
142
+ ".git"
143
+ ];
144
+ const looksLikeAppRoot = (dir) => {
145
+ if (APP_MARKERS.some((marker) => fs.existsSync(path.join(dir, marker)))) return true;
146
+ try {
147
+ return fs.readdirSync(dir).some((entry) => entry.endsWith(".xcodeproj") || entry.endsWith(".xcworkspace"));
148
+ } catch {
149
+ return false;
150
+ }
151
+ };
135
152
  const schemeSearchRoots = (project) => {
136
153
  const root = path.resolve(project.root);
137
154
  const superwallDir = path.resolve(project.superwallDir);
138
155
  const roots = [root];
139
- if (root === superwallDir) roots.push(path.dirname(root));
156
+ const parent = path.dirname(root);
157
+ if (root === superwallDir && parent !== root && looksLikeAppRoot(parent)) roots.push(parent);
140
158
  return roots;
141
159
  };
142
160
  const appScheme = async (roots, remote) => {
@@ -1,14 +1,14 @@
1
- import { a as apiKeyFromEnv } from "./telemetry-CpIXSAbQ.js";
2
- import "./json-C3hPIMkI.js";
3
- import "./update-BdcpwRu_.js";
4
- import { i as loadSession } from "./token-DHRH8cxi.js";
5
- import { t as defineCommand } from "./command-B12qooZb.js";
6
- import { a as fg, i as THEME, n as ui } from "./ui-C4ncRJqd.js";
1
+ import { _ as apiKeyFromEnv } from "./output-DmEUd7Xa.js";
2
+ import "./telemetry-vvgwHwjA.js";
3
+ import "./update-DeK9OQ5x.js";
4
+ import { i as loadSession } from "./token-CwKfB5Ic.js";
5
+ import { t as defineCommand } from "./command-Bav1fWvv.js";
6
+ import { a as THEME, n as ui, o as fg } from "./ui-Lqt_zFOr.js";
7
7
  import "./spawn-DSoTXy_j.js";
8
- import { t as scanProject } from "./scan-BrikLKx5.js";
9
- import { t as detectDrivers } from "./drivers-D6Ka26e2.js";
10
- import "./hosted-BCwzTTEw.js";
11
- import { t as detectExisting } from "./existing-CECenoHS.js";
8
+ import { t as scanProject } from "./scan-HfLbAkLc.js";
9
+ import { t as detectDrivers } from "./drivers-DSkM9kMJ.js";
10
+ import "./hosted-q7_n5udj.js";
11
+ import { t as detectExisting } from "./existing-D7p2hnhq.js";
12
12
 
13
13
  //#region src/commands/account/doctor.ts
14
14
  const runDoctor = defineCommand({
@@ -1,6 +1,6 @@
1
- import { k as VERSION } from "./telemetry-CpIXSAbQ.js";
1
+ import { g as VERSION } from "./output-DmEUd7Xa.js";
2
2
  import { n as readVersion, r as spawnStream, t as onPath } from "./spawn-DSoTXy_j.js";
3
- import { n as getHostedAuthToken, r as getHostedStatus, t as getHostedAnthropicBaseUrl } from "./hosted-BCwzTTEw.js";
3
+ import { n as getHostedAuthToken, r as getHostedStatus, t as getHostedAnthropicBaseUrl } from "./hosted-q7_n5udj.js";
4
4
  import { tmpdir } from "node:os";
5
5
  import { basename, join } from "node:path";
6
6
  import { readFile, rm } from "node:fs/promises";