@superwall/cli 1.6.2 → 2.0.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 (162) hide show
  1. package/README.md +281 -34
  2. package/dist/apple-CkKlHBZ9.js +195 -0
  3. package/dist/auth.d.ts +4 -19
  4. package/dist/auth.js +4 -2
  5. package/dist/{actions-H7f6knyY.js → billing-XCZU_T46.js} +98 -28
  6. package/dist/{bind-BIzaGq8K.js → bind-drne__Ys.js} +38 -33
  7. package/dist/{build-B7BS1rF2.js → build-Gpdq5QXP.js} +20 -26
  8. package/dist/client-BZ1UbpXz.js +66 -0
  9. package/dist/client-DP6Rc0t_.js +176 -0
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/create-BBrtgUgS.js +969 -0
  12. package/dist/{create-CwnnNqv4.js → create-Cwc3SRWJ.js} +194 -168
  13. package/dist/create-Yvf2gStM.js +19 -0
  14. package/dist/doctor-C9ldpPFC.js +83 -0
  15. package/dist/{drivers-6RMOPIdn.js → drivers-DNrx4LWA.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28083 -801
  18. package/dist/environment-DF1qKlny.js +58 -0
  19. package/dist/{existing-DHpPn1y6.js → existing-78LWSsqS.js} +12 -6
  20. package/dist/held-Cy8Wl4D1.js +1112 -0
  21. package/dist/held-Ddw1XSsr.js +16 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-BR2LR-EK.js → integrate-DcJhpXy8.js} +277 -253
  24. package/dist/kinds-GFXB3sYu.js +11 -0
  25. package/dist/log-NVhVe_oe.js +62 -0
  26. package/dist/login-B2TsCE2H.js +53 -0
  27. package/dist/login-BoBe8Psl.js +16 -0
  28. package/dist/{login-Bhxgqwtm.js → login-D0lh3_JI.js} +144 -66
  29. package/dist/lookup-D-nmmAbw.js +71 -0
  30. package/dist/migrate-Cfec564E.js +274 -0
  31. package/dist/notification-url-YDbq6FMA.js +100 -0
  32. package/dist/{open-studio-BnVD6tJ9.js → open-Ba2vBl1_.js} +34 -43
  33. package/dist/org-D0g_q3mv.js +35 -0
  34. package/dist/output-Ggzq5_-t.js +122 -0
  35. package/dist/paths-DxSLdpOI.js +29 -0
  36. package/dist/playbook-DIeb7hne.js +53 -0
  37. package/dist/{asc-products-Dvcyef3_.js → products-DH_fK9tY.js} +6 -39
  38. package/dist/promote-COD4fYdz.js +91 -0
  39. package/dist/push-CncywhkQ.js +482 -0
  40. package/dist/push-CtD4FZQV.js +22 -0
  41. package/dist/registry-DSrosOYs.js +10228 -0
  42. package/dist/{reports-DqMs9xNR.js → reports-DdPq4blM.js} +7 -6
  43. package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
  44. package/dist/{run-D-NbZLpj.js → run-C9qg_QlC.js} +16 -22
  45. package/dist/scan-Cv5uOwVY.js +4 -0
  46. package/dist/{scan-BmAW413l.js → scan-DLrsrFS9.js} +48 -37
  47. package/dist/scope-V336uz8j.js +198 -0
  48. package/dist/screenshot-file-0UETadF8.js +16 -0
  49. package/dist/{selection-BGi6GyxC.js → selection-Rdw-ZUoG.js} +94 -51
  50. package/dist/send-BxD9yf6F.js +150 -0
  51. package/dist/{dev-CgGAb5Al.js → server-D0tGG8C4.js} +82 -87
  52. package/dist/server-z1LH94R_.js +22 -0
  53. package/dist/session-1AV_Bs_d.js +6 -0
  54. package/dist/session-CFAmMhem.js +40 -0
  55. package/dist/session-D_nEWKXT.js +768 -0
  56. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  57. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  58. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  59. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  60. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  61. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  62. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  63. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  64. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  65. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  66. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  67. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  68. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  69. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  71. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  72. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  73. package/dist/skills/index.json +37 -0
  74. package/dist/skills/mobile-design/SKILL.md +447 -0
  75. package/dist/skills/mobile-design/references/responsive.md +162 -0
  76. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  77. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  78. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  79. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  80. package/dist/skills/superwall/SKILL.md +82 -9
  81. package/dist/skills/superwall/references/api.md +153 -37
  82. package/dist/skills/superwall/references/apple-setup.md +316 -0
  83. package/dist/skills/superwall/references/asc.md +74 -38
  84. package/dist/skills/superwall/references/data-analytics.md +55 -21
  85. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  86. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  87. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  88. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  89. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  90. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  91. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  96. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  97. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  98. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  99. package/dist/skills/superwall-editor/SKILL.md +61 -0
  100. package/dist/skills/superwall-editor/references/cli.md +135 -0
  101. package/dist/skills/superwall-editor/references/design.md +51 -0
  102. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  103. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  104. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  105. package/dist/skills/superwall-framework/SKILL.md +78 -28
  106. package/dist/skills/superwall-framework/references/cli.md +58 -28
  107. package/dist/skills/superwall-framework/references/examples.md +4 -3
  108. package/dist/skills/superwall-framework/references/layout.md +30 -8
  109. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  110. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  111. package/dist/skills/wwdc/SKILL.md +22 -0
  112. package/dist/skills/wwdc/references/docs.md +52 -0
  113. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  114. package/dist/{skills-AxAf7bDB.js → skills-BvFOa4y6.js} +99 -122
  115. package/dist/skills-DMG4bpKk.js +14 -0
  116. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  117. package/dist/spinner-CneRK5rk.js +294 -0
  118. package/dist/storage-DYvmIOHa.d.ts +16 -0
  119. package/dist/storage-s2Dnz-yl.js +31 -0
  120. package/dist/storekit-DafAnGkM.js +16 -0
  121. package/dist/storekit-yY_kS2iR.js +47 -0
  122. package/dist/telemetry-DtG92m5O.js +56 -0
  123. package/dist/theme-DUsCh-Vd.js +25 -0
  124. package/dist/timing-BVxPrYq3.js +5 -0
  125. package/dist/{token-BGAVPSQc.js → token-DzRh7dI1.js} +6 -38
  126. package/dist/tools.d.ts +96 -0
  127. package/dist/tools.js +11178 -0
  128. package/dist/ui-D_qf3Gvw.js +53 -0
  129. package/dist/upgrade-Bt4Ouw1y.js +117 -0
  130. package/dist/upgrade-Cqy5orjb.js +7 -0
  131. package/package.json +10 -5
  132. package/dist/api-Dv3LyZ5m.js +0 -151
  133. package/dist/api-output-aJNw7Syy.js +0 -20
  134. package/dist/app-mJC5NDtW.js +0 -189
  135. package/dist/asa-D6H7Pjae.js +0 -1194
  136. package/dist/asc-xCin0akG.js +0 -539
  137. package/dist/auth-ZlLL-Gko.js +0 -139
  138. package/dist/billing-C8kBge_S.js +0 -80
  139. package/dist/command-3fGYyC8r.js +0 -301
  140. package/dist/dev-Dx99K183.js +0 -22
  141. package/dist/doctor-CyUvut31.js +0 -88
  142. package/dist/feedback-RKyGuQ8_.js +0 -152
  143. package/dist/hosted-BeGVAntr.js +0 -32
  144. package/dist/migrate-C-4ISELN.js +0 -284
  145. package/dist/org-CQduIOic.js +0 -40
  146. package/dist/output-C-4UKMot.js +0 -136
  147. package/dist/params-l3CrvRtR.js +0 -51
  148. package/dist/pipeline-CHX0Syre.js +0 -977
  149. package/dist/print-skill-BiZLdCKv.js +0 -74
  150. package/dist/promote-Pgpz-3xl.js +0 -88
  151. package/dist/publish-BPeuc3lq.js +0 -35
  152. package/dist/push-DcSQ4odB.js +0 -35
  153. package/dist/query-CWLaZkdm.js +0 -53
  154. package/dist/resource-jwASPCrw.js +0 -483
  155. package/dist/skills-FK5aDuNV.js +0 -64
  156. package/dist/spinner-DFctF_Jw.js +0 -18
  157. package/dist/storekit-CC4gnTI6.js +0 -29
  158. package/dist/telemetry-Ch9cCTI-.js +0 -169
  159. package/dist/ui-4gLyfrgl.js +0 -27737
  160. package/dist/update-DIXbL-H9.js +0 -59
  161. package/dist/upgrade-De7JMI1g.js +0 -72
  162. /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
@@ -1,74 +0,0 @@
1
- import "./output-C-4UKMot.js";
2
- import { i as track, r as setTelemetryTags } from "./telemetry-Ch9cCTI-.js";
3
- import "./ui-4gLyfrgl.js";
4
- import { i as loadBundledSkill } from "./skills-AxAf7bDB.js";
5
- import "./spawn-DSoTXy_j.js";
6
- import { t as scanProject } from "./scan-BmAW413l.js";
7
- import { n as FRAMEWORK_REF } from "./actions-H7f6knyY.js";
8
- import { t as detectBilling } from "./billing-C8kBge_S.js";
9
- import { resolve } from "node:path";
10
-
11
- //#region src/commands/workflow/print-skill.ts
12
- /**
13
- * `<command> --skill` - print the raw playbook (skill + this project's
14
- * framework/provider reference) for an agent to follow directly, instead of
15
- * the CLI orchestrating the run. Stdout must stay clean markdown.
16
- */
17
- function runPrintSkill(actionId) {
18
- return async (argv) => {
19
- const app = (await scanProject(resolve(argv.installDir ?? process.cwd())).catch(() => null))?.apps[0];
20
- if (app) setTelemetryTags({ framework: app.framework.integration });
21
- const frameworkRef = app ? FRAMEWORK_REF[app.framework.integration] : void 0;
22
- if (actionId === "integrate") {
23
- const parts = [
24
- loadBundledSkill("superwall-integrate", frameworkRef),
25
- loadBundledSkill("superwall-placements", ["strategy", frameworkRef]),
26
- loadBundledSkill("superwall-dashboard")
27
- ].filter(Boolean);
28
- if (!parts.length) {
29
- process.stderr.write("No bundled skills found for integrate.\n");
30
- process.exitCode = 1;
31
- return;
32
- }
33
- process.stdout.write("# Set up Superwall - full integration\n\nDo all three phases in order:\n\n---\n\n" + parts.join("\n\n---\n\n") + "\n");
34
- track("skill printed", { workflow: actionId });
35
- return;
36
- }
37
- let skill;
38
- let reference;
39
- let withStrategy = false;
40
- switch (actionId) {
41
- case "review":
42
- case "review-fix":
43
- skill = "superwall-review";
44
- reference = frameworkRef;
45
- break;
46
- case "placements-review":
47
- case "placements-implement":
48
- skill = "superwall-placements";
49
- reference = frameworkRef;
50
- withStrategy = true;
51
- break;
52
- case "dashboard-setup":
53
- skill = "superwall-dashboard";
54
- break;
55
- case "migrate": {
56
- skill = "superwall-migrate";
57
- const billing = app ? detectBilling(app) : null;
58
- reference = billing?.revenueCat ? "revenuecat" : billing?.adapty ? "adapty" : billing?.qonversion ? "qonversion" : void 0;
59
- break;
60
- }
61
- }
62
- const body = loadBundledSkill(skill, withStrategy ? ["strategy", reference] : reference);
63
- if (!body) {
64
- process.stderr.write(`No bundled skill found for ${actionId}.\n`);
65
- process.exitCode = 1;
66
- return;
67
- }
68
- process.stdout.write(body + "\n");
69
- track("skill printed", { workflow: actionId });
70
- };
71
- }
72
-
73
- //#endregion
74
- export { runPrintSkill };
@@ -1,88 +0,0 @@
1
- import { y as VERSION } from "./output-C-4UKMot.js";
2
- import "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import "./token-BGAVPSQc.js";
5
- import { r as ApiError, t as defineCommand } from "./command-3fGYyC8r.js";
6
- import { n as ui } from "./ui-4gLyfrgl.js";
7
- import "./skills-AxAf7bDB.js";
8
- import "./spawn-DSoTXy_j.js";
9
- import "./login-Bhxgqwtm.js";
10
- import "./scan-BmAW413l.js";
11
- import "./hosted-BeGVAntr.js";
12
- import "./spinner-DFctF_Jw.js";
13
- import { S as promotePaywallVersion, v as livePaywallVersion } from "./resources-Bf9O1JNM.js";
14
- import { _ as collectProjectDeclarations, h as transition, k as loadFramework, r as projectDir, s as selectSurfaces } from "./selection-BGi6GyxC.js";
15
- import "./org-CQduIOic.js";
16
- import "./bind-BIzaGq8K.js";
17
- import { _ as requireApi, d as parsePlatformFlags, f as planTargets, h as resolveBinding, i as pickApplicationOption, m as wantedPlatforms, p as targetLabel, r as timed, t as group, x as resolveApps } from "./pipeline-CHX0Syre.js";
18
- import "./actions-H7f6knyY.js";
19
- import "./app-mJC5NDtW.js";
20
- import pc from "picocolors";
21
-
22
- //#region src/commands/paywalls/promote.ts
23
- const runPromote = defineCommand({
24
- name: "promote",
25
- output: "human",
26
- async run(context) {
27
- const api = await requireApi(context.interactive);
28
- const dir = projectDir(context);
29
- const framework = await loadFramework(dir);
30
- const project = framework.discoverProject(dir);
31
- const surfaces = selectSurfaces(project, context.argv.id);
32
- const declared = (await collectProjectDeclarations(framework, project.root)).platforms;
33
- const requested = context.argv.version;
34
- if (requested !== void 0 && !Number.isInteger(requested)) throw new Error("--version takes a pushed version number, e.g. --version 3.");
35
- const version = typeof requested === "number" ? requested : void 0;
36
- if (requested !== void 0 && surfaces.length > 1) throw new Error("--version targets one surface — combine it with a single --id <id>.");
37
- ui.intro(`Superwall ${pc.dim(`v${VERSION}`)}`);
38
- const apps = await resolveApps({
39
- api,
40
- superwallDir: project.superwallDir,
41
- wanted: wantedPlatforms(surfaces, declared),
42
- pickApplication: context.interactive ? pickApplicationOption : void 0
43
- });
44
- const multi = Object.keys(apps).length > 1;
45
- const targets = planTargets({
46
- surfaces,
47
- declared,
48
- apps,
49
- only: parsePlatformFlags(context.argv.platform)
50
- });
51
- if (requested !== void 0 && targets.length > 1) throw new Error(`--version targets one paywall — \`${surfaces[0]?.id}\` is pushed to ${targets.map((target) => target.platform).join(", ")}; add --platform <platform> to pick one.`);
52
- let promoted = 0;
53
- let skipped = 0;
54
- for (const target of targets) {
55
- let changed = true;
56
- await group(context, targetLabel(target, multi), async (note) => {
57
- note("Finding on Superwall");
58
- const binding = await resolveBinding({
59
- api,
60
- superwallDir: project.superwallDir,
61
- surface: target.surface,
62
- app: {
63
- platform: target.platform,
64
- applicationId: target.applicationId
65
- },
66
- surfaces: project.surfaces,
67
- create: false
68
- });
69
- note("Promoting");
70
- const before = await livePaywallVersion(api, binding.paywallId);
71
- const promo = await timed(() => promotePaywallVersion(api, binding.paywallId, { version }).catch((error) => {
72
- if (error instanceof ApiError && error.status === 404 && version !== void 0) error.hint = "Run `superwall promote` without --version to promote the latest.";
73
- throw error;
74
- }));
75
- changed = before !== promo.value.version;
76
- return [`${transition(before, promo.value.version)} ${promo.took}`];
77
- });
78
- if (changed) promoted += 1;
79
- else skipped += 1;
80
- }
81
- const noun = (n) => n === 1 ? "paywall" : "paywalls";
82
- const unchanged = skipped > 0 ? ` · ${pc.dim(`${skipped} already live`)}` : "";
83
- ui.outro(promoted > 0 ? `${pc.green(`${promoted} ${noun(promoted)} live`)}${unchanged}.` : `Nothing to do · ${skipped} already live.`);
84
- }
85
- });
86
-
87
- //#endregion
88
- export { runPromote };
@@ -1,35 +0,0 @@
1
- import "./output-C-4UKMot.js";
2
- import "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import "./token-BGAVPSQc.js";
5
- import { t as defineCommand } from "./command-3fGYyC8r.js";
6
- import "./ui-4gLyfrgl.js";
7
- import "./skills-AxAf7bDB.js";
8
- import "./spawn-DSoTXy_j.js";
9
- import "./login-Bhxgqwtm.js";
10
- import "./scan-BmAW413l.js";
11
- import "./hosted-BeGVAntr.js";
12
- import "./spinner-DFctF_Jw.js";
13
- import "./resources-Bf9O1JNM.js";
14
- import "./selection-BGi6GyxC.js";
15
- import "./org-CQduIOic.js";
16
- import "./bind-BIzaGq8K.js";
17
- import { _ as requireApi, n as runPushPipeline } from "./pipeline-CHX0Syre.js";
18
- import "./actions-H7f6knyY.js";
19
- import "./app-mJC5NDtW.js";
20
-
21
- //#region src/commands/paywalls/publish.ts
22
- const runPublish = defineCommand({
23
- name: "publish",
24
- output: "human",
25
- async run(context) {
26
- const api = await requireApi(context.interactive);
27
- await runPushPipeline({
28
- ...context,
29
- api
30
- }, { promote: true });
31
- }
32
- });
33
-
34
- //#endregion
35
- export { runPublish };
@@ -1,35 +0,0 @@
1
- import "./output-C-4UKMot.js";
2
- import "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import "./token-BGAVPSQc.js";
5
- import { t as defineCommand } from "./command-3fGYyC8r.js";
6
- import "./ui-4gLyfrgl.js";
7
- import "./skills-AxAf7bDB.js";
8
- import "./spawn-DSoTXy_j.js";
9
- import "./login-Bhxgqwtm.js";
10
- import "./scan-BmAW413l.js";
11
- import "./hosted-BeGVAntr.js";
12
- import "./spinner-DFctF_Jw.js";
13
- import "./resources-Bf9O1JNM.js";
14
- import "./selection-BGi6GyxC.js";
15
- import "./org-CQduIOic.js";
16
- import "./bind-BIzaGq8K.js";
17
- import { _ as requireApi, n as runPushPipeline } from "./pipeline-CHX0Syre.js";
18
- import "./actions-H7f6knyY.js";
19
- import "./app-mJC5NDtW.js";
20
-
21
- //#region src/commands/paywalls/push.ts
22
- const runPush = defineCommand({
23
- name: "push",
24
- output: "human",
25
- async run(context) {
26
- const api = await requireApi(context.interactive);
27
- await runPushPipeline({
28
- ...context,
29
- api
30
- }, { promote: false });
31
- }
32
- });
33
-
34
- //#endregion
35
- export { runPush };
@@ -1,53 +0,0 @@
1
- import "./output-C-4UKMot.js";
2
- import "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import "./token-BGAVPSQc.js";
5
- import { t as defineCommand } from "./command-3fGYyC8r.js";
6
- import "./ui-4gLyfrgl.js";
7
- import "./spinner-DFctF_Jw.js";
8
- import "./resources-Bf9O1JNM.js";
9
- import { t as requireOrg } from "./org-CQduIOic.js";
10
- import { t as apiCall } from "./api-output-aJNw7Syy.js";
11
- import { readFileSync } from "node:fs";
12
-
13
- //#region src/commands/platform/query.ts
14
- const runQuery = defineCommand({
15
- name: "query",
16
- auth: "required",
17
- interaction: "none",
18
- output: "both",
19
- async run(ctx) {
20
- const { id: organizationId } = await requireOrg(ctx.api, ctx.interactive);
21
- const sql = readSql(ctx);
22
- const params = ctx.json ? "?default_format=JSON" : "";
23
- if (ctx.json && /\bFORMAT\s+[A-Za-z0-9_]+\s*;?\s*$/i.test(sql)) throw new Error("Remove the FORMAT clause when using --json; the CLI requests ClickHouse JSON for you.");
24
- if (!ctx.json) ctx.ui.intro("Superwall query");
25
- const output = await apiCall(ctx, "Querying ClickHouse", () => ctx.api.postText(`/v2/organizations/${encodeURIComponent(organizationId)}/query${params}`, sql));
26
- if (ctx.json) {
27
- let parsed;
28
- try {
29
- parsed = JSON.parse(output);
30
- } catch {
31
- throw new Error("ClickHouse did not return valid JSON. Remove any FORMAT clause and try again.");
32
- }
33
- ctx.output.data(parsed);
34
- return;
35
- }
36
- ctx.output.text(output.trimEnd());
37
- }
38
- });
39
- function readSql(ctx) {
40
- const inline = ctx.argv.sql;
41
- const file = ctx.argv.file;
42
- if (inline && file) throw new Error("Pass SQL as an argument, with --file, or on stdin - choose one.");
43
- const value = inline ?? (file ? readFileSync(file, "utf8") : readStdin());
44
- if (!value?.trim()) throw new Error("Provide SQL: superwall query \"SELECT ...\", --file <query.sql>, or stdin.");
45
- return value.trim();
46
- }
47
- function readStdin() {
48
- if (process.stdin.isTTY) return "";
49
- return readFileSync(0, "utf8");
50
- }
51
-
52
- //#endregion
53
- export { runQuery };