@superwall/cli 2.6.0-beta.1 → 2.6.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 (147) hide show
  1. package/README.md +47 -16
  2. package/dist/{apple-Bmt_iywx.js → apple-D-rfsuDA.js} +17 -19
  3. package/dist/{approve-D2UgqaRx.js → approve-aPc5RoXB.js} +14 -13
  4. package/dist/{assets-B_quADds.js → assets-PyuXe45Y.js} +3 -3
  5. package/dist/auth.d.ts +11 -4
  6. package/dist/auth.js +4 -5
  7. package/dist/base-CAU0hWoI.js +82 -0
  8. package/dist/{billing-ZIETn0j4.js → billing-Dt6L_l9R.js} +3 -3
  9. package/dist/{build-BWjXurjs.js → build-CY5FnMNY.js} +35 -16
  10. package/dist/config-DOp5oChe.js +377 -0
  11. package/dist/{create-C3uklw-U.js → create-BZL5VH4L.js} +41 -41
  12. package/dist/{create-BCIgjRHn.js → create-D6w3UL0m.js} +9 -9
  13. package/dist/create-DM5Y1Pyk.js +18 -0
  14. package/dist/{doctor-D2Q1EZe8.js → doctor-C9FR0qw3.js} +50 -10
  15. package/dist/entry.js +45 -40
  16. package/dist/{environment-BocmdvZ-.js → environment-sE2wZYdg.js} +1 -1
  17. package/dist/{drivers-BQkO5tHs.js → existing--peXpOZj.js} +305 -8
  18. package/dist/framework-DW5fqjh4.js +65 -0
  19. package/dist/{source-BccdO4aL.js → git-Hf9Wc7Hp.js} +34 -92
  20. package/dist/{held-Bykbwy-m.js → held-CUBCOCGP.js} +8 -8
  21. package/dist/held-DVxvPMSG.js +15 -0
  22. package/dist/{install-dXZZ79Oe.js → install-C5d82gZF.js} +15 -17
  23. package/dist/{integrate-DiSjlOjC.js → integrate-D8J_X1bj.js} +33 -38
  24. package/dist/{login-5sWIKDI2.js → login-C6X7JrhM.js} +8 -9
  25. package/dist/{login-Jp6E6d2e.js → login-DXhm9L0F.js} +3 -3
  26. package/dist/login-et319ESO.js +13 -0
  27. package/dist/{lookup-CWzVfPpq.js → lookup-DqmIbUkv.js} +28 -4
  28. package/dist/{migrate-BKiOUsMY.js → migrate-BYF6hKZ2.js} +66 -45
  29. package/dist/{notification-url-BDBxbwZq.js → notification-url-Bo54nkXv.js} +4 -4
  30. package/dist/{open-DNd49kT-.js → open-xdgXUzaF.js} +2 -2
  31. package/dist/{org-Dud1rF9f.js → org-BD8U3D1_.js} +4 -4
  32. package/dist/{organization-7vJA3uy1.js → organization-D-ZlB3qU.js} +4 -4
  33. package/dist/{orgs-Z0H9WOs1.js → orgs-DQQJ3sw_.js} +1 -2
  34. package/dist/{paths-CzTJVpfi.js → paths-CIlyzF2I.js} +1 -1
  35. package/dist/{playbook-DJ__edOW.js → playbook-ecggWGFi.js} +10 -14
  36. package/dist/{products-Cqq59DBQ.js → products-CJq_iXv5.js} +1 -1
  37. package/dist/{promote-DLtPSvmL.js → promote-QVMLGYlU.js} +27 -28
  38. package/dist/{pull-AoUmaiMK.js → pull-CCXhb2a7.js} +72 -26
  39. package/dist/{pull-D-YuT3e0.js → pull-CrdsfsAl.js} +33 -39
  40. package/dist/pull-h71pL3r_.js +30 -0
  41. package/dist/push-BIq6R8Ro.js +29 -0
  42. package/dist/push-D6pJM_vv.js +21 -0
  43. package/dist/{push-BMblzg_6.js → push-DJMGG7zW.js} +23 -12
  44. package/dist/{push-BrzMFd4Z.js → push-DiMDwGfe.js} +15 -8
  45. package/dist/{registry-DDU10_Ix.js → registry-BSnQXft4.js} +1288 -901
  46. package/dist/registry-YwzTfCNc.js +22 -0
  47. package/dist/{resolve-DpOSDDdr.js → resolve-DO7bPota.js} +52 -6
  48. package/dist/{resources-CptT7HD6.js → resources-XwvXA20E.js} +15 -2
  49. package/dist/{run-r3foWfhV.js → run-B-YvxfRc.js} +15 -17
  50. package/dist/scan-B36wkZmI.js +4 -0
  51. package/dist/{scan-nVQO7JLx.js → scan-ViBhmrB7.js} +1 -1
  52. package/dist/{scope-l1qGLsgz.js → scope-BLLUxbrA.js} +24 -18
  53. package/dist/{scope-ehZ7L1nj.js → scope-Cg1AdAfO.js} +33 -3
  54. package/dist/screenshot-file-Dix2Qynm.js +127 -0
  55. package/dist/{sdk-DEfQttek.js → sdk-BFunw4Hc.js} +1 -1
  56. package/dist/{framework-CLmf4swr.js → selection-C07e_GGY.js} +4 -54
  57. package/dist/{series-D2ZpZ8cx.js → series-B8NJK4yS.js} +1 -1
  58. package/dist/{server-DLARhh1k.js → server-CBtHzl9y.js} +40 -18
  59. package/dist/server-CZwSfzKe.js +33 -0
  60. package/dist/{base-ChTi42M0.js → session-BfVx50iA.js} +8 -83
  61. package/dist/{session-Z0BeaJPf.js → session-BlrwAdGN.js} +1 -1
  62. package/dist/session-Cip4j99n.js +5 -0
  63. package/dist/{migration-Z69tLeHC.js → setup-a4B72xJ8.js} +290 -28
  64. package/dist/skills/superwall/SKILL.md +37 -10
  65. package/dist/skills/superwall/references/api.md +66 -21
  66. package/dist/skills/superwall/references/asa.md +109 -64
  67. package/dist/skills/superwall/references/dashboard-links.md +65 -28
  68. package/dist/skills/superwall/references/data-analytics.md +1 -1
  69. package/dist/skills/superwall/workflows/dashboard/setup.md +15 -5
  70. package/dist/skills/superwall/workflows/integrate/flutter.md +9 -7
  71. package/dist/skills/superwall-artifacts/SKILL.md +7 -2
  72. package/dist/skills/superwall-artifacts/references/cli.md +4 -1
  73. package/dist/skills/superwall-framework/SKILL.md +197 -14
  74. package/dist/skills/superwall-framework/references/cli.md +98 -7
  75. package/dist/skills/superwall-framework/references/examples.md +2 -2
  76. package/dist/skills/superwall-framework/references/migrate-from-editor.md +5 -0
  77. package/dist/skills/superwall-framework/references/migrate-from-native.md +5 -0
  78. package/dist/{skills-421SFEyF.js → skills-BB1uIt8t.js} +139 -9
  79. package/dist/{skills-CdKwaTRS.js → skills-SnxFa2in.js} +8 -12
  80. package/dist/source-DQs6iLtC.js +82 -0
  81. package/dist/{source-push-B4s6r9bB.js → source-push-w7miTr6m.js} +38 -14
  82. package/dist/{spinner-DPdBlZe2.js → spinner-BQp7fQvK.js} +7 -5
  83. package/dist/{starter-0OdVPH4l.js → starter-BlJ_InZJ.js} +16 -6
  84. package/dist/{status-Dsc7d3z2.js → status-DxsIw9zq.js} +9 -11
  85. package/dist/{output-Ggzq5_-t.js → storage-BR6imSqm.js} +40 -1
  86. package/dist/storekit-BqyujKQ_.js +203 -0
  87. package/dist/storekit-ELVCMF0X.js +15 -0
  88. package/dist/{bind-ClFjTt0U.js → theme-Ed0gz6hr.js} +29 -6
  89. package/dist/token-CWQ6tdva.js +100 -0
  90. package/dist/tools-skills/animate-onboarding/SKILL.md +1 -1
  91. package/dist/tools-skills/mobile-design/SKILL.md +1 -1
  92. package/dist/tools-skills/onboarding-questions/SKILL.md +1 -1
  93. package/dist/tools-skills/superwall/SKILL.md +43 -17
  94. package/dist/tools-skills/superwall/references/api.md +74 -24
  95. package/dist/tools-skills/superwall/references/asa.md +109 -64
  96. package/dist/tools-skills/superwall/references/dashboard-links.md +65 -28
  97. package/dist/tools-skills/superwall/references/data-analytics.md +1 -1
  98. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +4 -3
  99. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +21 -8
  100. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +9 -7
  101. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +4 -3
  102. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +2 -2
  103. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +4 -3
  104. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +4 -3
  105. package/dist/tools-skills/superwall-editor/SKILL.md +2 -3
  106. package/dist/tools.d.ts +6 -1
  107. package/dist/tools.js +1290 -747
  108. package/dist/{try-B8FYkTvQ.js → try-C3HW3hPZ.js} +20 -22
  109. package/dist/{lock-DgSx-p8Y.js → types-Dc9U_4kp.js} +86 -80
  110. package/dist/upgrade-Cw9jVt-r.js +348 -0
  111. package/dist/upgrade-DVsonzDF.js +27 -0
  112. package/package.json +11 -3
  113. package/dist/client-CyrYJzBF.js +0 -180
  114. package/dist/config-CGcG7GOt.js +0 -113
  115. package/dist/create-7HDW3DCl.js +0 -20
  116. package/dist/existing-Cl5x6_5u.js +0 -97
  117. package/dist/held-Chw3BtBV.js +0 -17
  118. package/dist/log-C0MDCfA2.js +0 -62
  119. package/dist/login-DZ8Pipf6.js +0 -17
  120. package/dist/pull-C1xm2zqG.js +0 -36
  121. package/dist/push-B42D8fKf.js +0 -22
  122. package/dist/push-Co5jk6Kr.js +0 -30
  123. package/dist/run-c1O2_8pp.js +0 -100
  124. package/dist/scan-D86kLtM7.js +0 -4
  125. package/dist/screenshot-file-XAS0Xy0e.js +0 -16
  126. package/dist/server-BEcsQaPu.js +0 -29
  127. package/dist/session-Csuaw6RU.js +0 -6
  128. package/dist/setup-C6NFy14d.js +0 -217
  129. package/dist/spawn-DmmmHIP-.js +0 -71
  130. package/dist/storage-DT_wxwJ8.js +0 -41
  131. package/dist/storekit-B9M2raxe.js +0 -47
  132. package/dist/storekit-BWZf-fNE.js +0 -17
  133. package/dist/telemetry-ovPiseFm.js +0 -56
  134. package/dist/theme-DUsCh-Vd.js +0 -25
  135. package/dist/token-Bu3FaRkv.js +0 -70
  136. package/dist/upgrade-B7TmvEPP.js +0 -206
  137. package/dist/upgrade-CAHyrWUL.js +0 -7
  138. /package/dist/{browser-Bp3yRKlU.js → browser-BVjaf98V.js} +0 -0
  139. /package/dist/{client-BJQXl62Q.js → client-BwYhzITp.js} +0 -0
  140. /package/dist/{design-lint-CiFc78aM.js → design-lint-mgO-2SGS.js} +0 -0
  141. /package/dist/{devtools-ByZ6XYnn.js → devtools-B6Vp6HMy.js} +0 -0
  142. /package/dist/{input-MDd67UIp.js → input-DOT_2Zvb.js} +0 -0
  143. /package/dist/{project-NoMtbMyl.js → project-BomArwSj.js} +0 -0
  144. /package/dist/{reports-HYVp169R.js → reports-hbxsd3Zo.js} +0 -0
  145. /package/dist/{storage-Bdz5AmqS.d.ts → storage-Bh3wT1Rn.d.ts} +0 -0
  146. /package/dist/{timing-Ca0TXY-A.js → timing-BKEEIBij.js} +0 -0
  147. /package/dist/{ui-D_qf3Gvw.js → ui-hFgji1e8.js} +0 -0
@@ -0,0 +1,377 @@
1
+ import { i as NotLoggedInError, n as resolveAuthToken } from "./token-CWQ6tdva.js";
2
+ import { a as resolveApiHost, f as formatJson, n as readSession, v as readJson, y as state } from "./storage-BR6imSqm.js";
3
+ import { b as USER_AGENT } from "./environment-sE2wZYdg.js";
4
+
5
+ //#region src/core/api/client.ts
6
+ const BODY_SNIPPET = 200;
7
+ function parseErrorEnvelope(body) {
8
+ let parsed;
9
+ try {
10
+ parsed = JSON.parse(body);
11
+ } catch {
12
+ return;
13
+ }
14
+ if (typeof parsed !== "object" || parsed === null) return void 0;
15
+ const text = (key) => {
16
+ const value = Reflect.get(parsed, key);
17
+ return typeof value === "string" && value !== "" ? value : void 0;
18
+ };
19
+ const message = text("message");
20
+ if (message === void 0) return void 0;
21
+ return {
22
+ message,
23
+ detail: {
24
+ type: text("type"),
25
+ code: text("code"),
26
+ param: text("param"),
27
+ docUrl: text("doc_url"),
28
+ resourceType: text("resource_type"),
29
+ resourceId: text("resource_id")
30
+ }
31
+ };
32
+ }
33
+ var ApiError = class extends Error {
34
+ detail;
35
+ request;
36
+ envelope;
37
+ hint;
38
+ constructor(request, status, body) {
39
+ const envelope = body === void 0 ? void 0 : parseErrorEnvelope(body);
40
+ const snippet = body?.trim().slice(0, BODY_SNIPPET);
41
+ super(envelope?.message ?? (snippet ? `HTTP ${status} — ${snippet}` : `HTTP ${status}`));
42
+ this.status = status;
43
+ this.body = body;
44
+ this.detail = envelope?.detail ?? {};
45
+ this.request = request;
46
+ this.envelope = envelope !== void 0;
47
+ }
48
+ };
49
+ const DROPPED_CODES = new Set([
50
+ "EPIPE",
51
+ "ECONNRESET",
52
+ "ECONNABORTED",
53
+ "UND_ERR_SOCKET",
54
+ "UND_ERR_CLOSED"
55
+ ]);
56
+ const DROPPED_MESSAGE = /other side closed|socket hang up|socket connection was closed/i;
57
+ function fetchFailureOf(error) {
58
+ let found = {};
59
+ const seen = /* @__PURE__ */ new Set();
60
+ let current = error;
61
+ while (typeof current === "object" && current !== null && !seen.has(current)) {
62
+ seen.add(current);
63
+ const code = Reflect.get(current, "code");
64
+ const message = Reflect.get(current, "message");
65
+ const useful = typeof message === "string" && message !== "" && message !== "fetch failed" ? message : void 0;
66
+ if (typeof code === "string" && code !== "") found = {
67
+ code,
68
+ message: useful
69
+ };
70
+ else if (found.code === void 0 && useful !== void 0) found = { message: useful };
71
+ const errors = Reflect.get(current, "errors");
72
+ current = Reflect.get(current, "cause") ?? (Array.isArray(errors) ? errors[0] : void 0);
73
+ }
74
+ return found;
75
+ }
76
+ const failureLabel = ({ code, message }) => {
77
+ if (code === void 0) return message;
78
+ return message === void 0 || message.includes(code) ? code : `${code}: ${message}`;
79
+ };
80
+ const isTimeout = (error) => error instanceof Error && error.name === "TimeoutError";
81
+ var ApiUnreachableError = class extends Error {
82
+ /** The connection opened and then dropped, so the API may or may not have got the request. */
83
+ dropped;
84
+ /** The API didn't answer before the deadline, so it may or may not have got the request. */
85
+ timedOut;
86
+ code;
87
+ constructor(host, cause, deadline) {
88
+ if (deadline !== void 0) {
89
+ super(`The Superwall API at ${host} didn't answer within ${deadline.ms / 1e3}s.\n` + (deadline.write ? " The change may or may not have been applied. Check before sending it again." : " Try again."));
90
+ this.name = "ApiUnreachableError";
91
+ this.cause = cause;
92
+ this.dropped = false;
93
+ this.timedOut = true;
94
+ return;
95
+ }
96
+ const local = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])/.test(host);
97
+ const failure = fetchFailureOf(cause);
98
+ const dropped = failure.code !== void 0 && DROPPED_CODES.has(failure.code) || DROPPED_MESSAGE.test(failure.message ?? "");
99
+ const label = failureLabel(failure);
100
+ const why = label === void 0 ? "" : ` (${label})`;
101
+ super(dropped ? `Lost the connection ${failure.code === "EPIPE" ? "while sending to" : "to"} the Superwall API at ${host}${why}.\n It closed before the request finished. Try again.` : `Couldn't reach the Superwall API at ${host}${why}.\n` + (local ? " That's a local address — start the API, or unset SUPERWALL_API_HOST to use production." : " Check your network or proxy, then try again."));
102
+ this.name = "ApiUnreachableError";
103
+ this.cause = cause;
104
+ this.dropped = dropped;
105
+ this.timedOut = false;
106
+ if (failure.code !== void 0) this.code = failure.code;
107
+ }
108
+ };
109
+ const PAGE_LIMIT = 50;
110
+ const GET_RETRIES = 3;
111
+ const RETRYABLE = new Set([
112
+ 429,
113
+ 502,
114
+ 503,
115
+ 504
116
+ ]);
117
+ const DROPPED_ATTEMPTS = 3;
118
+ const DROPPED_BACKOFF_MS = 250;
119
+ const REQUEST_TIMEOUT_MS = 6e4;
120
+ const TEXT_TIMEOUT_MS = 3e5;
121
+ async function parseApiError(request, res) {
122
+ const text = await res.text().catch(() => "");
123
+ return new ApiError(request, res.status, text);
124
+ }
125
+ const namesUserAgent = (headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "user-agent");
126
+ function retryDelay(res, retry) {
127
+ const after = Number(res.headers.get("retry-after"));
128
+ if (Number.isFinite(after) && after >= 0 && res.headers.has("retry-after")) return after * 1e3;
129
+ return 400 * 2 ** retry;
130
+ }
131
+ const createSuperwallApi = (initial, { userAgent = USER_AGENT(), timeoutMs = REQUEST_TIMEOUT_MS, textTimeoutMs = TEXT_TIMEOUT_MS } = {}) => {
132
+ let session = initial;
133
+ const host = () => resolveApiHost(session);
134
+ const send = async (url, init, ms = timeoutMs) => {
135
+ try {
136
+ return await fetch(url, {
137
+ ...init,
138
+ signal: AbortSignal.timeout(ms)
139
+ });
140
+ } catch (error) {
141
+ if (!isTimeout(error)) throw new ApiUnreachableError(host(), error);
142
+ throw new ApiUnreachableError(host(), error, {
143
+ ms,
144
+ write: init.method !== "GET"
145
+ });
146
+ }
147
+ };
148
+ const read$1 = async (body, deadline) => {
149
+ try {
150
+ return await body();
151
+ } catch (error) {
152
+ if (isTimeout(error)) throw new ApiUnreachableError(host(), error, deadline);
153
+ throw error;
154
+ }
155
+ };
156
+ const authorized = async () => {
157
+ const resolved = await resolveAuthToken(session);
158
+ session = resolved.session;
159
+ return resolved.token;
160
+ };
161
+ const request = async (method, path, body, options = {}) => {
162
+ const token = await authorized();
163
+ const once = () => {
164
+ return send(`${host()}${path}`, {
165
+ method,
166
+ headers: {
167
+ ...namesUserAgent(options.headers) ? {} : { "user-agent": userAgent },
168
+ ...options.headers,
169
+ authorization: `Bearer ${token}`,
170
+ accept: "application/json",
171
+ ...body !== void 0 ? { "content-type": "application/json" } : {}
172
+ },
173
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
174
+ });
175
+ };
176
+ const attempt = async () => {
177
+ for (let tried = 1;; tried++) try {
178
+ return await once();
179
+ } catch (error) {
180
+ if (!(options.idempotent === true && error instanceof ApiUnreachableError && error.dropped) || tried >= DROPPED_ATTEMPTS) throw error;
181
+ await new Promise((done) => setTimeout(done, DROPPED_BACKOFF_MS * 2 ** (tried - 1)));
182
+ }
183
+ };
184
+ let res = await attempt();
185
+ for (let retry = 0; method === "GET" && RETRYABLE.has(res.status) && retry < GET_RETRIES; retry++) {
186
+ await new Promise((done) => setTimeout(done, retryDelay(res, retry)));
187
+ res = await attempt();
188
+ }
189
+ if (!res.ok) throw await parseApiError(`${method} ${path}`, res);
190
+ if (res.status === 204) return void 0;
191
+ return read$1(() => res.json(), {
192
+ ms: timeoutMs,
193
+ write: method !== "GET"
194
+ });
195
+ };
196
+ const api = {
197
+ org: {},
198
+ get userEmail() {
199
+ return session.userEmail;
200
+ },
201
+ get host() {
202
+ return host();
203
+ },
204
+ forOrg: (id) => ({
205
+ ...api,
206
+ org: { id },
207
+ forOrg: api.forOrg
208
+ }),
209
+ get: (path, options) => request("GET", path, void 0, options),
210
+ post: (path, body, options) => request("POST", path, body, options),
211
+ put: (path, body, options) => request("PUT", path, body, options),
212
+ patch: (path, body, options) => request("PATCH", path, body, options),
213
+ del: (path, options) => request("DELETE", path, void 0, options),
214
+ async postText(path, body) {
215
+ const init = {
216
+ method: "POST",
217
+ headers: {
218
+ authorization: `Bearer ${await authorized()}`,
219
+ "user-agent": userAgent,
220
+ accept: "text/plain",
221
+ "content-type": "text/plain; charset=utf-8"
222
+ },
223
+ body
224
+ };
225
+ const res = await send(`${host()}${path}`, init, textTimeoutMs);
226
+ if (!res.ok) throw await parseApiError(`POST ${path}`, res);
227
+ return read$1(() => res.text(), {
228
+ ms: textTimeoutMs,
229
+ write: true
230
+ });
231
+ },
232
+ async list(path) {
233
+ const out = [];
234
+ let after;
235
+ for (let page = 0; page < PAGE_LIMIT; page++) {
236
+ const url = `${path}${path.includes("?") ? "&" : "?"}limit=100${after ? `&starting_after=${after}` : ""}`;
237
+ const batch = await api.get(url);
238
+ out.push(...batch.data);
239
+ if (!batch.has_more || batch.data.length === 0) break;
240
+ const last = batch.data.at(-1);
241
+ if (typeof last !== "object" || last === null || !("id" in last) || last.id == null) break;
242
+ after = String(last.id);
243
+ }
244
+ return out;
245
+ }
246
+ };
247
+ return api;
248
+ };
249
+ const superwallApi = () => {
250
+ const session = readSession();
251
+ if (!session) throw new NotLoggedInError();
252
+ return createSuperwallApi(session);
253
+ };
254
+ function withQuery(path, qs) {
255
+ const params = qs instanceof URLSearchParams ? qs : new URLSearchParams();
256
+ if (!(qs instanceof URLSearchParams)) for (const [key, value] of Object.entries(qs)) {
257
+ if (typeof value === "object" && value !== null) throw new Error(`Nested -d params aren't supported on GET/DELETE (got "${key}").`);
258
+ params.set(key, String(value));
259
+ }
260
+ const s = params.toString();
261
+ return s ? `${path}${path.includes("?") ? "&" : "?"}${s}` : path;
262
+ }
263
+
264
+ //#endregion
265
+ //#region src/core/state/config.ts
266
+ const FILE = "config.json";
267
+ function read() {
268
+ return readJson(state(), FILE) ?? {};
269
+ }
270
+ function write(config) {
271
+ state().write(FILE, `${formatJson(config)}\n`);
272
+ }
273
+ function readDefaultApp(projectId) {
274
+ return read().defaultApp?.[projectId];
275
+ }
276
+ function writeDefaultApp(projectId, applicationId) {
277
+ const config = read();
278
+ config.defaultApp = {
279
+ ...config.defaultApp ?? {},
280
+ [projectId]: applicationId
281
+ };
282
+ write(config);
283
+ }
284
+ function readOpenedOrgs() {
285
+ return read().openedOrgs ?? [];
286
+ }
287
+ function writeOpenedOrgs(ids) {
288
+ const config = read();
289
+ const next = [...new Set(ids)];
290
+ if (next.join() === (config.openedOrgs ?? []).join()) return;
291
+ config.openedOrgs = next;
292
+ write(config);
293
+ }
294
+ function readSkillsSync() {
295
+ return read().skillsSync;
296
+ }
297
+ function writeSkillsSync(sync) {
298
+ const config = read();
299
+ config.skillsSync = sync;
300
+ write(config);
301
+ }
302
+ function readAnonymousId() {
303
+ const config = read();
304
+ if (config.telemetry?.anonymousId) return config.telemetry.anonymousId;
305
+ const anonymousId = crypto.randomUUID();
306
+ config.telemetry = {
307
+ ...config.telemetry,
308
+ anonymousId
309
+ };
310
+ write(config);
311
+ return anonymousId;
312
+ }
313
+ function readOnboardedOrg() {
314
+ return read().onboarded?.org;
315
+ }
316
+ function writeOnboardedOrg(org) {
317
+ const config = read();
318
+ config.onboarded = {
319
+ ...config.onboarded,
320
+ org
321
+ };
322
+ write(config);
323
+ }
324
+ function readOnboardedApp(appPath) {
325
+ return read().onboarded?.apps?.[appPath];
326
+ }
327
+ function writeOnboardedApp(appPath, app) {
328
+ const config = read();
329
+ config.onboarded = {
330
+ ...config.onboarded,
331
+ apps: {
332
+ ...config.onboarded?.apps,
333
+ [appPath]: app
334
+ }
335
+ };
336
+ write(config);
337
+ }
338
+ function readUpdateCheck(tag = "latest") {
339
+ const config = read();
340
+ return tag === "next" ? config.updateCheckNext : config.updateCheck;
341
+ }
342
+ function writeUpdateCheck(check) {
343
+ const config = read();
344
+ if (check.tag === "next") config.updateCheckNext = check;
345
+ else config.updateCheck = check;
346
+ write(config);
347
+ }
348
+ function readAutoUpdate() {
349
+ return read().autoUpdate;
350
+ }
351
+ function writeAutoUpdate(update) {
352
+ const config = read();
353
+ config.autoUpdate = update;
354
+ write(config);
355
+ }
356
+ function readOnboardingIdempotencyKey() {
357
+ const config = read();
358
+ if (config.onboardingIdempotencyKey) return config.onboardingIdempotencyKey;
359
+ const key = crypto.randomUUID();
360
+ config.onboardingIdempotencyKey = key;
361
+ write(config);
362
+ return key;
363
+ }
364
+ function telemetryNoticeShown() {
365
+ return Boolean(read().telemetry?.noticeShown);
366
+ }
367
+ function writeTelemetryNoticeShown() {
368
+ const config = read();
369
+ config.telemetry = {
370
+ ...config.telemetry,
371
+ noticeShown: true
372
+ };
373
+ write(config);
374
+ }
375
+
376
+ //#endregion
377
+ export { withQuery as C, superwallApi as S, writeTelemetryNoticeShown as _, readOnboardedOrg as a, ApiUnreachableError as b, readSkillsSync as c, writeAutoUpdate as d, writeDefaultApp as f, writeSkillsSync as g, writeOpenedOrgs as h, readOnboardedApp as i, readUpdateCheck as l, writeOnboardedOrg as m, readAutoUpdate as n, readOnboardingIdempotencyKey as o, writeOnboardedApp as p, readDefaultApp as r, readOpenedOrgs as s, readAnonymousId as t, telemetryNoticeShown as u, writeUpdateCheck as v, createSuperwallApi as x, ApiError as y };
@@ -1,41 +1,36 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./theme-DUsCh-Vd.js";
12
- import "./log-C0MDCfA2.js";
13
- import "./scan-nVQO7JLx.js";
14
- import "./existing-Cl5x6_5u.js";
15
- import "./paths-CzTJVpfi.js";
16
- import "./orgs-Z0H9WOs1.js";
17
- import { O as field } from "./resources-CptT7HD6.js";
18
- import "./org-Dud1rF9f.js";
19
- import "./lookup-CWzVfPpq.js";
20
- import "./bind-ClFjTt0U.js";
21
- import "./login-5sWIKDI2.js";
22
- import "./skills-421SFEyF.js";
23
- import "./browser-Bp3yRKlU.js";
24
- import "./lock-DgSx-p8Y.js";
25
- import "./scope-ehZ7L1nj.js";
1
+ import "./token-CWQ6tdva.js";
2
+ import "./storage-BR6imSqm.js";
3
+ import "./environment-sE2wZYdg.js";
4
+ import "./config-DOp5oChe.js";
5
+ import "./skills-BB1uIt8t.js";
6
+ import "./scan-ViBhmrB7.js";
7
+ import { O as field } from "./resources-XwvXA20E.js";
8
+ import "./orgs-DQQJ3sw_.js";
9
+ import "./ui-hFgji1e8.js";
10
+ import "./spinner-BQp7fQvK.js";
11
+ import "./org-BD8U3D1_.js";
12
+ import "./theme-Ed0gz6hr.js";
13
+ import "./lookup-DqmIbUkv.js";
14
+ import "./types-Dc9U_4kp.js";
15
+ import { n as requireApi, r as projectPackageName, t as LoginRequiredError } from "./session-BfVx50iA.js";
16
+ import "./existing--peXpOZj.js";
17
+ import "./paths-CIlyzF2I.js";
18
+ import { C as starterConfig, E as slugOf, T as writeTemplate, _ as scaffoldFromPaywall, a as devCommand, g as projectDirOf, h as offerMigration, i as detectPackageManager, l as selectWorkspaceInstallNote, n as connectApp, o as initGit, p as migrationFor, r as detectHostApp, s as installDependencies, t as alreadyAProject, u as uniqueSurfaceId, w as writeSurfaceFiles } from "./setup-a4B72xJ8.js";
19
+ import "./framework-DW5fqjh4.js";
20
+ import "./login-C6X7JrhM.js";
21
+ import "./browser-BVjaf98V.js";
22
+ import "./login-DXhm9L0F.js";
23
+ import "./git-Hf9Wc7Hp.js";
24
+ import "./scope-Cg1AdAfO.js";
25
+ import "./upgrade-Cw9jVt-r.js";
26
26
  import { i as downloadRepoDir, n as PUBLIC_REPO, r as RepoDownloadError, t as PUBLIC_REF } from "./download-DhGd4hOB.js";
27
- import { a as projectPackageName, i as requireApi, r as LoginRequiredError } from "./base-ChTi42M0.js";
28
- import "./framework-CLmf4swr.js";
29
- import "./run-c1O2_8pp.js";
30
- import "./drivers-BQkO5tHs.js";
31
- import { _ as slugOf, c as scaffoldFromPaywall, g as writeTemplate, h as writeSurfaceFiles, i as migrationFor, m as starterConfig, o as offerMigration, s as projectDirOf } from "./migration-Z69tLeHC.js";
32
- import "./login-Jp6E6d2e.js";
33
- import "./source-BccdO4aL.js";
34
- import { a as devCommand, c as uniqueSurfaceId, i as detectPackageManager, n as connectApp, o as initGit, r as detectHostApp, s as installDependencies, t as alreadyAProject } from "./setup-C6NFy14d.js";
35
- import "./assets-B_quADds.js";
36
- import "./source-push-B4s6r9bB.js";
37
- import "./server-DLARhh1k.js";
38
- import { i as startStudio, n as migrationNextSteps, t as askStudio } from "./open-DNd49kT-.js";
27
+ import "./base-CAU0hWoI.js";
28
+ import "./selection-C07e_GGY.js";
29
+ import "./source-DQs6iLtC.js";
30
+ import "./assets-PyuXe45Y.js";
31
+ import "./source-push-w7miTr6m.js";
32
+ import "./server-CBtHzl9y.js";
33
+ import { i as startStudio, n as migrationNextSteps, t as askStudio } from "./open-xdgXUzaF.js";
39
34
  import * as fs from "node:fs";
40
35
  import * as path from "node:path";
41
36
  import pc from "picocolors";
@@ -218,18 +213,23 @@ async function runCreate(ctx, options, deps = runtime) {
218
213
  else ui.warn(`${error instanceof Error ? error.message : String(error)}\nSkipping — the first \`superwall push\` connects you.`);
219
214
  }
220
215
  const manager = await detectPackageManager(root);
221
- const installed = options.install && await installDependencies(ui, target, manager);
222
- await initGit(ui, root);
216
+ const install = options.install ? await installDependencies(ui, target, manager) : {
217
+ installed: false,
218
+ command: `${manager} install`
219
+ };
220
+ if (options.git) await initGit(ui, root);
223
221
  const rebuild = await offerRebuild(ctx, options, migration, deps);
224
222
  const integrate = detected?.existing.fullyIntegrated ? [] : [{
225
223
  label: "superwall integrate",
226
224
  children: [{ label: "Set up the SDK in your app" }]
227
225
  }];
228
- const dev = installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`;
226
+ const dev = install.installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${install.command} && ${devCommand(manager)}`;
227
+ const note = install.installed || install.command !== `${manager} install` ? void 0 : selectWorkspaceInstallNote(manager, target);
228
+ const devSteps = [{ label: "Open the studio" }, ...note === void 0 ? [] : [{ label: note }]];
229
229
  ui.step("Next steps");
230
230
  ui.list({ items: from === void 0 ? [{
231
231
  label: dev,
232
- children: [{ label: "Open the studio" }]
232
+ children: devSteps
233
233
  }, ...integrate] : [...migrationNextSteps(rebuild.studio !== void 0, "superwall", from, rebuild.choice).map((label) => ({ label })), ...integrate] });
234
234
  if (rebuild.studio !== void 0) await deps.startStudio(target, rebuild.studio.surfaceId);
235
235
  }
@@ -1,12 +1,12 @@
1
- import { r as formatJson, t as blocks } from "./output-Ggzq5_-t.js";
2
- import { C as appleCredentialsFromEnv, m as ENV_APPLE_PASSWORD, p as ENV_APPLE_ID, x as VERSION } from "./environment-BocmdvZ-.js";
3
- import { t as ApiError } from "./client-CyrYJzBF.js";
4
- import { i as savedKey, m as KEY_LABEL, n as testModeWarning, o as chooseIosApp, s as resolveApp, t as upsertHeldKey, x as keyKind, y as findIntegrations } from "./held-Bykbwy-m.js";
5
- import { t as apiCall } from "./spinner-DPdBlZe2.js";
6
- import { n as SUPERWALL_HOME } from "./paths-CzTJVpfi.js";
7
- import { A as listField, M as textField, O as field, j as parseJson } from "./resources-CptT7HD6.js";
8
- import { c as replaceAppPurchaseKey, s as replaceAppAscKey } from "./client-BJQXl62Q.js";
9
- import { t as timing } from "./timing-Ca0TXY-A.js";
1
+ import { f as formatJson, u as blocks } from "./storage-BR6imSqm.js";
2
+ import { C as appleCredentialsFromEnv, m as ENV_APPLE_PASSWORD, p as ENV_APPLE_ID, x as VERSION } from "./environment-sE2wZYdg.js";
3
+ import { y as ApiError } from "./config-DOp5oChe.js";
4
+ import { i as savedKey, m as KEY_LABEL, n as testModeWarning, o as chooseIosApp, s as resolveApp, t as upsertHeldKey, x as keyKind, y as findIntegrations } from "./held-CUBCOCGP.js";
5
+ import { A as listField, M as textField, O as field, j as parseJson } from "./resources-XwvXA20E.js";
6
+ import { t as apiCall } from "./spinner-BQp7fQvK.js";
7
+ import { n as SUPERWALL_HOME } from "./paths-CIlyzF2I.js";
8
+ import { c as replaceAppPurchaseKey, s as replaceAppAscKey } from "./client-BwYhzITp.js";
9
+ import { t as timing } from "./timing-BKEEIBij.js";
10
10
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import { createHash, pbkdf2Sync, randomBytes } from "node:crypto";
@@ -0,0 +1,18 @@
1
+ import "./token-CWQ6tdva.js";
2
+ import "./storage-BR6imSqm.js";
3
+ import "./environment-sE2wZYdg.js";
4
+ import "./config-DOp5oChe.js";
5
+ import "./held-CUBCOCGP.js";
6
+ import "./resources-XwvXA20E.js";
7
+ import "./orgs-DQQJ3sw_.js";
8
+ import "./ui-hFgji1e8.js";
9
+ import "./spinner-BQp7fQvK.js";
10
+ import "./org-BD8U3D1_.js";
11
+ import "./lookup-DqmIbUkv.js";
12
+ import "./paths-CIlyzF2I.js";
13
+ import "./scope-BLLUxbrA.js";
14
+ import "./client-BwYhzITp.js";
15
+ import "./timing-BKEEIBij.js";
16
+ import { i as runAscKeysCreate, n as keyAccess, r as keyRole, t as createAndSaveKey } from "./create-D6w3UL0m.js";
17
+
18
+ export { createAndSaveKey, keyAccess, keyRole, runAscKeysCreate };
@@ -1,13 +1,28 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import { S as apiKeyFromEnv } from "./environment-BocmdvZ-.js";
4
- import { n as readSession } from "./storage-DT_wxwJ8.js";
5
- import "./spawn-DmmmHIP-.js";
6
- import { n as ui } from "./ui-D_qf3Gvw.js";
7
- import { n as fg, t as THEME } from "./theme-DUsCh-Vd.js";
8
- import { t as scanProject } from "./scan-nVQO7JLx.js";
9
- import { t as detectExisting } from "./existing-Cl5x6_5u.js";
10
- import { t as detectDrivers } from "./drivers-BQkO5tHs.js";
1
+ import "./token-CWQ6tdva.js";
2
+ import { n as readSession } from "./storage-BR6imSqm.js";
3
+ import { S as apiKeyFromEnv, x as VERSION } from "./environment-sE2wZYdg.js";
4
+ import "./config-DOp5oChe.js";
5
+ import "./skills-BB1uIt8t.js";
6
+ import { t as scanProject } from "./scan-ViBhmrB7.js";
7
+ import "./resources-XwvXA20E.js";
8
+ import "./orgs-DQQJ3sw_.js";
9
+ import { n as ui } from "./ui-hFgji1e8.js";
10
+ import "./spinner-BQp7fQvK.js";
11
+ import "./org-BD8U3D1_.js";
12
+ import { n as fg, t as THEME } from "./theme-Ed0gz6hr.js";
13
+ import "./lookup-DqmIbUkv.js";
14
+ import "./types-Dc9U_4kp.js";
15
+ import "./session-BfVx50iA.js";
16
+ import { l as detectDrivers, t as detectExisting } from "./existing--peXpOZj.js";
17
+ import "./paths-CIlyzF2I.js";
18
+ import "./setup-a4B72xJ8.js";
19
+ import "./framework-DW5fqjh4.js";
20
+ import "./login-C6X7JrhM.js";
21
+ import "./browser-BVjaf98V.js";
22
+ import "./login-DXhm9L0F.js";
23
+ import "./git-Hf9Wc7Hp.js";
24
+ import "./scope-Cg1AdAfO.js";
25
+ import { m as selectProjectInstall, p as selectCachedLatest, r as isNewerVersion, u as resolveUpdateTag } from "./upgrade-Cw9jVt-r.js";
11
26
 
12
27
  //#region src/core/support/doctor.ts
13
28
  async function runDoctor(ctx, deps = {}) {
@@ -38,6 +53,7 @@ async function runDoctor(ctx, deps = {}) {
38
53
  ]
39
54
  ] : [];
40
55
  const rows = [
56
+ resolveCliCheck(ctx.installDir),
41
57
  [
42
58
  drivers.length > 0,
43
59
  "Coding agent",
@@ -78,6 +94,30 @@ async function runDoctor(ctx, deps = {}) {
78
94
  const failed = rows.filter(([ok]) => !ok).length;
79
95
  ui.outro(failed === 0 ? "All checks passed." : `${failed} of ${rows.length} checks need attention.`);
80
96
  }
97
+ function resolveCliCheck(installDir) {
98
+ const found = selectProjectInstall(installDir);
99
+ const tag = resolveUpdateTag(found?.version ?? VERSION);
100
+ const project = found && tag !== "latest" ? selectProjectInstall(installDir, tag) : found;
101
+ const version = project ? project.version : VERSION;
102
+ const source = project ? ` from ${project.manifest}` : "";
103
+ const update = project ? project.update : "superwall upgrade";
104
+ if (version === void 0) return [
105
+ false,
106
+ "CLI",
107
+ `unknown version${source} - run \`${update}\``
108
+ ];
109
+ const latest = selectCachedLatest(version);
110
+ if (latest === void 0 || !isNewerVersion(latest, version)) return [
111
+ true,
112
+ "CLI",
113
+ `${version}${source}`
114
+ ];
115
+ return [
116
+ false,
117
+ "CLI",
118
+ `${version}${source}, ${latest} available - run \`${update}\``
119
+ ];
120
+ }
81
121
 
82
122
  //#endregion
83
123
  export { runDoctor };