@superwall/cli 2.2.0 → 2.3.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 (113) hide show
  1. package/README.md +26 -11
  2. package/dist/{apple-Bcr_PteR.js → apple-D79LBw5E.js} +13 -13
  3. package/dist/assets-Diivv88t.js +89 -0
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/auth.js +3 -3
  6. package/dist/{billing-CWM1ds3K.js → billing-CCuMv6mh.js} +3 -3
  7. package/dist/{bind-DEYxsnZD.js → bind-CVRlFlRo.js} +4 -4
  8. package/dist/{build--oQKfZU6.js → build-BCq0cGh-.js} +7 -6
  9. package/dist/{client-CimFymxG.js → client-CYtQvWJR.js} +3 -3
  10. package/dist/{create-BG9n4fvs.js → create-BZyUW60x.js} +28 -226
  11. package/dist/{create-DTAyHkxb.js → create-BaP6hoQ1.js} +6 -6
  12. package/dist/create-DNfuZ9os.js +19 -0
  13. package/dist/{doctor-BkygMUe2.js → doctor-kx01VvQX.js} +6 -6
  14. package/dist/{drivers-C6eXj5-r.js → drivers-D0818zGc.js} +3 -3
  15. package/dist/entry.js +19 -19
  16. package/dist/{environment-CQn323uB.js → environment-a7W-0wg0.js} +1 -1
  17. package/dist/{existing-CvOluc9U.js → existing-B7qxYiUX.js} +2 -2
  18. package/dist/held-C4BiAQ_X.js +16 -0
  19. package/dist/{held-QM7yfrXq.js → held-CEyXc1SI.js} +6 -6
  20. package/dist/{integrate-Ci_MLkQG.js → integrate-RK5U0GTQ.js} +22 -22
  21. package/dist/login-DV70XgZO.js +16 -0
  22. package/dist/{login-BIAWgdzM.js → login-DrMLxlF4.js} +6 -6
  23. package/dist/{login-DLi71nJq.js → login-NxCl2WuU.js} +1 -1
  24. package/dist/{lookup-DZFrfzO0.js → lookup-Dor6ch5A.js} +2 -2
  25. package/dist/{migrate-BKF1WckS.js → migrate-CjSpcnNu.js} +25 -22
  26. package/dist/{open-BjvGVwJf.js → migration-MlzZHGP-.js} +22 -56
  27. package/dist/{notification-url-erXQ1edb.js → notification-url-C_QXtljc.js} +2 -2
  28. package/dist/open-CBW0Cuog.js +41 -0
  29. package/dist/{org-CvPGVSBF.js → org-BJCyaL1b.js} +2 -2
  30. package/dist/{paths-oRuC18Kt.js → paths-Cp_lgyWO.js} +1 -1
  31. package/dist/{playbook-CtTj1HBK.js → playbook-VqV7546k.js} +10 -10
  32. package/dist/{promote-BkJYISza.js → promote-BSckFPwZ.js} +18 -16
  33. package/dist/pull-DEumBwvc.js +303 -0
  34. package/dist/{push-Ul2SW87i.js → push-D-dewDd1.js} +8 -6
  35. package/dist/push-YEPqa6hs.js +24 -0
  36. package/dist/{registry-OmPZ6dj0.js → registry-D6M1JxYC.js} +236 -142
  37. package/dist/{resources-FIrK7pE9.js → resources-DKn4itf3.js} +21 -7
  38. package/dist/{run-CwEY1eu5.js → run-Ccv5egCC.js} +2 -2
  39. package/dist/{scan-CpbfZ2ju.js → scan-Be17rMcQ.js} +1 -1
  40. package/dist/scan-CocGVPe0.js +4 -0
  41. package/dist/{scope-BSqVfZvy.js → scope-92neiQ2q.js} +5 -4
  42. package/dist/{selection-CHnVk8uw.js → selection-C5ZY23dQ.js} +16 -96
  43. package/dist/server-1pOxW1GJ.js +24 -0
  44. package/dist/{server-D5xl5iKO.js → server-DZ7L28w4.js} +9 -7
  45. package/dist/{session-BFwasPVq.js → session-CdnUL4zt.js} +444 -243
  46. package/dist/session-Cm0U68t3.js +6 -0
  47. package/dist/{session-6lnJ0shD.js → session-gTuw2_8i.js} +1 -1
  48. package/dist/setup-esb3_a7N.js +216 -0
  49. package/dist/skills/animate-onboarding/SKILL.md +2 -2
  50. package/dist/skills/index.json +18 -18
  51. package/dist/skills/mobile-design/SKILL.md +2 -2
  52. package/dist/skills/onboarding-questions/SKILL.md +2 -2
  53. package/dist/skills/superwall/SKILL.md +104 -20
  54. package/dist/skills/superwall/references/api.md +21 -5
  55. package/dist/skills/superwall/workflows/dashboard/playbook.md +6 -4
  56. package/dist/skills/superwall/workflows/dashboard/setup.md +10 -5
  57. package/dist/skills/superwall/workflows/integrate/playbook.md +4 -2
  58. package/dist/skills/superwall/workflows/migrate/adapty.md +7 -6
  59. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -3
  60. package/dist/skills/superwall/workflows/migrate/qonversion.md +7 -6
  61. package/dist/skills/superwall/workflows/migrate/revenuecat.md +8 -7
  62. package/dist/skills/superwall-editor/SKILL.md +52 -1
  63. package/dist/skills/superwall-framework/SKILL.md +90 -15
  64. package/dist/skills/superwall-framework/references/cli.md +92 -21
  65. package/dist/skills/superwall-framework/references/migrate-from-editor.md +6 -2
  66. package/dist/skills/superwall-framework/references/mobile-design.md +1 -1
  67. package/dist/{skills-B8uSuanf.js → skills-B_oH2dYK.js} +8 -8
  68. package/dist/{skills-D7sG0xom.js → skills-miJDcjQ2.js} +4 -4
  69. package/dist/source-push-NVrs53Uo.js +205 -0
  70. package/dist/{spinner-TZeZEeVv.js → spinner-D6phP4Af.js} +3 -3
  71. package/dist/{storage-DqKJe13V.js → storage-BcvKhvzZ.js} +1 -1
  72. package/dist/storekit-D1A5VHT1.js +16 -0
  73. package/dist/{storekit-uyT3DWo4.js → storekit-Di3BkafX.js} +3 -3
  74. package/dist/{telemetry-D_uIIuSk.js → telemetry-BpYXL-z3.js} +1 -1
  75. package/dist/{token-BJsLGoSX.js → token-4dQOfOaK.js} +1 -1
  76. package/dist/tools-skills/animate-onboarding/SKILL.md +1 -1
  77. package/dist/tools-skills/mobile-design/SKILL.md +1 -1
  78. package/dist/tools-skills/onboarding-questions/SKILL.md +1 -1
  79. package/dist/tools-skills/superwall/SKILL.md +80 -8
  80. package/dist/tools-skills/superwall/references/api.md +116 -24
  81. package/dist/tools-skills/superwall/references/apple-setup.md +316 -0
  82. package/dist/tools-skills/superwall/references/asc.md +74 -38
  83. package/dist/tools-skills/superwall/references/data-analytics.md +62 -29
  84. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +3 -3
  85. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +8 -8
  86. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +6 -6
  87. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +4 -4
  88. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +5 -5
  89. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +6 -6
  90. package/dist/tools-skills/superwall/workflows/placements/android.md +2 -2
  91. package/dist/tools-skills/superwall/workflows/placements/expo.md +2 -2
  92. package/dist/tools-skills/superwall/workflows/placements/flutter.md +2 -2
  93. package/dist/tools-skills/superwall/workflows/placements/ios.md +2 -2
  94. package/dist/tools-skills/superwall/workflows/placements/playbook.md +2 -2
  95. package/dist/tools-skills/superwall/workflows/placements/react-native.md +2 -2
  96. package/dist/tools-skills/superwall/workflows/placements/strategy.md +2 -2
  97. package/dist/tools-skills/superwall/workflows/review/playbook.md +1 -1
  98. package/dist/tools-skills/superwall-editor/SKILL.md +2 -2
  99. package/dist/tools.d.ts +1 -1
  100. package/dist/tools.js +222 -109
  101. package/dist/{upgrade-DV_rmhyV.js → upgrade-BnOq32zn.js} +2 -2
  102. package/dist/{upgrade-BRM51As6.js → upgrade-Cb6f4S_c.js} +1 -1
  103. package/package.json +2 -2
  104. package/dist/create-kT2C9k4h.js +0 -19
  105. package/dist/held-Bwkhufdj.js +0 -16
  106. package/dist/login-Dy9N5ZDH.js +0 -16
  107. package/dist/push-BIizJJOn.js +0 -22
  108. package/dist/scan-DjyvuWel.js +0 -4
  109. package/dist/server-BTveynqC.js +0 -22
  110. package/dist/session-Ds6tLC19.js +0 -6
  111. package/dist/storekit-C_LFh8qy.js +0 -16
  112. /package/dist/{reports-D_qbl7_u.js → reports-CwwKLUh0.js} +0 -0
  113. /package/dist/{storage-BbJF7z3l.d.ts → storage-gRyQetN9.d.ts} +0 -0
package/README.md CHANGED
@@ -74,6 +74,7 @@ superwall dev # open the studio and preview everything live
74
74
  superwall push # build and push immutable versions (production untouched)
75
75
  superwall promote # point production at a pushed version
76
76
  superwall publish # push and promote in one step
77
+ superwall pull # bring teammates' paywalls from the app's source repo into this project
77
78
  ```
78
79
 
79
80
  Every paywall and web funnel is a mini React app: file-based routes, your
@@ -218,13 +219,25 @@ records a note in the source commit that rides along with every version, and
218
219
  Renames are resolved, never guessed — interactively, or with
219
220
  `push --rename old=new` in CI.
220
221
 
221
- A push also saves the project's source to the app's repo. It applies your
222
- changes on top of whatever teammates have published since your last push
223
- (the commit it last synced to is in `superwall.lock`, so commit it), so two
224
- people working on different paywalls never undo each other. If you both
225
- changed the same file, or the repo has changes this project never synced
226
- with, the push stops and names the files rather than overwriting their work;
227
- `--overwrite-source` replaces the remote source with yours when you mean to.
222
+ A push also saves the source of each paywall it pushes to the app's repo.
223
+ Only that paywall's directory and the files outside every paywall and funnel
224
+ (your `package.json`, shared components) come from you; every other paywall
225
+ and funnel stays as the repo has it, and `superwall.lock` keeps their entries.
226
+ Your changes land on top of whatever teammates have published since your last
227
+ push (the commit it last synced to is in `superwall.lock`), so two people
228
+ working on different paywalls never undo each other, even from a checkout
229
+ that never synced. If a teammate changed a file you are pushing, the push
230
+ stops and names only those files: run `superwall pull` and publish again, or
231
+ `--overwrite-source` to replace that paywall's source with yours. The
232
+ overwrite never touches other paywalls.
233
+
234
+ `superwall pull` merges the app's source repo into your project: teammates'
235
+ paywalls, their `superwall.lock` bindings and the sync point. Your own edits
236
+ stay. If you both changed a file it names the files and changes nothing;
237
+ `pull --theirs` takes the repo's copy of them. A version whose source never
238
+ landed stays pending, so `promote` still won't ship it. With no project,
239
+ `superwall pull --app <id> [dir]` creates `superwall/` from the app's source,
240
+ so you can work on an app's paywalls without its codebase or GitHub.
228
241
 
229
242
  The full reference — assets, localization, trials, transitions, web
230
243
  checkout, troubleshooting — lives at
@@ -239,9 +252,9 @@ Stripe-style: `superwall <resource> <operation> [ids] [--field value]`.
239
252
  superwall apps get <app> # everything about one app: bundle ID, Apple team, keys
240
253
  superwall apps <app> # the same: an id where the operation goes means get
241
254
  superwall apps update <app> --team-id <team-id>
242
- superwall products create --identifier pro_monthly --price 9.99 --period month
255
+ superwall entitlements create --identifier pro --app <app>
256
+ superwall products create --identifier pro_monthly --price 9.99 --period month --entitlement pro
243
257
  superwall products storekit # generate a local .storekit file
244
- superwall entitlements create --identifier pro
245
258
  superwall campaigns create --description "Onboarding upsell" --placement onboarding_complete
246
259
  superwall campaigns placements create <campaign-id> --event-name onboarding_complete
247
260
  superwall campaigns audiences readout <campaign-id> <audience-id>
@@ -608,7 +621,9 @@ Set `SUPERWALL_CHANNEL=next` to opt into experimental and beta features:
608
621
  commands that are not in the stable set yet, and the matching agent skills
609
622
  from the `next` branch of the skills repo. Everything else is unchanged.
610
623
  Export it in your shell rc so every terminal and agent sees it. Unset it to
611
- go back to the stable set.
624
+ go back to the stable set. The framework (`create`, `dev`, `build`, `push`,
625
+ `promote`, `publish`, `pull`, `migrate <paywall-id>`, `migrate --screen`) is in public
626
+ beta on the stable set and needs no channel.
612
627
 
613
628
  ## Telemetry
614
629
 
@@ -629,7 +644,7 @@ packages/cli/
629
644
  │ ├── program/ the command system: defineCommand, parser, help, lifecycle
630
645
  │ ├── commands/ registry.ts + one directory per section of `superwall --help`
631
646
  │ │ ├── workflows/ integrate, review, migrate
632
- │ │ ├── paywalls/ create, dev, build, push, promote, publish
647
+ │ │ ├── paywalls/ create, dev, build, push, promote, publish, pull
633
648
  │ │ ├── main/ bootstrap, apps, products, entitlements, campaigns, paywalls, users, webhooks, events, annotations
634
649
  │ │ ├── analytics/ query
635
650
  │ │ ├── api/ docs, get, post, patch, delete
@@ -1,21 +1,21 @@
1
- import "./token-BJsLGoSX.js";
1
+ import "./token-4dQOfOaK.js";
2
2
  import { t as blocks } from "./output-Ggzq5_-t.js";
3
- import "./environment-CQn323uB.js";
4
- import "./storage-DqKJe13V.js";
5
- import { t as ApiError } from "./client-CimFymxG.js";
6
- import { E as updateBundleId, a as chooseAppIntent, g as RefusedByApi, i as savedKey, m as KEY_LABEL, n as testModeWarning, p as KEY_KINDS, s as resolveApp, y as findIntegrations } from "./held-QM7yfrXq.js";
3
+ import "./environment-a7W-0wg0.js";
4
+ import "./storage-BcvKhvzZ.js";
5
+ import { t as ApiError } from "./client-CYtQvWJR.js";
6
+ import { E as updateBundleId, a as chooseAppIntent, g as RefusedByApi, i as savedKey, m as KEY_LABEL, n as testModeWarning, p as KEY_KINDS, s as resolveApp, y as findIntegrations } from "./held-CEyXc1SI.js";
7
7
  import "./config-BO1Y87kV.js";
8
- import { t as apiCall } from "./spinner-TZeZEeVv.js";
8
+ import { t as apiCall } from "./spinner-D6phP4Af.js";
9
9
  import "./ui-D_qf3Gvw.js";
10
- import "./paths-oRuC18Kt.js";
11
- import "./resources-FIrK7pE9.js";
12
- import "./org-CvPGVSBF.js";
13
- import "./lookup-DZFrfzO0.js";
14
- import "./scope-BSqVfZvy.js";
10
+ import "./paths-Cp_lgyWO.js";
11
+ import "./resources-DKn4itf3.js";
12
+ import "./org-BJCyaL1b.js";
13
+ import "./lookup-Dor6ch5A.js";
14
+ import "./scope-92neiQ2q.js";
15
15
  import "./client-BZ1UbpXz.js";
16
16
  import "./timing-BVxPrYq3.js";
17
- import { n as ensureNotificationUrl, r as environmentLines, t as describeNotificationUrl } from "./notification-url-erXQ1edb.js";
18
- import { a as chooseTeam, n as keyAccess, o as signIn, r as keyRole, s as appleDeps, t as createAndSaveKey } from "./create-DTAyHkxb.js";
17
+ import { n as ensureNotificationUrl, r as environmentLines, t as describeNotificationUrl } from "./notification-url-C_QXtljc.js";
18
+ import { a as chooseTeam, n as keyAccess, o as signIn, r as keyRole, s as appleDeps, t as createAndSaveKey } from "./create-BaP6hoQ1.js";
19
19
 
20
20
  //#region src/core/app-store-connect/setup/apple.ts
21
21
  const STEPS = [
@@ -0,0 +1,89 @@
1
+ import { r as ASSET_HOST } from "./environment-a7W-0wg0.js";
2
+ import { t as ApiError } from "./client-CYtQvWJR.js";
3
+ import { S as pushPaywallAssets } from "./resources-DKn4itf3.js";
4
+ import * as fs from "node:fs";
5
+
6
+ //#region src/core/paywalls/assets.ts
7
+ const assetBaseUrl = (applicationId) => `${ASSET_HOST()}/${applicationId}`;
8
+ function requireAssets(built) {
9
+ if (!Array.isArray(built.assets)) throw new AssetSyncError("This project's superwall version builds snapshots without hosted assets — update the project's superwall dependency to push.");
10
+ return built.assets;
11
+ }
12
+ var AssetSyncError = class extends Error {};
13
+ const assetName = (asset) => asset.path.split(/[\\/]/).pop() || asset.fileName;
14
+ function uploadFailure(asset, response) {
15
+ const name = assetName(asset);
16
+ if (!response) return new AssetSyncError(`Couldn't upload ${name} — the asset store is unreachable. Check your network, then push again.`);
17
+ if (response.status === 404 || response.status === 403) return new AssetSyncError(`Couldn't upload ${name} — the asset store rejected the upload with HTTP ${response.status}. That upload URL is issued by Superwall and expires, so this usually means the storage endpoint is misconfigured or unreachable rather than anything wrong with the file.`);
18
+ return new AssetSyncError(`Couldn't upload ${name} — the asset store returned HTTP ${response.status}.`);
19
+ }
20
+ const CACHE_CONTROL = "public, max-age=31536000, immutable";
21
+ const UPLOAD_CONCURRENCY = 4;
22
+ const pool = async (items, limit, work) => {
23
+ const queue = [...items];
24
+ const runners = Array.from({ length: Math.min(limit, queue.length) }, async () => {
25
+ for (let item = queue.shift(); item !== void 0; item = queue.shift()) await work(item);
26
+ });
27
+ await Promise.all(runners);
28
+ };
29
+ async function syncAssets(input) {
30
+ const { api, paywallId, assets } = input;
31
+ const put = input.put ?? fetch;
32
+ const read = input.read ?? ((path) => fs.readFileSync(path));
33
+ const totalBytes = assets.reduce((total, asset) => total + asset.bytes, 0);
34
+ if (assets.length === 0) return {
35
+ assets: [],
36
+ uploaded: 0,
37
+ uploadedBytes: 0,
38
+ totalBytes: 0
39
+ };
40
+ const resolved = await pushPaywallAssets(api, paywallId, assets.map((asset) => ({
41
+ sha256: asset.sha256,
42
+ bytes: asset.bytes,
43
+ mime: asset.mime,
44
+ file_name: asset.fileName
45
+ }))).catch((error) => {
46
+ if (error instanceof ApiError && error.status === 404) throw new AssetSyncError("This Superwall environment does not support hosted assets yet. Keep every asset under 32 kB so the snapshot can inline it, or upgrade the platform.");
47
+ throw error;
48
+ });
49
+ const bySha = new Map(resolved.map((entry) => [entry.sha256, entry]));
50
+ const missing = [];
51
+ const hosted = /* @__PURE__ */ new Map();
52
+ for (const asset of assets) {
53
+ const entry = bySha.get(asset.sha256);
54
+ if (!entry) throw new AssetSyncError(`Superwall did not return a URL for ${assetName(asset)} — asset sync is incomplete.`);
55
+ if (!entry.url.endsWith(`/${asset.fileName}`)) throw new AssetSyncError(`Superwall hosted ${asset.fileName} at ${entry.url}, which does not match the URL baked into the snapshot. Delete superwall.lock and push again to rebind this paywall.`);
56
+ hosted.set(asset.sha256, entry.url);
57
+ if (entry.uploadUrl !== void 0) missing.push(asset);
58
+ }
59
+ let uploadedBytes = 0;
60
+ await pool(missing, UPLOAD_CONCURRENCY, async (asset) => {
61
+ const uploadUrl = bySha.get(asset.sha256)?.uploadUrl;
62
+ if (uploadUrl === void 0) return;
63
+ const body = read(asset.path);
64
+ const send = () => put(uploadUrl, {
65
+ method: "PUT",
66
+ headers: {
67
+ "content-type": asset.mime,
68
+ "cache-control": CACHE_CONTROL
69
+ },
70
+ body: new Uint8Array(body)
71
+ });
72
+ let response = await send().catch(() => void 0);
73
+ if (!response?.ok) response = await send().catch(() => void 0);
74
+ if (!response?.ok) throw uploadFailure(asset, response);
75
+ uploadedBytes += asset.bytes;
76
+ });
77
+ return {
78
+ assets: assets.map((asset) => ({
79
+ url: hosted.get(asset.sha256) ?? "",
80
+ mime_type: asset.mime
81
+ })),
82
+ uploaded: missing.length,
83
+ uploadedBytes,
84
+ totalBytes
85
+ };
86
+ }
87
+
88
+ //#endregion
89
+ export { requireAssets as n, syncAssets as r, assetBaseUrl as t };
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Session } from "./storage-BbJF7z3l.js";
1
+ import { t as Session } from "./storage-gRyQetN9.js";
2
2
 
3
3
  //#region src/core/account/errors.d.ts
4
4
  declare class NotLoggedInError extends Error {
package/dist/auth.js CHANGED
@@ -1,6 +1,6 @@
1
- import { n as resolveAuthToken, r as NotLoggedInError, t as getOAuthAccessToken } from "./token-BJsLGoSX.js";
1
+ import { n as resolveAuthToken, r as NotLoggedInError, t as getOAuthAccessToken } from "./token-4dQOfOaK.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-CQn323uB.js";
4
- import "./storage-DqKJe13V.js";
3
+ import "./environment-a7W-0wg0.js";
4
+ import "./storage-BcvKhvzZ.js";
5
5
 
6
6
  export { NotLoggedInError, getOAuthAccessToken, resolveAuthToken };
@@ -1,6 +1,6 @@
1
- import { f as Integration } from "./environment-CQn323uB.js";
2
- import { i as readPackageJson, r as allDeps } from "./scan-CpbfZ2ju.js";
3
- import { d as readBundledSkill } from "./skills-D7sG0xom.js";
1
+ import { f as Integration } from "./environment-a7W-0wg0.js";
2
+ import { i as readPackageJson, r as allDeps } from "./scan-Be17rMcQ.js";
3
+ import { d as readBundledSkill } from "./skills-miJDcjQ2.js";
4
4
  import { readFileSync } from "node:fs";
5
5
  import fg from "fast-glob";
6
6
 
@@ -1,8 +1,8 @@
1
- import { f as Integration } from "./environment-CQn323uB.js";
2
- import { n as withSpinner } from "./spinner-TZeZEeVv.js";
1
+ import { f as Integration } from "./environment-a7W-0wg0.js";
2
+ import { n as withSpinner } from "./spinner-D6phP4Af.js";
3
3
  import { n as ui } from "./ui-D_qf3Gvw.js";
4
- import { n as createApplication, p as listProjects, s as createProject, v as platformLabel } from "./resources-FIrK7pE9.js";
5
- import { n as orgForNewProject } from "./org-CvPGVSBF.js";
4
+ import { c as createProject, m as listProjects, r as createApplication, y as platformLabel } from "./resources-DKn4itf3.js";
5
+ import { n as orgForNewProject } from "./org-BJCyaL1b.js";
6
6
 
7
7
  //#region src/core/account/bind.ts
8
8
  const NEW = "__new__";
@@ -1,12 +1,13 @@
1
- import "./token-BJsLGoSX.js";
1
+ import "./token-4dQOfOaK.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import { v as VERSION } from "./environment-CQn323uB.js";
4
- import "./storage-DqKJe13V.js";
5
- import "./client-CimFymxG.js";
3
+ import { v as VERSION } from "./environment-a7W-0wg0.js";
4
+ import "./storage-BcvKhvzZ.js";
5
+ import "./client-CYtQvWJR.js";
6
6
  import "./config-BO1Y87kV.js";
7
7
  import { n as ui } from "./ui-D_qf3Gvw.js";
8
- import "./resources-FIrK7pE9.js";
9
- import { N as resolveFramework, P as assetBaseUrl, a as resolveProjectDir, d as kb, h as took, i as requireProject, n as parseIds, s as selectSurfaces, v as collectProjectDeclarations, w as readLock, y as writeProjectTypes } from "./selection-CHnVk8uw.js";
8
+ import "./resources-DKn4itf3.js";
9
+ import { t as assetBaseUrl } from "./assets-Diivv88t.js";
10
+ import { a as resolveProjectDir, b as writeProjectTypes, d as kb, h as took, i as requireProject, k as readLock, n as parseIds, s as selectSurfaces, y as collectProjectDeclarations, z as resolveFramework } from "./selection-C5ZY23dQ.js";
10
11
  import * as fs from "node:fs";
11
12
  import * as path from "node:path";
12
13
  import pc from "picocolors";
@@ -1,6 +1,6 @@
1
- import { n as resolveAuthToken, r as NotLoggedInError } from "./token-BJsLGoSX.js";
2
- import { _ as USER_AGENT } from "./environment-CQn323uB.js";
3
- import { a as resolveApiHost, n as readSession } from "./storage-DqKJe13V.js";
1
+ import { n as resolveAuthToken, r as NotLoggedInError } from "./token-4dQOfOaK.js";
2
+ import { _ as USER_AGENT } from "./environment-a7W-0wg0.js";
3
+ import { a as resolveApiHost, n as readSession } from "./storage-BcvKhvzZ.js";
4
4
 
5
5
  //#region src/core/api/client.ts
6
6
  const BODY_SNIPPET = 200;
@@ -1,31 +1,35 @@
1
- import "./token-BJsLGoSX.js";
1
+ import "./token-4dQOfOaK.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-CQn323uB.js";
4
- import "./storage-DqKJe13V.js";
5
- import "./client-CimFymxG.js";
3
+ import "./environment-a7W-0wg0.js";
4
+ import "./storage-BcvKhvzZ.js";
5
+ import "./client-CYtQvWJR.js";
6
6
  import "./config-BO1Y87kV.js";
7
- import "./telemetry-D_uIIuSk.js";
7
+ import "./telemetry-BpYXL-z3.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-TZeZEeVv.js";
9
+ import "./spinner-D6phP4Af.js";
10
10
  import "./ui-D_qf3Gvw.js";
11
11
  import "./theme-DUsCh-Vd.js";
12
12
  import "./log-NVhVe_oe.js";
13
- import { i as readPackageJson, r as allDeps, t as scanProject } from "./scan-CpbfZ2ju.js";
14
- import { t as detectExisting } from "./existing-CvOluc9U.js";
15
- import "./paths-oRuC18Kt.js";
16
- import { D as field, f as listApplications, n as createApplication, p as listProjects, v as platformLabel } from "./resources-FIrK7pE9.js";
17
- import "./org-CvPGVSBF.js";
18
- import { n as findApplication } from "./lookup-DZFrfzO0.js";
19
- import { r as resolveScopeFromKey } from "./bind-DEYxsnZD.js";
20
- import "./login-BIAWgdzM.js";
21
- import "./skills-D7sG0xom.js";
22
- import { E as writeApp } from "./selection-CHnVk8uw.js";
23
- import { a as gitAvailable, b as requirePlatform, c as projectPackageName, n as requireApi, t as LoginRequiredError } from "./session-BFwasPVq.js";
24
- import "./login-DLi71nJq.js";
25
- import "./run-CwEY1eu5.js";
26
- import "./drivers-C6eXj5-r.js";
27
- import { b as writeTemplate, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, i as startStudio, n as migrationNextSteps, s as isSuperwallProject, t as askStudio, u as offerMigration, v as starterConfig, x as slugOf, y as writeSurfaceFiles } from "./open-BjvGVwJf.js";
28
- import "./server-D5xl5iKO.js";
13
+ import "./scan-Be17rMcQ.js";
14
+ import "./existing-B7qxYiUX.js";
15
+ import "./paths-Cp_lgyWO.js";
16
+ import { O as field } from "./resources-DKn4itf3.js";
17
+ import "./org-BJCyaL1b.js";
18
+ import "./lookup-Dor6ch5A.js";
19
+ import "./bind-CVRlFlRo.js";
20
+ import "./login-DrMLxlF4.js";
21
+ import "./skills-miJDcjQ2.js";
22
+ import "./assets-Diivv88t.js";
23
+ import "./selection-C5ZY23dQ.js";
24
+ import { n as requireApi, t as LoginRequiredError, u as projectPackageName } from "./session-CdnUL4zt.js";
25
+ import "./source-push-NVrs53Uo.js";
26
+ import "./login-NxCl2WuU.js";
27
+ import "./run-Ccv5egCC.js";
28
+ import "./drivers-D0818zGc.js";
29
+ 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-MlzZHGP-.js";
30
+ import "./server-DZ7L28w4.js";
31
+ import { i as startStudio, n as migrationNextSteps, t as askStudio } from "./open-CBW0Cuog.js";
32
+ 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-esb3_a7N.js";
29
33
  import { execFile } from "node:child_process";
30
34
  import * as fs from "node:fs";
31
35
  import * as path from "node:path";
@@ -35,7 +39,7 @@ import * as os$1 from "node:os";
35
39
  import { gunzipSync } from "node:zlib";
36
40
 
37
41
  //#region src/core/paywalls/project/examples.ts
38
- const run$1 = promisify(execFile);
42
+ const run = promisify(execFile);
39
43
  const EXAMPLES_REPO = process.env.SUPERWALL_EXAMPLES_REPO ?? "superwall/superwall";
40
44
  const EXAMPLES_REF = process.env.SUPERWALL_EXAMPLES_REF ?? "main";
41
45
  var ExampleError = class extends Error {};
@@ -60,7 +64,7 @@ async function downloadExample(name, target, fetchImpl = fetch) {
60
64
  const prefix = `${EXAMPLES_REPO.split("/")[1]}-${EXAMPLES_REF.replace(/\//g, "-")}`;
61
65
  fs.mkdirSync(target, { recursive: true });
62
66
  try {
63
- await run$1("tar", [
67
+ await run("tar", [
64
68
  "-xf",
65
69
  tarball,
66
70
  "-C",
@@ -84,208 +88,6 @@ function adoptExamplePackage(target, name) {
84
88
  fs.writeFileSync(file, `${JSON.stringify(parsed, null, 2)}\n`);
85
89
  }
86
90
 
87
- //#endregion
88
- //#region src/core/paywalls/project/setup.ts
89
- const run = promisify(execFile);
90
- const APP_PLATFORMS = [
91
- "ios",
92
- "android",
93
- "flutter",
94
- "react_native",
95
- "web"
96
- ];
97
- function alreadyAProject(root) {
98
- const target = path.join(root, "superwall");
99
- if (isSuperwallProject(target)) return `\`${target}\` is already a superwall project — run \`superwall dev\` to open it.`;
100
- if (fs.existsSync(path.join(target, "package.json"))) return `\`${target}\` already has a package.json that isn't a superwall project — move it aside first.`;
101
- for (const marker of ["superwall.config.ts", "superwall.lock"]) if (fs.existsSync(path.join(root, marker))) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
102
- const parsed = readPackageJson(root);
103
- if (parsed && "superwall" in allDeps(parsed)) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
104
- }
105
- const LOCKFILES = [
106
- ["bun.lock", "bun"],
107
- ["bun.lockb", "bun"],
108
- ["pnpm-lock.yaml", "pnpm"],
109
- ["yarn.lock", "yarn"],
110
- ["package-lock.json", "npm"]
111
- ];
112
- async function available(manager) {
113
- try {
114
- await run(manager, ["--version"], { shell: process.platform === "win32" });
115
- return true;
116
- } catch {
117
- return false;
118
- }
119
- }
120
- async function detectPackageManager(root) {
121
- const agent = process.env.npm_config_user_agent ?? "";
122
- const candidates = [
123
- ...LOCKFILES.filter(([file]) => fs.existsSync(path.join(root, file))).map(([, manager]) => manager),
124
- ...[
125
- "bun",
126
- "pnpm",
127
- "yarn",
128
- "npm"
129
- ].filter((manager) => agent.startsWith(manager)),
130
- "bun"
131
- ];
132
- for (const manager of candidates) if (await available(manager)) return manager;
133
- return "npm";
134
- }
135
- function devCommand(manager) {
136
- return manager === "npm" ? "npm run dev" : `${manager} dev`;
137
- }
138
- async function installDependencies(ui, target, manager) {
139
- const spin = ui.spinner();
140
- spin.start(`Installing dependencies with ${manager}`);
141
- try {
142
- await run(manager, ["install"], {
143
- cwd: target,
144
- shell: process.platform === "win32",
145
- timeout: 3e5
146
- });
147
- spin.stop("Dependencies installed");
148
- return true;
149
- } catch {
150
- spin.stop(`\`${manager} install\` failed — run it yourself in superwall/`);
151
- return false;
152
- }
153
- }
154
- async function initGit(ui, root) {
155
- if (!await gitAvailable()) return;
156
- if (await run("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root }).then(() => true, () => false)) return;
157
- try {
158
- await run("git", ["init", "--quiet"], { cwd: root });
159
- await run("git", ["add", "-A"], { cwd: root });
160
- await run("git", [
161
- "commit",
162
- "--quiet",
163
- "-m",
164
- "New superwall project"
165
- ], { cwd: root });
166
- ui.step("Initialized a git repository");
167
- } catch {
168
- return;
169
- }
170
- }
171
- function humanName(root) {
172
- return projectPackageName(root).split(/[-_.]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
173
- }
174
- async function detectHostApp(root) {
175
- try {
176
- const app = (await scanProject(root)).apps[0];
177
- if (!app) return void 0;
178
- return {
179
- app,
180
- existing: detectExisting(app)
181
- };
182
- } catch {
183
- return;
184
- }
185
- }
186
- async function createAppFlow(ui, api, root) {
187
- const projects = await listProjects(api);
188
- const [first] = projects;
189
- if (first === void 0) {
190
- ui.warn("Your account has no projects yet — create one in the dashboard first.");
191
- return null;
192
- }
193
- let project = first;
194
- if (projects.length > 1) {
195
- const picked = await ui.select({
196
- message: "Which project does the app belong to?",
197
- options: projects.map((candidate) => ({
198
- value: String(candidate.id),
199
- label: candidate.name ?? String(candidate.id)
200
- }))
201
- });
202
- if (picked === null) return null;
203
- project = projects.find((candidate) => String(candidate.id) === picked) ?? project;
204
- }
205
- const name = await ui.text({
206
- message: "What is the app called?",
207
- initialValue: humanName(root),
208
- validate: (value) => value.trim() === "" ? "Give the app a name." : void 0
209
- });
210
- if (name === null) return null;
211
- const platform = await ui.select({
212
- message: "Which platform?",
213
- options: APP_PLATFORMS.map((value) => ({
214
- value,
215
- label: platformLabel(value)
216
- }))
217
- });
218
- if (platform === null) return null;
219
- const spin = ui.spinner();
220
- spin.start("Creating the app");
221
- const created = await createApplication(api, { projectId: String(project.id) }, {
222
- name: name.trim(),
223
- platform
224
- });
225
- spin.stop(`Created \`${name.trim()}\``);
226
- if (created.id === void 0) return null;
227
- return {
228
- id: created.id,
229
- name: name.trim(),
230
- platform
231
- };
232
- }
233
- async function connectApp(ui, interactive, root, target, detected, appId) {
234
- const api = await requireApi(interactive);
235
- if (appId !== void 0) {
236
- const app$1 = (await findApplication(api, appId))?.app;
237
- if (app$1 === void 0) throw new Error(`No app with id \`${appId}\` in this account — run \`superwall apps\` to list them.`);
238
- writeApp(target, requirePlatform(app$1), String(app$1.id));
239
- ui.success(`Pushes go to \`${app$1.name ?? app$1.id}\` — saved in superwall.lock, so commit that file.`);
240
- return;
241
- }
242
- if (detected?.existing.apiKey) {
243
- const scope = await resolveScopeFromKey(api, detected.existing.apiKey).catch(() => null);
244
- if (scope) {
245
- writeApp(target, requirePlatform((await listApplications(api).catch(() => [])).find((candidate) => String(candidate.id) === scope.applicationId) ?? { id: scope.applicationId }), scope.applicationId);
246
- ui.success(`\`${detected.app.name}\` is already on Superwall as \`${scope.appName ?? scope.applicationId}\` — pushes go there. Saved in superwall.lock; commit that file.`);
247
- return;
248
- }
249
- ui.info("Found a Superwall API key in the app, but no matching app in this account — pick one instead.");
250
- }
251
- const apps = await listApplications(api);
252
- let app = null;
253
- if (apps.length === 1 && apps[0] !== void 0) app = apps[0];
254
- else if (apps.length > 1) {
255
- if (!interactive) {
256
- ui.info("Several apps in your account — the first `superwall push` will ask which one.");
257
- return;
258
- }
259
- const picked = await ui.select({
260
- message: "Which app should these paywalls push to?",
261
- options: [...apps.map((candidate) => ({
262
- value: String(candidate.id),
263
- label: candidate.name ?? candidate.bundle_id ?? String(candidate.id),
264
- hint: platformLabel(candidate.platform)
265
- })), {
266
- value: "__new__",
267
- label: "Create a new app"
268
- }]
269
- });
270
- if (picked === null) return;
271
- app = picked === "__new__" ? await createAppFlow(ui, api, root) : apps.find((candidate) => String(candidate.id) === picked) ?? null;
272
- } else {
273
- if (!interactive) {
274
- ui.info("Your account has no apps yet — the first `superwall push` will set one up.");
275
- return;
276
- }
277
- app = await createAppFlow(ui, api, root);
278
- }
279
- if (app === null) return;
280
- writeApp(target, requirePlatform(app), String(app.id));
281
- ui.success(`Pushes go to \`${app.name ?? app.id}\` — saved in superwall.lock, so commit that file.`);
282
- }
283
- function uniqueSurfaceId(superwallDir, slug) {
284
- let candidate = slug;
285
- for (let n = 2; fs.existsSync(path.join(superwallDir, "paywalls", candidate)); n += 1) candidate = `${slug}-${n}`;
286
- return candidate;
287
- }
288
-
289
91
  //#endregion
290
92
  //#region src/core/paywalls/project/create.ts
291
93
  const runtime = {
@@ -1,10 +1,10 @@
1
1
  import { r as formatJson, t as blocks } from "./output-Ggzq5_-t.js";
2
- import { b as appleCredentialsFromEnv, d as ENV_APPLE_PASSWORD, u as ENV_APPLE_ID, v as VERSION } from "./environment-CQn323uB.js";
3
- import { t as ApiError } from "./client-CimFymxG.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-QM7yfrXq.js";
5
- import { t as apiCall } from "./spinner-TZeZEeVv.js";
6
- import { n as SUPERWALL_HOME } from "./paths-oRuC18Kt.js";
7
- import { A as parseJson, D as field, j as textField, k as listField } from "./resources-FIrK7pE9.js";
2
+ import { b as appleCredentialsFromEnv, d as ENV_APPLE_PASSWORD, u as ENV_APPLE_ID, v as VERSION } from "./environment-a7W-0wg0.js";
3
+ import { t as ApiError } from "./client-CYtQvWJR.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-CEyXc1SI.js";
5
+ import { t as apiCall } from "./spinner-D6phP4Af.js";
6
+ import { n as SUPERWALL_HOME } from "./paths-Cp_lgyWO.js";
7
+ import { A as listField, M as textField, O as field, j as parseJson } from "./resources-DKn4itf3.js";
8
8
  import { c as replaceAppPurchaseKey, s as replaceAppAscKey } from "./client-BZ1UbpXz.js";
9
9
  import { t as timing } from "./timing-BVxPrYq3.js";
10
10
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -0,0 +1,19 @@
1
+ import "./token-4dQOfOaK.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-a7W-0wg0.js";
4
+ import "./storage-BcvKhvzZ.js";
5
+ import "./client-CYtQvWJR.js";
6
+ import "./held-CEyXc1SI.js";
7
+ import "./config-BO1Y87kV.js";
8
+ import "./spinner-D6phP4Af.js";
9
+ import "./ui-D_qf3Gvw.js";
10
+ import "./paths-Cp_lgyWO.js";
11
+ import "./resources-DKn4itf3.js";
12
+ import "./org-BJCyaL1b.js";
13
+ import "./lookup-Dor6ch5A.js";
14
+ import "./scope-92neiQ2q.js";
15
+ import "./client-BZ1UbpXz.js";
16
+ import "./timing-BVxPrYq3.js";
17
+ import { i as runAscKeysCreate, n as keyAccess, r as keyRole, t as createAndSaveKey } from "./create-BaP6hoQ1.js";
18
+
19
+ export { createAndSaveKey, keyAccess, keyRole, runAscKeysCreate };
@@ -1,13 +1,13 @@
1
- import "./token-BJsLGoSX.js";
1
+ import "./token-4dQOfOaK.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import { y as apiKeyFromEnv } from "./environment-CQn323uB.js";
4
- import { n as readSession } from "./storage-DqKJe13V.js";
3
+ import { y as apiKeyFromEnv } from "./environment-a7W-0wg0.js";
4
+ import { n as readSession } from "./storage-BcvKhvzZ.js";
5
5
  import "./spawn-DmmmHIP-.js";
6
6
  import { n as ui } from "./ui-D_qf3Gvw.js";
7
7
  import { n as fg, t as THEME } from "./theme-DUsCh-Vd.js";
8
- import { t as scanProject } from "./scan-CpbfZ2ju.js";
9
- import { t as detectExisting } from "./existing-CvOluc9U.js";
10
- import { t as detectDrivers } from "./drivers-C6eXj5-r.js";
8
+ import { t as scanProject } from "./scan-Be17rMcQ.js";
9
+ import { t as detectExisting } from "./existing-B7qxYiUX.js";
10
+ import { t as detectDrivers } from "./drivers-D0818zGc.js";
11
11
 
12
12
  //#region src/core/support/doctor.ts
13
13
  async function runDoctor(ctx, deps = {}) {
@@ -1,6 +1,6 @@
1
- import { t as getOAuthAccessToken } from "./token-BJsLGoSX.js";
2
- import { t as API_HOST, v as VERSION } from "./environment-CQn323uB.js";
3
- import { n as readSession } from "./storage-DqKJe13V.js";
1
+ import { t as getOAuthAccessToken } from "./token-4dQOfOaK.js";
2
+ import { t as API_HOST, v as VERSION } from "./environment-a7W-0wg0.js";
3
+ import { n as readSession } from "./storage-BcvKhvzZ.js";
4
4
  import { n as readVersion, r as spawnStream, t as onPath } from "./spawn-DmmmHIP-.js";
5
5
  import { basename, join } from "node:path";
6
6
  import { tmpdir } from "node:os";