@superwall/cli 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +10 -0
  2. package/dist/{apple-z2qjOzIZ.js → apple-Dyr7OFBx.js} +17 -16
  3. package/dist/approve-Czs1-JO9.js +186 -0
  4. package/dist/{assets-DXXegdDt.js → assets-BrB9jQPQ.js} +3 -3
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +3 -3
  7. package/dist/{billing-B8tOjsnY.js → billing-D5qqIlVb.js} +3 -3
  8. package/dist/{bind-Bx9K6LwP.js → bind-B3eEcRyp.js} +4 -4
  9. package/dist/browser-Bp3yRKlU.js +36 -0
  10. package/dist/{build-Bu2kkzRe.js → build-DD9pSwHX.js} +10 -8
  11. package/dist/{client-DOgk9gAS.js → client-AI9H4GGB.js} +3 -3
  12. package/dist/{config-BO1Y87kV.js → config-CGcG7GOt.js} +9 -1
  13. package/dist/{create-B03MAuPe.js → create-B4m-IKlr.js} +8 -8
  14. package/dist/create-CJljlkJK.js +20 -0
  15. package/dist/{create-DzC_89gq.js → create-ChfgWpiM.js} +41 -69
  16. package/dist/{doctor-BGZSKY_B.js → doctor-XtXW6tKE.js} +6 -6
  17. package/dist/download-2Zu2I_Og.js +58 -0
  18. package/dist/{drivers-DqLgQxkC.js → drivers-CMEL13gp.js} +4 -4
  19. package/dist/entry.js +69 -33
  20. package/dist/{environment-i8BhiBDB.js → environment-BWT2S4qC.js} +9 -2
  21. package/dist/{existing-BPOG5zLO.js → existing-b0GxFcnc.js} +2 -2
  22. package/dist/{session-BDLQUJyV.js → git-D7AVdugb.js} +97 -335
  23. package/dist/held-CX7Zf8u-.js +17 -0
  24. package/dist/{held-C56PYMRH.js → held-D3PUNky2.js} +7 -7
  25. package/dist/install-CVUXsx8c.js +103 -0
  26. package/dist/{integrate-DZ4Qvoch.js → integrate-qvKd9pVW.js} +29 -27
  27. package/dist/{log-NVhVe_oe.js → log-C0MDCfA2.js} +1 -1
  28. package/dist/{login-p9GVEKzD.js → login-COmGHrU5.js} +2 -1
  29. package/dist/login-ClnJi1Ea.js +17 -0
  30. package/dist/{login-ONZdK8vN.js → login-PMoXUGqq.js} +9 -42
  31. package/dist/{lookup-flTi0at0.js → lookup-gjcKIZvh.js} +4 -3
  32. package/dist/{migrate-DnXpbhL1.js → migrate-SkkLLdmr.js} +33 -28
  33. package/dist/{migration-DJ1uNKhk.js → migration-DS44-3Zr.js} +10 -10
  34. package/dist/{notification-url-CCDeS5S-.js → notification-url-BjQPLf4-.js} +4 -4
  35. package/dist/{open-QdsZ_N47.js → open-DQpm2yVs.js} +2 -2
  36. package/dist/{org-BiFPjoHD.js → org-C04eAO-j.js} +3 -2
  37. package/dist/organization-BOECL3vZ.js +39 -0
  38. package/dist/orgs-D6Kk96mG.js +81 -0
  39. package/dist/{paths-yRgm5Jpa.js → paths-REb-GrbX.js} +2 -2
  40. package/dist/{playbook-B-pRKNa4.js → playbook-Du4Oydbf.js} +11 -11
  41. package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
  42. package/dist/project-CP6hiHra.js +47 -0
  43. package/dist/{promote-Djzk4C81.js → promote-Dm2_b1WK.js} +24 -19
  44. package/dist/pull-DsdOoG-D.js +36 -0
  45. package/dist/{pull-BLA9XwHj.js → pull-F6pvO4To.js} +9 -28
  46. package/dist/pull-zYAbqo9n.js +106 -0
  47. package/dist/{push-gSBxGDik.js → push-BIFLhAiO.js} +9 -7
  48. package/dist/push-CJVfvFZq.js +29 -0
  49. package/dist/push-D_l9KJZN.js +290 -0
  50. package/dist/push-SVzv7fzE.js +22 -0
  51. package/dist/{registry-D3xmWk9p.js → registry-DIJB0mJa.js} +890 -158
  52. package/dist/resolve--GsHj0Q1.js +171 -0
  53. package/dist/{resources-BTnczJCA.js → resources-BaP3p_LY.js} +3 -80
  54. package/dist/{run-C1SoizcJ.js → run-C5OPwhvS.js} +2 -2
  55. package/dist/run-CgLmD2vR.js +1345 -0
  56. package/dist/{scan-Dwk_lT5q.js → scan-Bj5y0zTZ.js} +1 -1
  57. package/dist/scan-v_WTE722.js +4 -0
  58. package/dist/{scope-Db7blD-l.js → scope-Bp_zwJOo.js} +6 -5
  59. package/dist/scope-CCb_7UvN.js +89 -0
  60. package/dist/sdk-TvT0p_nO.js +71 -0
  61. package/dist/selection-BltBpyp5.js +179 -0
  62. package/dist/series-TAixFBWW.js +685 -0
  63. package/dist/{server-Cb2N75JL.js → server-CdVIboQn.js} +10 -8
  64. package/dist/server-CvJVusw3.js +29 -0
  65. package/dist/session-B8JNXkwN.js +6 -0
  66. package/dist/session-D3fgXQBt.js +219 -0
  67. package/dist/{session-CnDJp_HO.js → session-Ywim-P8M.js} +1 -1
  68. package/dist/{setup-BLahHpgy.js → setup-zzjtTy8k.js} +9 -8
  69. package/dist/skills/index.json +5 -0
  70. package/dist/skills/superwall/SKILL.md +48 -30
  71. package/dist/skills/superwall/references/api.md +3 -2
  72. package/dist/skills/superwall-editor/SKILL.md +7 -5
  73. package/dist/skills/superwall-framework/SKILL.md +11 -8
  74. package/dist/skills/superwall-framework/references/onboarding-state.md +21 -14
  75. package/dist/skills/superwall-workspaces/SKILL.md +313 -0
  76. package/dist/skills/superwall-workspaces/references/cli.md +174 -0
  77. package/dist/skills/superwall-workspaces/references/slots.md +103 -0
  78. package/dist/{skills-zebMTZyr.js → skills-2qYaUXGE.js} +15 -9
  79. package/dist/skills-8um2fBPS.js +14 -0
  80. package/dist/{source-push-DxuJuwEf.js → source-push-kAep4gPe.js} +6 -5
  81. package/dist/{spinner-BN3U1CVB.js → spinner-BANVLncC.js} +17 -5
  82. package/dist/starter-CiLrp1cN.js +190 -0
  83. package/dist/status-CoYMK7QL.js +139 -0
  84. package/dist/{storage-VagEaaJC.js → storage-DzP22xKn.js} +1 -1
  85. package/dist/storekit-D5eopLM0.js +17 -0
  86. package/dist/{storekit-CoOf4Rvh.js → storekit-n1x0bWkQ.js} +4 -4
  87. package/dist/{telemetry-CM0BDwCK.js → telemetry-CXN6f-ZX.js} +2 -2
  88. package/dist/{token-lUUOkTJA.js → token-FmeHywYt.js} +1 -1
  89. package/dist/tools-skills/superwall/SKILL.md +49 -31
  90. package/dist/tools-skills/superwall/references/api.md +3 -2
  91. package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
  92. package/dist/tools.d.ts +1 -1
  93. package/dist/tools.js +575 -75
  94. package/dist/try-BWbzgelb.js +120 -0
  95. package/dist/{selection-u2KiKu_d.js → types-JdxmnCko.js} +1 -178
  96. package/dist/upgrade-Bk5boOgW.js +206 -0
  97. package/dist/upgrade-CoWCEnoi.js +7 -0
  98. package/package.json +5 -3
  99. package/prompts/commandments.xml +2 -0
  100. package/dist/create-BdZS_T68.js +0 -19
  101. package/dist/held-DSNUY-NZ.js +0 -16
  102. package/dist/login-Blrkm6oi.js +0 -16
  103. package/dist/push-BkMgOT6X.js +0 -24
  104. package/dist/scan-Kp-MAutK.js +0 -4
  105. package/dist/server-psYghr9K.js +0 -24
  106. package/dist/session-CehHJWZk.js +0 -6
  107. package/dist/skills-DDV4zcLR.js +0 -14
  108. package/dist/storekit-BcBb2jXB.js +0 -16
  109. package/dist/upgrade-CpTJv_M7.js +0 -7
  110. package/dist/upgrade-DZbKb67W.js +0 -117
  111. /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
  112. /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
  113. /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
  114. /package/dist/{reports-CwwKLUh0.js → reports-CuhB1_ub.js} +0 -0
  115. /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
  116. /package/dist/{storage-gRyQetN9.d.ts → storage-BjQCiTuz.d.ts} +0 -0
  117. /package/dist/{timing-BVxPrYq3.js → timing-Ca0TXY-A.js} +0 -0
@@ -0,0 +1,120 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import { t as ApiError } from "./client-AI9H4GGB.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./spinner-BANVLncC.js";
8
+ import "./ui-D_qf3Gvw.js";
9
+ import "./orgs-D6Kk96mG.js";
10
+ import "./resources-BaP3p_LY.js";
11
+ import "./lookup-gjcKIZvh.js";
12
+ import { n as openBrowser } from "./browser-Bp3yRKlU.js";
13
+ import "./types-JdxmnCko.js";
14
+ import "./scope-CCb_7UvN.js";
15
+ import "./download-2Zu2I_Og.js";
16
+ import { n as dashboardOrigin } from "./resolve--GsHj0Q1.js";
17
+ import { a as findEntrypoint, r as WorkspaceError, s as readProject } from "./project-CP6hiHra.js";
18
+ import { a as summarizeSeries, c as defaultRange, h as DRAFT_MODULE_MAX_BYTES, n as parseFilters, u as bundleWorkspace } from "./series-TAixFBWW.js";
19
+ import { n as resolveOrganization, t as resolveAppScope } from "./organization-BOECL3vZ.js";
20
+ import { i as warnIfSdkBehind } from "./sdk-TvT0p_nO.js";
21
+
22
+ //#region src/core/workspaces/try.ts
23
+ async function postDraft(ctx, path, body) {
24
+ try {
25
+ return await ctx.api.post(path, body);
26
+ } catch (error) {
27
+ if (error instanceof ApiError && error.status === 400) throw new WorkspaceError(error.message);
28
+ throw error;
29
+ }
30
+ }
31
+ async function uploadDraft(ctx, project, organizationId, wrangler) {
32
+ const { module, bytes } = await bundleWorkspace(project.root, wrangler);
33
+ if (bytes > DRAFT_MODULE_MAX_BYTES) throw new WorkspaceError(`The bundle is ${bytes} bytes; a draft can be ${DRAFT_MODULE_MAX_BYTES} at most.`);
34
+ return postDraft(ctx, "/v2/workspaces/drafts", {
35
+ organization_id: Number(organizationId),
36
+ manifest: project.manifest,
37
+ module
38
+ });
39
+ }
40
+ async function tryMetric(ctx, project, entrypoint, input, wrangler) {
41
+ if (input.app === void 0) throw new WorkspaceError("A metric runs for one app. Say which with --app <id>.");
42
+ const { organizationId, applicationId } = await resolveAppScope(ctx.api, input.app, input.org);
43
+ if (organizationId === void 0) throw new WorkspaceError(`Couldn't find the organization of app ${input.app}. Say which with --org <id>.`);
44
+ const range = defaultRange(input.days);
45
+ const filters = parseFilters(input.filter);
46
+ const draft = await uploadDraft(ctx, project, organizationId, wrangler);
47
+ const run = await postDraft(ctx, `/v2/workspaces/drafts/${encodeURIComponent(draft.id)}/metric`, {
48
+ organization_id: Number(organizationId),
49
+ application_id: Number(applicationId),
50
+ entrypoint_id: entrypoint.id,
51
+ from: input.from ?? range.from,
52
+ to: input.to ?? range.to,
53
+ interval: input.interval,
54
+ ...input.breakdown === void 0 ? {} : { breakdown: input.breakdown },
55
+ ...input.filter.length === 0 ? {} : { filters }
56
+ });
57
+ const summary = summarizeSeries(run.series);
58
+ if (ctx.json) {
59
+ ctx.output.data({
60
+ draft_id: draft.id,
61
+ expires_at: draft.expires_at,
62
+ requested_scopes: draft.requested_scopes,
63
+ entrypoint_id: entrypoint.id,
64
+ summary,
65
+ series: run.series
66
+ });
67
+ return;
68
+ }
69
+ ctx.ui.success(`Ran \`${entrypoint.id}\` on the real runtime, as you. Only you can reach this draft, until ${draft.expires_at}.`);
70
+ ctx.ui.list({
71
+ empty: "It returned no points.",
72
+ items: summary.map((series) => ({
73
+ label: series.name,
74
+ meta: `${series.points} points, sum ${round(series.sum)}, latest ${round(series.last)} at ${series.lastAt}`
75
+ }))
76
+ });
77
+ if (input.points) ctx.ui.list({ items: run.series.points.map((point) => ({
78
+ label: point.t,
79
+ meta: `${point.breakdown ?? ""} ${round(point.value)}`.trim()
80
+ })) });
81
+ }
82
+ const round = (value) => Math.round(value * 1e3) / 1e3;
83
+ async function tryFrame(ctx, project, entrypoint, input, seams) {
84
+ const scope = input.app === void 0 ? { organizationId: await resolveOrganization(ctx, input.org) } : await resolveAppScope(ctx.api, input.app, input.org);
85
+ if (scope.organizationId === void 0) throw new WorkspaceError(`Couldn't find the organization of app ${input.app}. Say which with --org <id>.`);
86
+ const draft = await uploadDraft(ctx, project, scope.organizationId, seams.wrangler);
87
+ const search = new URLSearchParams({ entrypoint: entrypoint.id });
88
+ if (scope.applicationId !== void 0) search.set("app", scope.applicationId);
89
+ if (input.campaign !== void 0) search.set("campaign", input.campaign);
90
+ if (input.user !== void 0) search.set("user", input.user);
91
+ if (input.environment !== void 0) search.set("environment", input.environment);
92
+ const url = `${dashboardOrigin(ctx.api.host)}/${scope.organizationId}/workspace-drafts/${draft.id}?${search}`;
93
+ if (ctx.json) {
94
+ ctx.output.data({
95
+ draft_id: draft.id,
96
+ expires_at: draft.expires_at,
97
+ requested_scopes: draft.requested_scopes,
98
+ entrypoint_id: entrypoint.id,
99
+ url
100
+ });
101
+ return;
102
+ }
103
+ ctx.ui.success(`Uploaded a draft of \`${entrypoint.id}\`. It runs as you, and only you can reach it, until ${draft.expires_at}.`);
104
+ ctx.ui.info(`Open ${url}`);
105
+ if (input.open && ctx.outputMode === "rich") await (seams.open ?? openBrowser)(url);
106
+ }
107
+ function tryReadout(entrypoint) {
108
+ throw new WorkspaceError(`\`${entrypoint.id}\` (${entrypoint.slot}) is a readout, and readouts can't be tried on the real runtime yet. Run \`superwall workspaces dev\` to run it locally.`);
109
+ }
110
+ async function runWorkspaceTry(ctx, input, seams = {}) {
111
+ const project = readProject(input.dir);
112
+ const entrypoint = findEntrypoint(project.manifest, input.entrypoint);
113
+ await warnIfSdkBehind(ctx.ui, project.root);
114
+ if (entrypoint.slot === "chart.source@1") return tryMetric(ctx, project, entrypoint, input, seams.wrangler);
115
+ if (entrypoint.slot === "campaign.metric@1") return tryReadout(entrypoint);
116
+ return tryFrame(ctx, project, entrypoint, input, seams);
117
+ }
118
+
119
+ //#endregion
120
+ export { runWorkspaceTry };
@@ -1,60 +1,6 @@
1
- import { n as billingPlanOf } from "./resources-BTnczJCA.js";
2
- import { createRequire } from "node:module";
3
1
  import * as fs from "node:fs";
4
- import { globSync, readFileSync, statSync } from "node:fs";
5
2
  import * as path from "node:path";
6
- import { join, resolve } from "node:path";
7
- import pc from "picocolors";
8
- import { pathToFileURL } from "node:url";
9
3
 
10
- //#region src/core/paywalls/project/framework.ts
11
- var FrameworkNotFoundError = class extends Error {
12
- constructor(dir) {
13
- super(`No superwall framework found from ${dir}.\nInstall it in the project (\`npm i superwall\` / \`bun add superwall\`) and make sure you run this inside a project with a superwall/ directory.`);
14
- }
15
- };
16
- async function importSubpath(packageDir, subpath) {
17
- return import(pathToFileURL(createRequire(join(packageDir, "package.json")).resolve(subpath)).href);
18
- }
19
- function fn(mod, name, subpath) {
20
- const candidate = mod[name];
21
- if (typeof candidate !== "function") throw new Error(`This project's superwall version does not export ${name} from ${subpath} — update the project's superwall dependency.`);
22
- return candidate;
23
- }
24
- function resolveFrameworkDir(cwd) {
25
- for (const anchor of [join(cwd, "superwall", "package.json"), join(cwd, "package.json")]) try {
26
- return join(createRequire(anchor).resolve("superwall/package.json"), "..");
27
- } catch {
28
- continue;
29
- }
30
- throw new FrameworkNotFoundError(cwd);
31
- }
32
- function frameworkVersion(cwd) {
33
- try {
34
- const { version } = JSON.parse(readFileSync(join(resolveFrameworkDir(cwd), "package.json"), "utf8"));
35
- if (typeof version === "string" && version !== "") return version;
36
- } catch {
37
- return "unknown";
38
- }
39
- return "unknown";
40
- }
41
- async function resolveFramework(cwd) {
42
- const dir = resolveFrameworkDir(cwd);
43
- const [discover, build, preview] = await Promise.all([
44
- importSubpath(dir, "superwall/discover"),
45
- importSubpath(dir, "superwall/build"),
46
- importSubpath(dir, "superwall/preview")
47
- ]);
48
- const studioProject = typeof preview.buildStudioProject === "function" ? preview.buildStudioProject : void 0;
49
- return {
50
- discoverProject: fn(discover, "discoverProject", "superwall/discover"),
51
- buildSnapshot: fn(build, "buildSnapshot", "superwall/build"),
52
- startPreviewServer: fn(preview, "startPreviewServer", "superwall/preview"),
53
- studioProject
54
- };
55
- }
56
-
57
- //#endregion
58
4
  //#region src/core/paywalls/project/lock.ts
59
5
  const isScreenOrigin = (origin) => "path" in origin;
60
6
  const isFileName = (value) => typeof value === "string" && value !== "" && !/[\\/]/.test(value) && !value.startsWith(".");
@@ -339,127 +285,4 @@ function writeProjectTypes(project, products = {}) {
339
285
  }
340
286
 
341
287
  //#endregion
342
- //#region src/core/paywalls/pipeline/output.ts
343
- const kb = (bytes) => `${(bytes / 1024).toFixed(1)} kB`;
344
- const weight = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : kb(bytes);
345
- const SHORT_SHA = 7;
346
- const shortSha = (sha) => typeof sha === "string" && sha.length >= SHORT_SHA ? sha.slice(0, SHORT_SHA) : void 0;
347
- function pushedLine(input) {
348
- const sha = shortSha(input.snapshotId);
349
- const pushed = `Pushed ${input.promoting ? `version ${input.version}` : pc.yellow(`version ${input.version}`)}${sha ? ` ${pc.dim(`(${sha})`)}` : ""}`;
350
- return input.promoting || input.live === void 0 ? pushed : `${pushed} · ${pc.dim(`live ${input.live}`)}`;
351
- }
352
- function transition(before, after) {
353
- if (before === void 0) return `Promoted ${pc.green(`version ${after}`)}`;
354
- if (before === after) return `Version ${pc.green(String(after))} already live`;
355
- if (after < before) return `Rolled back ${pc.green(`version ${before} → ${after}`)}`;
356
- return `Promoted ${pc.green(`version ${before} → ${after}`)}`;
357
- }
358
- const BIND_VERB = {
359
- lock: "Linked to",
360
- matched: "Linked to",
361
- created: "Created",
362
- renamed: "Rebound after rename to"
363
- };
364
- const LAYOUT_HINT = "expected superwall/{paywalls,funnels}/<id>/ with config.ts and app/index.tsx";
365
- const NOTE_LIMIT = 2e3;
366
- const PENDING_NAMES = 10;
367
- function pendingPromoteWarning(pending, multi = false) {
368
- if (pending.length === 0) return void 0;
369
- const entries = pending.map((entry) => typeof entry === "string" ? { id: entry } : entry);
370
- const ids = [...new Set(entries.map((entry) => entry.id))];
371
- const platforms = new Set(entries.flatMap((entry) => entry.platform ? [entry.platform] : []));
372
- const platformFlag = multi && platforms.size === 1 ? ` --platform ${[...platforms][0]}` : "";
373
- const command = `superwall promote --id ${ids.join(",")}${platformFlag}`;
374
- const labels = entries.map((entry) => multi && entry.platform ? `${entry.id} · ${entry.platform}` : entry.id);
375
- if (labels.length === 1) return `${labels[0]} is pushed but not live — run \`${command}\` to publish it.`;
376
- const shown = labels.slice(0, PENDING_NAMES).map((label) => ` ${label}`);
377
- const rest = labels.length - shown.length;
378
- return [
379
- `These ${labels.length} paywalls are pushed but not live:`,
380
- ...shown,
381
- ...rest > 0 ? [` …and ${rest} more`] : [],
382
- "",
383
- ` ${command}`
384
- ].join("\n");
385
- }
386
- function resolveNote(message) {
387
- if (message === void 0) return void 0;
388
- if (message.length > NOTE_LIMIT) throw new Error(`Publish note is ${message.length} characters (limit ${NOTE_LIMIT}).`);
389
- return message;
390
- }
391
- const took = (since) => {
392
- const seconds = (Date.now() - since) / 1e3;
393
- return pc.dim(seconds < 10 ? `(${seconds.toFixed(1)}s)` : `(${Math.round(seconds)}s)`);
394
- };
395
-
396
- //#endregion
397
- //#region src/core/paywalls/pipeline/selection.ts
398
- function resolveProjectDir(dir) {
399
- const [first] = resolveProjectDirs(dir === void 0 ? [] : [dir]);
400
- return first ?? process.cwd();
401
- }
402
- function resolveProjectDirs(dirs) {
403
- const list = dirs.filter((entry) => entry.length > 0);
404
- if (list.length === 0) return [process.cwd()];
405
- const expanded = list.flatMap((entry) => entry.includes("*") ? expandGlob(entry) : [entry]);
406
- return [...new Set(expanded.map((entry) => resolve(entry)))];
407
- }
408
- function expandGlob(pattern) {
409
- try {
410
- return [...globSync(pattern)].filter((entry) => statSync(entry, { throwIfNoEntry: false })?.isDirectory() ?? false).sort();
411
- } catch {
412
- return [pattern];
413
- }
414
- }
415
- function requireProject(project, dir) {
416
- if (!project.marker) throw new Error(`Not a superwall project: ${dir}\nExpected a package.json here (or in superwall/) that depends on superwall.`);
417
- if (project.packageName === "superwall") throw new Error(`${project.superwallDir}/package.json is named "superwall".\nNode resolves every bare \`import "superwall"\` inside a package to that package itself, so the framework can never load. Rename it to your project's name.`);
418
- return project;
419
- }
420
- function parseIds(values) {
421
- return values.flatMap((entry) => entry.split(",")).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
422
- }
423
- function selectSurfaces(project, ids) {
424
- const wanted = parseIds(ids);
425
- const known = project.surfaces.map((surface) => surface.id).join(", ");
426
- if (wanted.length === 0) {
427
- if (project.surfaces.length === 0) throw new Error(`No paywalls or funnels found — ${LAYOUT_HINT}.`);
428
- return [...project.surfaces];
429
- }
430
- const selected = [];
431
- for (const id of wanted) {
432
- const matches = project.surfaces.filter((surface$1) => surface$1.id === id);
433
- if (matches.length === 0) throw new Error(`No paywall or funnel named "${id}"` + (known ? ` — this project has: ${known}.` : ` — ${LAYOUT_HINT}.`));
434
- if (matches.length > 1) {
435
- const kinds = matches.map((surface$1) => `${surface$1.kind}/${surface$1.id}`).join(" and ");
436
- throw new Error(`"${id}" is ambiguous — this project has ${kinds}.`);
437
- }
438
- const surface = matches[0];
439
- if (surface && !selected.includes(surface)) selected.push(surface);
440
- }
441
- return selected;
442
- }
443
- function requireClean(surfaces) {
444
- const problems = surfaces.flatMap((surface) => surface.diagnostics ?? []);
445
- if (problems.length === 0) return;
446
- throw new Error([
447
- ...problems,
448
- "",
449
- "Publishing is immutable — fix these first, then push again."
450
- ].join("\n"));
451
- }
452
- function storesDiffer(products, live, comparePlans = true) {
453
- return products.some((product) => {
454
- const pushed = live?.find((ref) => ref.reference === product.reference_name && ref.identifier === product.identifier);
455
- if (pushed === void 0) return false;
456
- if (pushed.store !== void 0 && pushed.store !== product.store) return true;
457
- return comparePlans && pushed.billingPlan !== billingPlanOf(product.billing_plan_type);
458
- });
459
- }
460
- function needsWork(built, pushed, live) {
461
- return built !== pushed && built !== live;
462
- }
463
-
464
- //#endregion
465
- export { removeBinding as A, formatLock as C, parseLock as D, originKey as E, writeOrigin as F, writeSnapshot as I, writeSources as L, writeBinding as M, writeBindings as N, parseSources as O, writeLock as P, frameworkVersion as R, describeBindings as S, isScreenOrigin as T, weight as _, resolveProjectDir as a, writeProjectTypes as b, storesDiffer as c, kb as d, pendingPromoteWarning as f, transition as g, took as h, requireProject as i, writeApp as j, readLock as k, BIND_VERB as l, resolveNote as m, parseIds as n, resolveProjectDirs as o, pushedLine as p, requireClean as r, selectSurfaces as s, needsWork as t, LAYOUT_HINT as u, TYPES_FILE as v, formatSharedLock as w, NewerLockError as x, collectProjectDeclarations as y, resolveFramework as z };
288
+ export { writeLock as _, describeBindings as a, writeSources as b, isScreenOrigin as c, parseSources as d, readLock as f, writeBindings as g, writeBinding as h, NewerLockError as i, originKey as l, writeApp as m, collectProjectDeclarations as n, formatLock as o, removeBinding as p, writeProjectTypes as r, formatSharedLock as s, TYPES_FILE as t, parseLock as u, writeOrigin as v, writeSnapshot as y };
@@ -0,0 +1,206 @@
1
+ import { _ as RUNNING_VIA_NPX, a as AUTO_UPDATE, x as VERSION } from "./environment-BWT2S4qC.js";
2
+ import { c as readSkillsSync, d as writeAutoUpdate, l as readUpdateCheck, n as readAutoUpdate, v as writeUpdateCheck } from "./config-CGcG7GOt.js";
3
+ import { r as spawnStream } from "./spawn-DmmmHIP-.js";
4
+ import { execFileSync } from "node:child_process";
5
+ import { existsSync, realpathSync } from "node:fs";
6
+ import { tmpdir } from "node:os";
7
+ import { join, sep } from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+ import pc from "picocolors";
10
+
11
+ //#region src/core/support/upgrade.ts
12
+ const CHECK_INTERVAL_MS = 1440 * 60 * 1e3;
13
+ const REGISTRY_URL = "https://registry.npmjs.org/superwall/latest";
14
+ const pending = [];
15
+ function isNewerVersion(latest, current) {
16
+ const l = latest.split(".").map((n) => parseInt(n, 10));
17
+ const c = current.split(".").map((n) => parseInt(n, 10));
18
+ for (let i = 0; i < 3; i++) {
19
+ const a = l[i] ?? 0;
20
+ const b = c[i] ?? 0;
21
+ if (Number.isNaN(a) || Number.isNaN(b)) return false;
22
+ if (a !== b) return a > b;
23
+ }
24
+ return false;
25
+ }
26
+ async function selectLatestVersion() {
27
+ try {
28
+ const res = await fetch(REGISTRY_URL, {
29
+ headers: { accept: "application/json" },
30
+ signal: AbortSignal.timeout(5e3)
31
+ });
32
+ if (!res.ok) return null;
33
+ const { version } = await res.json();
34
+ return version ?? null;
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+ function majorOf(version) {
40
+ return parseInt(version.split(".")[0] ?? "", 10);
41
+ }
42
+ function selectAvailableUpdate() {
43
+ const latest = readUpdateCheck()?.latest;
44
+ if (!latest || !isNewerVersion(latest, VERSION)) return null;
45
+ return latest;
46
+ }
47
+ function refreshUpdateCheck() {
48
+ if (process.env.NODE_TEST_CONTEXT) return;
49
+ const cached = readUpdateCheck();
50
+ if ((cached?.checkedAt ? Date.now() - Date.parse(cached.checkedAt) : Infinity) < CHECK_INTERVAL_MS) return;
51
+ pending.push(selectLatestVersion().then((version) => {
52
+ if (version) writeUpdateCheck({
53
+ latest: version,
54
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString()
55
+ });
56
+ }));
57
+ }
58
+ async function flushUpdateCheck(capMs = 2e3) {
59
+ if (pending.length === 0) return;
60
+ await Promise.race([Promise.allSettled(pending), new Promise((done) => setTimeout(done, capMs).unref())]);
61
+ }
62
+ function maybeNotifyUpdate(stream) {
63
+ const latest = selectAvailableUpdate();
64
+ if (!latest) return;
65
+ stream.write(`${pc.dim(`Update available ${VERSION} → ${latest} · run \`superwall upgrade\``)}\n`);
66
+ }
67
+ function selectAutoUpdate() {
68
+ if (process.env.NODE_TEST_CONTEXT || !AUTO_UPDATE()) return null;
69
+ const latest = selectAvailableUpdate();
70
+ if (!latest || majorOf(latest) !== majorOf(VERSION)) return null;
71
+ const last = readAutoUpdate();
72
+ if (last?.version === latest && Date.now() - Date.parse(last.startedAt) < CHECK_INTERVAL_MS) return null;
73
+ return latest;
74
+ }
75
+ function recordAutoUpdate(version) {
76
+ writeAutoUpdate({
77
+ version,
78
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
79
+ });
80
+ }
81
+ function printAutoUpdate(stream, version) {
82
+ stream.write(`${pc.dim(`Updating ${VERSION} → ${version} in the background`)}\n`);
83
+ }
84
+ function isGlobalInstall(file = fileURLToPath(import.meta.url)) {
85
+ try {
86
+ const root = execFileSync("npm", ["root", "--global"], {
87
+ encoding: "utf8",
88
+ timeout: 3e3,
89
+ stdio: [
90
+ "ignore",
91
+ "pipe",
92
+ "ignore"
93
+ ]
94
+ }).trim();
95
+ return root !== "" && realpathSync(file).startsWith(`${realpathSync(root)}${sep}`);
96
+ } catch {
97
+ return false;
98
+ }
99
+ }
100
+ const SKILLS_OUTCOME = {
101
+ current: "Superwall skills are up to date",
102
+ updated: "Superwall skills updated",
103
+ failed: "Superwall skills not updated"
104
+ };
105
+ async function updateAgentSkills(ctx, work) {
106
+ const spin = ctx.ui.spinner();
107
+ spin.start("Checking Superwall skills");
108
+ const skills = await work().catch(() => "failed");
109
+ spin.stop(SKILLS_OUTCOME[skills]);
110
+ if (skills === "failed") ctx.ui.warn("Couldn't update the Superwall skills. Run `superwall skills --force` to retry.");
111
+ return skills;
112
+ }
113
+ async function updateSkillsInProcess() {
114
+ const { updateSkills } = await import("./skills-8um2fBPS.js");
115
+ return updateSkills();
116
+ }
117
+ async function updateSkillsWithInstalledCli(version) {
118
+ const prefix = [];
119
+ const { code } = await spawnStream({
120
+ bin: "npm",
121
+ args: ["prefix", "--global"],
122
+ cwd: process.cwd(),
123
+ onStdoutLine: (line) => prefix.push(line.trim())
124
+ });
125
+ const bin = prefix[0] ? join(prefix[0], "bin", "superwall") : void 0;
126
+ if (code !== 0 || !bin || !existsSync(bin)) return "failed";
127
+ const startedAt = Date.now();
128
+ if ((await spawnStream({
129
+ bin,
130
+ args: [
131
+ "skills",
132
+ "--force",
133
+ "--yes"
134
+ ],
135
+ cwd: tmpdir(),
136
+ onStdoutLine: () => {},
137
+ onStderrLine: () => {}
138
+ })).code !== 0) return "failed";
139
+ const sync = readSkillsSync();
140
+ return sync?.cliVersion === version && Date.parse(sync.syncedAt) >= startedAt ? "updated" : "failed";
141
+ }
142
+ async function runUpgrade(ctx, pinned) {
143
+ const { ui } = ctx;
144
+ if (RUNNING_VIA_NPX()) {
145
+ ui.info("You're running via npx, which always fetches the latest published version - nothing to upgrade.");
146
+ const skills$1 = await updateAgentSkills(ctx, updateSkillsInProcess);
147
+ if (ctx.json) return ctx.output.data({
148
+ upgraded: false,
149
+ via: "npx",
150
+ skills: skills$1
151
+ });
152
+ return;
153
+ }
154
+ ui.intro("Superwall upgrade");
155
+ const spin = ui.spinner();
156
+ spin.start("Checking the latest version");
157
+ const latest = pinned ?? await selectLatestVersion();
158
+ if (!latest) {
159
+ spin.stop("Check failed");
160
+ throw new Error("Couldn't reach the npm registry - try again.");
161
+ }
162
+ if (!isNewerVersion(latest, VERSION)) {
163
+ spin.stop(`You're on the latest version (\`${VERSION}\`)`);
164
+ const skills$1 = await updateAgentSkills(ctx, updateSkillsInProcess);
165
+ if (ctx.json) return ctx.output.data({
166
+ upgraded: false,
167
+ version: VERSION,
168
+ skills: skills$1
169
+ });
170
+ return;
171
+ }
172
+ spin.message(`Upgrading \`${VERSION}\` → \`${latest}\``);
173
+ const errors = [];
174
+ const { code } = await spawnStream({
175
+ bin: "npm",
176
+ args: [
177
+ "install",
178
+ "--global",
179
+ `superwall@${latest}`
180
+ ],
181
+ cwd: process.cwd(),
182
+ onStdoutLine: () => {},
183
+ onStderrLine: (line) => errors.push(line)
184
+ });
185
+ if (code !== 0) {
186
+ spin.stop("Upgrade failed");
187
+ const detail = errors.slice(-3).join(" ").trim();
188
+ throw new Error(`npm couldn't upgrade the package${detail ? ` (${detail.slice(0, 200)})` : ""}. Try: npm install --global superwall@latest`);
189
+ }
190
+ writeUpdateCheck({
191
+ latest,
192
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString()
193
+ });
194
+ spin.stop(`Upgraded \`${VERSION}\` → \`${latest}\``);
195
+ const skills = await updateAgentSkills(ctx, () => updateSkillsWithInstalledCli(latest));
196
+ if (ctx.json) return ctx.output.data({
197
+ upgraded: true,
198
+ from: VERSION,
199
+ to: latest,
200
+ skills
201
+ });
202
+ ui.outro("You're on the latest version.");
203
+ }
204
+
205
+ //#endregion
206
+ export { printAutoUpdate as a, runUpgrade as c, maybeNotifyUpdate as i, selectAutoUpdate as l, isGlobalInstall as n, recordAutoUpdate as o, isNewerVersion as r, refreshUpdateCheck as s, flushUpdateCheck as t };
@@ -0,0 +1,7 @@
1
+ import "./output-Ggzq5_-t.js";
2
+ import "./environment-BWT2S4qC.js";
3
+ import "./config-CGcG7GOt.js";
4
+ import "./spawn-DmmmHIP-.js";
5
+ import { a as printAutoUpdate, c as runUpgrade, i as maybeNotifyUpdate, l as selectAutoUpdate, n as isGlobalInstall, o as recordAutoUpdate, r as isNewerVersion, s as refreshUpdateCheck, t as flushUpdateCheck } from "./upgrade-Bk5boOgW.js";
6
+
7
+ export { flushUpdateCheck, isGlobalInstall, isNewerVersion, maybeNotifyUpdate, printAutoUpdate, recordAutoUpdate, refreshUpdateCheck, runUpgrade, selectAutoUpdate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superwall/cli",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "The official CLI for managing Superwall from your terminal or coding agent.",
5
5
  "keywords": [
6
6
  "agent",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@anthropic-ai/claude-agent-sdk": "0.3.201",
67
- "@superwall/studio": "2.3.1",
67
+ "@superwall/studio": "2.5.0",
68
68
  "ansi-escapes": "^7.3.0",
69
69
  "fast-glob": "^3.3.3",
70
70
  "ink": "^5.2.1",
@@ -80,9 +80,11 @@
80
80
  "@types/react": "^18.3.31",
81
81
  "@types/yargs": "^17.0.33",
82
82
  "ink-testing-library": "^4.0.0",
83
+ "react-dom": "^18.3.1",
83
84
  "tsdown": "^0.15.0",
84
85
  "tsx": "^4.19.0",
85
- "typescript": "^5.7.0"
86
+ "typescript": "^5.7.0",
87
+ "wrangler": "4.157.0"
86
88
  },
87
89
  "engines": {
88
90
  "node": ">=20.0.0"
@@ -13,5 +13,7 @@
13
13
 
14
14
  <rule>Follow the task's output instructions exactly: for an implementation task, do NOT write a long summary - end with '[STATUS] Done'; for a review/report task, end with the concise report it asks for.</rule>
15
15
 
16
+ <rule>When you confirm a Superwall bug, a wrong or missing doc, or a capability the user needed that Superwall lacks, report it yourself without asking (Superwall's terms cover it): `superwall feedback "MESSAGE" --kind bug|docs|idea --use-case "USE_CASE" --app APP_ID --json`, where MESSAGE says what you ran, expected and got, and USE_CASE what the user is trying to do and why. Leave out secrets and end users' personal data. Then say so in one [STATUS] line.</rule>
17
+
16
18
  <rule>If you cannot complete the integration safely (ambiguous project, missing entry point, would require destructive changes), stop and explain what you need instead of guessing.</rule>
17
19
  </rules>
@@ -1,19 +0,0 @@
1
- import "./token-lUUOkTJA.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import "./client-DOgk9gAS.js";
6
- import "./held-C56PYMRH.js";
7
- import "./config-BO1Y87kV.js";
8
- import "./spinner-BN3U1CVB.js";
9
- import "./ui-D_qf3Gvw.js";
10
- import "./paths-yRgm5Jpa.js";
11
- import "./resources-BTnczJCA.js";
12
- import "./org-BiFPjoHD.js";
13
- import "./lookup-flTi0at0.js";
14
- import "./scope-Db7blD-l.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-B03MAuPe.js";
18
-
19
- export { createAndSaveKey, keyAccess, keyRole, runAscKeysCreate };
@@ -1,16 +0,0 @@
1
- import "./token-lUUOkTJA.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import "./client-DOgk9gAS.js";
6
- import { t as upsertHeldKey } from "./held-C56PYMRH.js";
7
- import "./config-BO1Y87kV.js";
8
- import "./spinner-BN3U1CVB.js";
9
- import "./ui-D_qf3Gvw.js";
10
- import "./resources-BTnczJCA.js";
11
- import "./org-BiFPjoHD.js";
12
- import "./lookup-flTi0at0.js";
13
- import "./scope-Db7blD-l.js";
14
- import "./client-BZ1UbpXz.js";
15
-
16
- export { upsertHeldKey };
@@ -1,16 +0,0 @@
1
- import "./token-lUUOkTJA.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import "./client-DOgk9gAS.js";
6
- import "./config-BO1Y87kV.js";
7
- import "./telemetry-CM0BDwCK.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-BN3U1CVB.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-Dwk_lT5q.js";
12
- import "./paths-yRgm5Jpa.js";
13
- import { i as startLogin, n as pollLogin, r as runLogin, t as performLogin } from "./login-ONZdK8vN.js";
14
- import "./skills-zebMTZyr.js";
15
-
16
- export { performLogin, pollLogin, runLogin, startLogin };
@@ -1,24 +0,0 @@
1
- import "./token-lUUOkTJA.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import "./client-DOgk9gAS.js";
6
- import "./config-BO1Y87kV.js";
7
- import "./telemetry-CM0BDwCK.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-BN3U1CVB.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-Dwk_lT5q.js";
12
- import "./paths-yRgm5Jpa.js";
13
- import "./resources-BTnczJCA.js";
14
- import "./lookup-flTi0at0.js";
15
- import "./login-ONZdK8vN.js";
16
- import "./skills-zebMTZyr.js";
17
- import "./assets-DXXegdDt.js";
18
- import "./selection-u2KiKu_d.js";
19
- import "./session-BDLQUJyV.js";
20
- import "./source-push-DxuJuwEf.js";
21
- import { i as timed, n as runPush, r as runPushPipeline, t as group } from "./push-gSBxGDik.js";
22
- import "./login-p9GVEKzD.js";
23
-
24
- export { group, runPush, runPushPipeline, timed };
@@ -1,4 +0,0 @@
1
- import "./environment-i8BhiBDB.js";
2
- import { t as scanProject } from "./scan-Dwk_lT5q.js";
3
-
4
- export { scanProject };
@@ -1,24 +0,0 @@
1
- import "./token-lUUOkTJA.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-i8BhiBDB.js";
4
- import "./storage-VagEaaJC.js";
5
- import "./client-DOgk9gAS.js";
6
- import "./config-BO1Y87kV.js";
7
- import "./telemetry-CM0BDwCK.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-BN3U1CVB.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-Dwk_lT5q.js";
12
- import "./paths-yRgm5Jpa.js";
13
- import "./resources-BTnczJCA.js";
14
- import "./lookup-flTi0at0.js";
15
- import "./login-ONZdK8vN.js";
16
- import "./skills-zebMTZyr.js";
17
- import "./assets-DXXegdDt.js";
18
- import "./selection-u2KiKu_d.js";
19
- import "./session-BDLQUJyV.js";
20
- import "./source-push-DxuJuwEf.js";
21
- import "./login-p9GVEKzD.js";
22
- import { t as runStudio } from "./server-Cb2N75JL.js";
23
-
24
- export { runStudio };