@superwall/cli 1.6.0 → 1.6.2

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 (67) hide show
  1. package/README.md +6 -0
  2. package/dist/{actions-Dt35nIi8.js → actions-H7f6knyY.js} +2 -2
  3. package/dist/{api-BOR-uXZe.js → api-Dv3LyZ5m.js} +7 -7
  4. package/dist/{app-BU27SLPX.js → app-mJC5NDtW.js} +7 -7
  5. package/dist/{asa-2ykGnjaV.js → asa-D6H7Pjae.js} +8 -8
  6. package/dist/{asc-r3xmFT0L.js → asc-xCin0akG.js} +9 -9
  7. package/dist/{auth-BWZfguI8.js → auth-ZlLL-Gko.js} +8 -8
  8. package/dist/auth.js +2 -2
  9. package/dist/{billing-BsQgXXYh.js → billing-C8kBge_S.js} +1 -1
  10. package/dist/{bind-BSTAinn6.js → bind-BIzaGq8K.js} +2 -2
  11. package/dist/build-B7BS1rF2.js +87 -0
  12. package/dist/{command-DMoMn7uc.js → command-3fGYyC8r.js} +4 -4
  13. package/dist/{create-CSo6XjSm.js → create-CwnnNqv4.js} +20 -19
  14. package/dist/{dev-CuXa3J4Z.js → dev-CgGAb5Al.js} +9 -6
  15. package/dist/dev-Dx99K183.js +22 -0
  16. package/dist/{doctor-DXJaDqsx.js → doctor-CyUvut31.js} +9 -9
  17. package/dist/{drivers-Cr252DOJ.js → drivers-6RMOPIdn.js} +2 -2
  18. package/dist/entry.js +99 -32
  19. package/dist/{existing-Ckx_g7Be.js → existing-DHpPn1y6.js} +2 -2
  20. package/dist/feedback-RKyGuQ8_.js +152 -0
  21. package/dist/{hosted-Cjekn8oJ.js → hosted-BeGVAntr.js} +2 -2
  22. package/dist/{integrate-DVqhvPVq.js → integrate-BR2LR-EK.js} +20 -20
  23. package/dist/{login-Bjj8QvIN.js → login-Bhxgqwtm.js} +3 -3
  24. package/dist/{migrate-qmvOtp3l.js → migrate-C-4ISELN.js} +22 -21
  25. package/dist/{open-studio-CpHqjovS.js → open-studio-BnVD6tJ9.js} +16 -13
  26. package/dist/{output-CiELrN8w.js → output-C-4UKMot.js} +1 -1
  27. package/dist/{pipeline-DSCHL9KA.js → pipeline-CHX0Syre.js} +9 -494
  28. package/dist/{print-skill-CaHRJ8xW.js → print-skill-BiZLdCKv.js} +6 -6
  29. package/dist/{promote-UMTh8Q33.js → promote-Pgpz-3xl.js} +15 -14
  30. package/dist/publish-BPeuc3lq.js +35 -0
  31. package/dist/push-DcSQ4odB.js +35 -0
  32. package/dist/{query-CnSsDZ7Q.js → query-CWLaZkdm.js} +7 -7
  33. package/dist/{resource-5bgyyL9B.js → resource-jwASPCrw.js} +11 -11
  34. package/dist/{run-BVeZWbXx.js → run-D-NbZLpj.js} +2 -2
  35. package/dist/{scan-CAObNRgc.js → scan-BmAW413l.js} +1 -1
  36. package/dist/selection-BGi6GyxC.js +496 -0
  37. package/dist/skills/superwall/SKILL.md +70 -39
  38. package/dist/skills/superwall/references/api.md +14 -21
  39. package/dist/skills/superwall/references/asa.md +6 -0
  40. package/dist/skills/superwall/references/asc.md +7 -8
  41. package/dist/skills/superwall/references/data-analytics.md +7 -4
  42. package/dist/skills/superwall/references/docs.md +2 -2
  43. package/dist/skills/superwall/references/sdk-integration.md +3 -4
  44. package/dist/skills/superwall/workflows/dashboard/setup.md +23 -24
  45. package/dist/skills/superwall/workflows/integrate/expo.md +14 -11
  46. package/dist/skills/superwall/workflows/integrate/react-native.md +4 -3
  47. package/dist/skills/superwall-framework/SKILL.md +109 -36
  48. package/dist/skills/superwall-framework/references/cli.md +45 -5
  49. package/dist/skills/superwall-framework/references/mobile-design.md +60 -181
  50. package/dist/{skills-grTDuHlc.js → skills-AxAf7bDB.js} +77 -8
  51. package/dist/{skills-Cu41i-Az.js → skills-FK5aDuNV.js} +6 -6
  52. package/dist/{telemetry-BuCbmoux.js → telemetry-Ch9cCTI-.js} +1 -1
  53. package/dist/{token-mju3Q-vc.js → token-BGAVPSQc.js} +1 -1
  54. package/dist/{update-DnGfpCD7.js → update-DIXbL-H9.js} +2 -2
  55. package/dist/{upgrade-PMoj3yqJ.js → upgrade-De7JMI1g.js} +5 -5
  56. package/package.json +2 -2
  57. package/dist/dev-B0MF6z3L.js +0 -21
  58. package/dist/feedback-Dt5yebMS.js +0 -73
  59. package/dist/publish-DWX8S9yZ.js +0 -34
  60. package/dist/push-Dox4_5Dq.js +0 -34
  61. package/dist/skills/superwall-framework/references/responsive.md +0 -162
  62. /package/dist/{api-output-CEhN-U_N.js → api-output-aJNw7Syy.js} +0 -0
  63. /package/dist/{asc-products-1e1DoGeL.js → asc-products-Dvcyef3_.js} +0 -0
  64. /package/dist/{org-CV8c849b.js → org-CQduIOic.js} +0 -0
  65. /package/dist/{params-BxgTuCzr.js → params-l3CrvRtR.js} +0 -0
  66. /package/dist/{reports-C0xHCLnt.js → reports-DqMs9xNR.js} +0 -0
  67. /package/dist/{storekit-Dlpbq5Wv.js → storekit-CC4gnTI6.js} +0 -0
@@ -1,178 +1,22 @@
1
- import { b as apiKeyFromEnv, o as API_HOST, p as ENV_API_KEY, s as ASSET_HOST, y as VERSION } from "./output-CiELrN8w.js";
2
- import { i as loadSession } from "./token-mju3Q-vc.js";
3
- import { i as createSuperwallApi, r as ApiError } from "./command-DMoMn7uc.js";
1
+ import { b as apiKeyFromEnv, o as API_HOST, p as ENV_API_KEY, y as VERSION } from "./output-C-4UKMot.js";
2
+ import { i as loadSession } from "./token-BGAVPSQc.js";
3
+ import { i as createSuperwallApi, r as ApiError } from "./command-3fGYyC8r.js";
4
4
  import { n as ui } from "./ui-4gLyfrgl.js";
5
- import { C as pushPaywallAssets, D as versionProducts, S as promotePaywallVersion, _ as livePaywall, a as createHeadlessPaywall, b as platformLabel, d as linkSourceCommit, f as listAppPaywalls, h as listProjects, p as listApplications, w as pushPaywallVersion, y as mintSourceAccess } from "./resources-Bf9O1JNM.js";
6
- import { r as performLoginWithUi } from "./app-BU27SLPX.js";
7
- import { createRequire } from "node:module";
5
+ import { D as versionProducts, S as promotePaywallVersion, _ as livePaywall, a as createHeadlessPaywall, b as platformLabel, d as linkSourceCommit, f as listAppPaywalls, h as listProjects, p as listApplications, w as pushPaywallVersion, y as mintSourceAccess } from "./resources-Bf9O1JNM.js";
6
+ import { A as assetBaseUrl, C as writeApp, D as writeSnapshot, M as syncAssets, O as frameworkVersion, S as removeBinding, T as writeBindings, _ as collectProjectDeclarations, a as requireClean, c as BIND_VERB, d as pendingPromoteWarning, f as pushedLine, g as weight, h as transition, j as requireAssets, k as loadFramework, m as took, o as requireProject, p as resolveNote, r as projectDir, s as selectSurfaces, t as needsWork, u as kb, v as writeProjectTypes, w as writeBinding, x as readLock, y as describeBindings } from "./selection-BGi6GyxC.js";
7
+ import { r as performLoginWithUi } from "./app-mJC5NDtW.js";
8
8
  import pc from "picocolors";
9
9
  import * as path from "node:path";
10
- import { join, resolve } from "node:path";
10
+ import { resolve } from "node:path";
11
11
  import * as os$1 from "node:os";
12
12
  import { cpus } from "node:os";
13
13
  import { promisify } from "node:util";
14
14
  import * as fs from "node:fs";
15
- import { globSync, readFileSync, statSync } from "node:fs";
16
- import { pathToFileURL } from "node:url";
15
+ import { globSync, statSync } from "node:fs";
17
16
  import { execFile } from "node:child_process";
18
17
  import fg from "fast-glob";
19
18
  import { productVariables } from "@superwall/studio/products";
20
19
 
21
- //#region src/core/paywalls/project/lock.ts
22
- const isScreenOrigin = (origin) => "path" in origin;
23
- const isFileName = (value) => typeof value === "string" && value !== "" && !/[\\/]/.test(value) && !value.startsWith(".");
24
- const SCREEN_FRAMEWORKS = new Set([
25
- "swiftui",
26
- "uikit",
27
- "compose",
28
- "android-views",
29
- "react-native",
30
- "flutter"
31
- ]);
32
- const readOrigin = (candidate) => {
33
- if (typeof candidate.paywallId === "string" && typeof candidate.url === "string") return {
34
- paywallId: candidate.paywallId,
35
- url: candidate.url
36
- };
37
- if (typeof candidate.path === "string" && typeof candidate.framework === "string" && SCREEN_FRAMEWORKS.has(candidate.framework)) {
38
- const framework = candidate.framework;
39
- return isFileName(candidate.screenshot) ? {
40
- path: candidate.path,
41
- framework,
42
- screenshot: candidate.screenshot
43
- } : {
44
- path: candidate.path,
45
- framework
46
- };
47
- }
48
- };
49
- const EXPLAINER = "Commit this file: it binds each paywall to its dashboard entry, per app, so every machine and CI push to the same place. Managed by the Superwall CLI.";
50
- const emptyLock = () => ({
51
- version: 1,
52
- apps: {},
53
- paywalls: {},
54
- funnels: {}
55
- });
56
- const originKey = (kind, surfaceId) => `${kind}/${surfaceId}`;
57
- const readOrigins = (value) => {
58
- if (!isRecord(value)) return void 0;
59
- const origins = {};
60
- for (const [key, candidate] of Object.entries(value)) {
61
- if (!isRecord(candidate)) continue;
62
- const origin = readOrigin(candidate);
63
- if (origin) origins[key] = origin;
64
- }
65
- return Object.keys(origins).length > 0 ? origins : void 0;
66
- };
67
- const lockPath = (superwallDir) => path.join(superwallDir, "superwall.lock");
68
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
69
- const readBinding = (value) => {
70
- if (!isRecord(value) || typeof value.paywallId !== "string") return void 0;
71
- return typeof value.snapshot === "string" ? {
72
- paywallId: value.paywallId,
73
- snapshot: value.snapshot
74
- } : { paywallId: value.paywallId };
75
- };
76
- const readSection = (value) => {
77
- const section = {};
78
- if (!isRecord(value)) return section;
79
- for (const [surfaceId, entry] of Object.entries(value)) {
80
- if (!isRecord(entry)) continue;
81
- const bindings = {};
82
- for (const [platform, candidate] of Object.entries(entry)) {
83
- const binding = readBinding(candidate);
84
- if (binding) bindings[platform] = binding;
85
- }
86
- if (Object.keys(bindings).length > 0) section[surfaceId] = bindings;
87
- }
88
- return section;
89
- };
90
- function readLock(superwallDir) {
91
- const file = lockPath(superwallDir);
92
- if (!fs.existsSync(file)) return emptyLock();
93
- try {
94
- const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
95
- if (!isRecord(parsed) || parsed.version !== 1) return emptyLock();
96
- const lock = emptyLock();
97
- if (isRecord(parsed.apps)) {
98
- for (const [platform, id] of Object.entries(parsed.apps)) if (typeof id === "string") lock.apps[platform] = id;
99
- }
100
- lock.paywalls = readSection(parsed.paywalls);
101
- lock.funnels = readSection(parsed.funnels);
102
- const origins = readOrigins(parsed.origins);
103
- if (origins) lock.origins = origins;
104
- return lock;
105
- } catch {}
106
- return emptyLock();
107
- }
108
- function writeLock(superwallDir, lock) {
109
- const annotated = {
110
- "//": EXPLAINER,
111
- version: lock.version,
112
- apps: lock.apps,
113
- paywalls: lock.paywalls,
114
- funnels: lock.funnels,
115
- ...lock.origins && Object.keys(lock.origins).length > 0 ? { origins: lock.origins } : {}
116
- };
117
- fs.writeFileSync(lockPath(superwallDir), `${JSON.stringify(annotated, null, 2)}\n`);
118
- }
119
- function writeOrigin(superwallDir, kind, surfaceId, origin) {
120
- const lock = readLock(superwallDir);
121
- lock.origins = {
122
- ...lock.origins,
123
- [originKey(kind, surfaceId)]: origin
124
- };
125
- writeLock(superwallDir, lock);
126
- }
127
- const sectionOf = (lock, kind) => kind === "paywall" ? lock.paywalls : lock.funnels;
128
- function writeApp(superwallDir, platform, applicationId) {
129
- const lock = readLock(superwallDir);
130
- lock.apps[platform] = applicationId;
131
- writeLock(superwallDir, lock);
132
- }
133
- function writeBinding(superwallDir, kind, surfaceId, platform, binding) {
134
- const lock = readLock(superwallDir);
135
- const section = sectionOf(lock, kind);
136
- section[surfaceId] = {
137
- ...section[surfaceId],
138
- [platform]: binding
139
- };
140
- writeLock(superwallDir, lock);
141
- }
142
- function writeBindings(superwallDir, kind, surfaceId, bindings) {
143
- const lock = readLock(superwallDir);
144
- sectionOf(lock, kind)[surfaceId] = { ...bindings };
145
- writeLock(superwallDir, lock);
146
- }
147
- function writeSnapshot(superwallDir, kind, surfaceId, platform, snapshot) {
148
- const lock = readLock(superwallDir);
149
- const section = sectionOf(lock, kind);
150
- const binding = section[surfaceId]?.[platform];
151
- if (!binding || binding.snapshot === snapshot) return;
152
- section[surfaceId] = {
153
- ...section[surfaceId],
154
- [platform]: {
155
- ...binding,
156
- snapshot
157
- }
158
- };
159
- writeLock(superwallDir, lock);
160
- }
161
- function removeBinding(superwallDir, kind, surfaceId) {
162
- const lock = readLock(superwallDir);
163
- const section = sectionOf(lock, kind);
164
- if (!(surfaceId in section)) return false;
165
- delete section[surfaceId];
166
- writeLock(superwallDir, lock);
167
- return true;
168
- }
169
- const describeBindings = (bindings) => {
170
- const entries = Object.entries(bindings);
171
- if (entries.length === 1 && entries[0] !== void 0) return `paywall ${entries[0][1].paywallId}`;
172
- return `paywalls ${entries.map(([platform, binding]) => `${binding.paywallId} (${platform})`).join(", ")}`;
173
- };
174
-
175
- //#endregion
176
20
  //#region src/core/paywalls/binding/apps.ts
177
21
  const PLATFORMS = [
178
22
  "ios",
@@ -304,219 +148,6 @@ async function requireApi(interactive) {
304
148
  return createSuperwallApi(signedIn);
305
149
  }
306
150
 
307
- //#endregion
308
- //#region src/core/paywalls/project/types.ts
309
- const TYPES_FILE = "superwall.d.ts";
310
- const SUPERSEDED = ["superwall-env.d.ts", "superwall-routes.d.ts"];
311
- const HEADER = `// Generated by the Superwall CLI. Commit it; don't edit it, and don't delete it.
312
- // It is what makes \`import hero from "./assets/hero.jpg"\` typecheck and what
313
- // makes router.push("...") autocomplete and reject typos. \`superwall dev\`
314
- // rewrites it whenever your app/ directories change.
315
-
316
- /// <reference types="superwall/assets" />
317
- `;
318
- const routeBlock = (names) => [
319
- "declare module \"superwall/navigation\" {",
320
- " interface SuperwallRoutes {",
321
- ...names.map((name) => ` ${JSON.stringify(name)}: true;`),
322
- " }",
323
- "}",
324
- "",
325
- "export type SuperwallRouteName = keyof import(\"superwall/navigation\").SuperwallRoutes;"
326
- ].join("\n");
327
- const isStripeIdentifier = (identifier) => /^(test|live):price_[^:]+/.test(identifier);
328
- const productBlock = (references, stripe) => [
329
- "declare module \"superwall/hooks\" {",
330
- " interface SuperwallProducts {",
331
- ...references.map((name) => ` ${JSON.stringify(name)}: true;`),
332
- " }",
333
- "",
334
- " interface SuperwallStripeProducts {",
335
- ...stripe.map((name) => ` ${JSON.stringify(name)}: true;`),
336
- " }",
337
- "}"
338
- ].join("\n");
339
- const productIdsOf = (surface) => surface.productIds ?? Object.fromEntries(Object.entries(surface.products).map(([reference, id]) => [reference, [id]]));
340
- const declaredPlatforms = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : void 0;
341
- async function collectProjectDeclarations(framework, root) {
342
- const declarations = {
343
- products: {},
344
- platforms: {}
345
- };
346
- if (!framework.studioProject) return declarations;
347
- try {
348
- const payload = await framework.studioProject(root);
349
- for (const surface of payload.surfaces) {
350
- for (const [reference, ids] of Object.entries(productIdsOf(surface))) declarations.products[reference] = [...new Set([...declarations.products[reference] ?? [], ...ids])];
351
- if (typeof surface.kind === "string" && typeof surface.id === "string") declarations.platforms[`${surface.kind}/${surface.id}`] = declaredPlatforms(surface.platforms);
352
- }
353
- return declarations;
354
- } catch {
355
- return declarations;
356
- }
357
- }
358
- function projectTypes(project, products = {}) {
359
- const names = /* @__PURE__ */ new Set();
360
- for (const surface of project.surfaces) for (const route of surface.routes) names.add(route.name);
361
- const sorted = [...names].sort();
362
- const sortedProducts = Object.keys(products).sort();
363
- const sortedStripe = sortedProducts.filter((name) => (products[name] ?? []).some((identifier) => isStripeIdentifier(identifier)));
364
- const blocks = [sorted.length > 0 ? routeBlock(sorted) : "", sortedProducts.length > 0 ? productBlock(sortedProducts, sortedStripe) : ""].filter(Boolean);
365
- return blocks.length === 0 ? `${HEADER}\nexport {};\n` : `${HEADER}\n${blocks.join("\n\n")}\n`;
366
- }
367
- function writeProjectTypes(project, products = {}) {
368
- const file = path.join(project.superwallDir, TYPES_FILE);
369
- const next = projectTypes(project, products);
370
- try {
371
- if (!fs.existsSync(file) || fs.readFileSync(file, "utf8") !== next) fs.writeFileSync(file, next);
372
- } catch {
373
- return;
374
- }
375
- for (const name of SUPERSEDED) {
376
- const stale = path.join(project.superwallDir, name);
377
- try {
378
- if (fs.readFileSync(stale, "utf8").includes("Superwall CLI")) fs.rmSync(stale);
379
- } catch {
380
- continue;
381
- }
382
- }
383
- }
384
-
385
- //#endregion
386
- //#region src/core/paywalls/project/framework.ts
387
- var FrameworkNotFoundError = class extends Error {
388
- constructor(dir) {
389
- 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.`);
390
- }
391
- };
392
- async function importSubpath(packageDir, subpath) {
393
- return import(pathToFileURL(createRequire(join(packageDir, "package.json")).resolve(subpath)).href);
394
- }
395
- function fn(mod, name, subpath) {
396
- if (typeof mod !== "object" || mod === null) throw new Error(`superwall ${subpath} did not load as a module`);
397
- const candidate = mod[name];
398
- if (typeof candidate !== "function") throw new Error(`This project's superwall version does not export ${name} from ${subpath} — update the project's superwall dependency.`);
399
- return candidate;
400
- }
401
- function resolveFrameworkDir(cwd) {
402
- for (const anchor of [join(cwd, "superwall", "package.json"), join(cwd, "package.json")]) try {
403
- return join(createRequire(anchor).resolve("superwall/package.json"), "..");
404
- } catch {
405
- continue;
406
- }
407
- throw new FrameworkNotFoundError(cwd);
408
- }
409
- function frameworkVersion(cwd) {
410
- try {
411
- const parsed = JSON.parse(readFileSync(join(resolveFrameworkDir(cwd), "package.json"), "utf8"));
412
- if (typeof parsed === "object" && parsed !== null) {
413
- const version = parsed.version;
414
- if (typeof version === "string" && version !== "") return version;
415
- }
416
- } catch {
417
- return "unknown";
418
- }
419
- return "unknown";
420
- }
421
- async function loadFramework(cwd) {
422
- const dir = resolveFrameworkDir(cwd);
423
- const [discover, build, preview] = await Promise.all([
424
- importSubpath(dir, "superwall/discover"),
425
- importSubpath(dir, "superwall/build"),
426
- importSubpath(dir, "superwall/preview")
427
- ]);
428
- const studioProject = typeof preview === "object" && preview !== null && typeof preview.buildStudioProject === "function" ? preview.buildStudioProject : void 0;
429
- return {
430
- discoverProject: fn(discover, "discoverProject", "superwall/discover"),
431
- buildSnapshot: fn(build, "buildSnapshot", "superwall/build"),
432
- startPreviewServer: fn(preview, "startPreviewServer", "superwall/preview"),
433
- studioProject
434
- };
435
- }
436
-
437
- //#endregion
438
- //#region src/core/paywalls/assets.ts
439
- const assetBaseUrl = (applicationId) => `${ASSET_HOST()}/${applicationId}`;
440
- function requireAssets(built) {
441
- 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.");
442
- return built.assets;
443
- }
444
- var AssetSyncError = class extends Error {};
445
- const assetName = (asset) => asset.path.split(/[\\/]/).pop() || asset.fileName;
446
- function uploadFailure(asset, response) {
447
- const name = assetName(asset);
448
- if (!response) return new AssetSyncError(`Couldn't upload ${name} — the asset store is unreachable. Check your network, then push again.`);
449
- 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.`);
450
- return new AssetSyncError(`Couldn't upload ${name} — the asset store returned HTTP ${response.status}.`);
451
- }
452
- const CACHE_CONTROL = "public, max-age=31536000, immutable";
453
- const UPLOAD_CONCURRENCY = 4;
454
- const pool = async (items, limit, work) => {
455
- const queue = [...items];
456
- const runners = Array.from({ length: Math.min(limit, queue.length) }, async () => {
457
- for (let item = queue.shift(); item !== void 0; item = queue.shift()) await work(item);
458
- });
459
- await Promise.all(runners);
460
- };
461
- async function syncAssets(input) {
462
- const { api, paywallId, assets } = input;
463
- const put = input.put ?? fetch;
464
- const read = input.read ?? ((path$1) => fs.readFileSync(path$1));
465
- const totalBytes = assets.reduce((total, asset) => total + asset.bytes, 0);
466
- if (assets.length === 0) return {
467
- assets: [],
468
- uploaded: 0,
469
- uploadedBytes: 0,
470
- totalBytes: 0
471
- };
472
- const resolved = await pushPaywallAssets(api, paywallId, assets.map((asset) => ({
473
- sha256: asset.sha256,
474
- bytes: asset.bytes,
475
- mime: asset.mime,
476
- file_name: asset.fileName
477
- }))).catch((error) => {
478
- 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.");
479
- throw error;
480
- });
481
- const bySha = new Map(resolved.map((entry) => [entry.sha256, entry]));
482
- const missing = [];
483
- const hosted = /* @__PURE__ */ new Map();
484
- for (const asset of assets) {
485
- const entry = bySha.get(asset.sha256);
486
- if (!entry) throw new AssetSyncError(`Superwall did not return a URL for ${assetName(asset)} — asset sync is incomplete.`);
487
- 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.`);
488
- hosted.set(asset.sha256, entry.url);
489
- if (entry.uploadUrl !== void 0) missing.push(asset);
490
- }
491
- let uploadedBytes = 0;
492
- await pool(missing, UPLOAD_CONCURRENCY, async (asset) => {
493
- const uploadUrl = bySha.get(asset.sha256)?.uploadUrl;
494
- if (uploadUrl === void 0) return;
495
- const body = read(asset.path);
496
- const send = () => put(uploadUrl, {
497
- method: "PUT",
498
- headers: {
499
- "content-type": asset.mime,
500
- "cache-control": CACHE_CONTROL
501
- },
502
- body: new Uint8Array(body)
503
- });
504
- let response = await send().catch(() => void 0);
505
- if (!response?.ok) response = await send().catch(() => void 0);
506
- if (!response?.ok) throw uploadFailure(asset, response);
507
- uploadedBytes += asset.bytes;
508
- });
509
- return {
510
- assets: assets.map((asset) => ({
511
- url: hosted.get(asset.sha256) ?? "",
512
- mime_type: asset.mime
513
- })),
514
- uploaded: missing.length,
515
- uploadedBytes,
516
- totalBytes
517
- };
518
- }
519
-
520
151
  //#endregion
521
152
  //#region src/core/paywalls/binding/binding.ts
522
153
  var BindingError = class extends Error {};
@@ -1033,122 +664,6 @@ async function resolveRenames(input) {
1033
664
  };
1034
665
  }
1035
666
 
1036
- //#endregion
1037
- //#region src/commands/paywalls/pipeline/report.ts
1038
- const kb = (bytes) => `${(bytes / 1024).toFixed(1)} kB`;
1039
- const weight = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : kb(bytes);
1040
- const SHORT_SHA = 7;
1041
- const shortSha = (sha) => typeof sha === "string" && sha.length >= SHORT_SHA ? sha.slice(0, SHORT_SHA) : void 0;
1042
- function pushedLine(input) {
1043
- const sha = shortSha(input.snapshotId);
1044
- const pushed = `Pushed ${input.promoting ? `version ${input.version}` : pc.yellow(`version ${input.version}`)}${sha ? ` ${pc.dim(`(${sha})`)}` : ""}`;
1045
- return input.promoting || input.live === void 0 ? pushed : `${pushed} · ${pc.dim(`live ${input.live}`)}`;
1046
- }
1047
- function transition(before, after) {
1048
- if (before === void 0) return `Promoted ${pc.green(`version ${after}`)}`;
1049
- if (before === after) return `Version ${pc.green(String(after))} already live`;
1050
- if (after < before) return `Rolled back ${pc.green(`version ${before} → ${after}`)}`;
1051
- return `Promoted ${pc.green(`version ${before} → ${after}`)}`;
1052
- }
1053
- const BIND_VERB = {
1054
- lock: "Linked to",
1055
- matched: "Linked to",
1056
- created: "Created",
1057
- renamed: "Rebound after rename to"
1058
- };
1059
- const LAYOUT_HINT = "expected superwall/{paywalls,funnels}/<id>/ with config.ts and app/index.tsx";
1060
- const NOTE_LIMIT = 2e3;
1061
- const PENDING_NAMES = 10;
1062
- function pendingPromoteWarning(pending, multi = false) {
1063
- if (pending.length === 0) return void 0;
1064
- const entries = pending.map((entry) => typeof entry === "string" ? { id: entry } : entry);
1065
- const ids = [...new Set(entries.map((entry) => entry.id))];
1066
- const platforms = new Set(entries.flatMap((entry) => entry.platform ? [entry.platform] : []));
1067
- const platformFlag = multi && platforms.size === 1 ? ` --platform ${[...platforms][0]}` : "";
1068
- const command = `superwall promote --id ${ids.join(",")}${platformFlag}`;
1069
- const labels = entries.map((entry) => multi && entry.platform ? `${entry.id} · ${entry.platform}` : entry.id);
1070
- if (labels.length === 1) return `${labels[0]} is pushed but not live — run \`${command}\` to publish it.`;
1071
- const shown = labels.slice(0, PENDING_NAMES).map((label) => ` ${label}`);
1072
- const rest = labels.length - shown.length;
1073
- return [
1074
- `These ${labels.length} paywalls are pushed but not live:`,
1075
- ...shown,
1076
- ...rest > 0 ? [` …and ${rest} more`] : [],
1077
- "",
1078
- ` ${command}`
1079
- ].join("\n");
1080
- }
1081
- function resolveNote(message) {
1082
- if (typeof message !== "string") return void 0;
1083
- if (message.length > NOTE_LIMIT) throw new Error(`Publish note is ${message.length} characters (limit ${NOTE_LIMIT}).`);
1084
- return message;
1085
- }
1086
- const took = (since) => {
1087
- const seconds = (Date.now() - since) / 1e3;
1088
- return pc.dim(seconds < 10 ? `(${seconds.toFixed(1)}s)` : `(${Math.round(seconds)}s)`);
1089
- };
1090
-
1091
- //#endregion
1092
- //#region src/commands/paywalls/pipeline/selection.ts
1093
- function projectDir(context) {
1094
- const [first] = projectDirs(context);
1095
- return first ?? process.cwd();
1096
- }
1097
- function projectDirs(context) {
1098
- const raw = context.argv.dir;
1099
- const list = (Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw]).filter((entry) => typeof entry === "string" && entry.length > 0);
1100
- if (list.length === 0) return [process.cwd()];
1101
- const expanded = list.flatMap((entry) => entry.includes("*") ? expandGlob(entry) : [entry]);
1102
- return [...new Set(expanded.map((entry) => resolve(entry)))];
1103
- }
1104
- function expandGlob(pattern) {
1105
- try {
1106
- return [...globSync(pattern)].filter((entry) => statSync(entry, { throwIfNoEntry: false })?.isDirectory() ?? false).sort();
1107
- } catch {
1108
- return [pattern];
1109
- }
1110
- }
1111
- function requireProject(project, dir) {
1112
- if (!project.marker) throw new Error(`Not a superwall project: ${dir}\nExpected a package.json here (or in superwall/) that depends on superwall.`);
1113
- 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.`);
1114
- return project;
1115
- }
1116
- function parseIds(value) {
1117
- return (Array.isArray(value) ? value : value === void 0 ? [] : [value]).flatMap((entry) => typeof entry === "string" ? entry.split(",") : []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
1118
- }
1119
- function selectSurfaces(project, ids) {
1120
- const wanted = parseIds(ids);
1121
- const known = project.surfaces.map((surface) => surface.id).join(", ");
1122
- if (wanted.length === 0) {
1123
- if (project.surfaces.length === 0) throw new Error(`No paywalls or funnels found — ${LAYOUT_HINT}.`);
1124
- return [...project.surfaces];
1125
- }
1126
- const selected = [];
1127
- for (const id of wanted) {
1128
- const matches = project.surfaces.filter((surface$1) => surface$1.id === id);
1129
- if (matches.length === 0) throw new Error(`No paywall or funnel named "${id}"` + (known ? ` — this project has: ${known}.` : ` — ${LAYOUT_HINT}.`));
1130
- if (matches.length > 1) {
1131
- const kinds = matches.map((surface$1) => `${surface$1.kind}/${surface$1.id}`).join(" and ");
1132
- throw new Error(`"${id}" is ambiguous — this project has ${kinds}.`);
1133
- }
1134
- const surface = matches[0];
1135
- if (surface && !selected.includes(surface)) selected.push(surface);
1136
- }
1137
- return selected;
1138
- }
1139
- function requireClean(surfaces) {
1140
- const problems = surfaces.flatMap((surface) => surface.diagnostics ?? []);
1141
- if (problems.length === 0) return;
1142
- throw new Error([
1143
- ...problems,
1144
- "",
1145
- "Publishing is immutable — fix these first, then push again."
1146
- ].join("\n"));
1147
- }
1148
- function needsWork(built, pushed, live) {
1149
- return built !== pushed && built !== live;
1150
- }
1151
-
1152
667
  //#endregion
1153
668
  //#region src/commands/paywalls/pick-app.ts
1154
669
  async function pickApplicationOption(apps, platform) {
@@ -1459,4 +974,4 @@ async function runPushPipeline(context, options) {
1459
974
  }
1460
975
 
1461
976
  //#endregion
1462
- export { requireApi as A, requireAssets as C, collectProjectDeclarations as D, loadFramework as E, isScreenOrigin as F, readLock as I, writeApp as L, writeProjectScaffold as M, requirePlatform as N, writeProjectTypes as O, resolveApps as P, writeOrigin as R, assetBaseUrl as S, frameworkVersion as T, parsePlatformFlags as _, projectDir as a, wantedPlatforms as b, selectSurfaces as c, pushSource as d, gitAvailable as f, projectForApplication as g, fetchProducts as h, pickApplicationOption as i, projectPackageName as j, LoginRequiredError as k, LAYOUT_HINT as l, warnNotPortable as m, runPushPipeline as n, projectDirs as o, collectSourceFiles as p, timed as r, requireProject as s, group as t, transition as u, planTargets as v, syncAssets as w, resolveBinding as x, targetLabel as y };
977
+ export { requireApi as _, pushSource as a, requirePlatform as b, warnNotPortable as c, parsePlatformFlags as d, planTargets as f, LoginRequiredError as g, resolveBinding as h, pickApplicationOption as i, fetchProducts as l, wantedPlatforms as m, runPushPipeline as n, gitAvailable as o, targetLabel as p, timed as r, collectSourceFiles as s, group as t, projectForApplication as u, projectPackageName as v, resolveApps as x, writeProjectScaffold as y };
@@ -1,11 +1,11 @@
1
- import "./output-CiELrN8w.js";
2
- import { i as track, r as setTelemetryTags } from "./telemetry-BuCbmoux.js";
1
+ import "./output-C-4UKMot.js";
2
+ import { i as track, r as setTelemetryTags } from "./telemetry-Ch9cCTI-.js";
3
3
  import "./ui-4gLyfrgl.js";
4
- import { i as loadBundledSkill } from "./skills-grTDuHlc.js";
4
+ import { i as loadBundledSkill } from "./skills-AxAf7bDB.js";
5
5
  import "./spawn-DSoTXy_j.js";
6
- import { t as scanProject } from "./scan-CAObNRgc.js";
7
- import { n as FRAMEWORK_REF } from "./actions-Dt35nIi8.js";
8
- import { t as detectBilling } from "./billing-BsQgXXYh.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
9
  import { resolve } from "node:path";
10
10
 
11
11
  //#region src/commands/workflow/print-skill.ts
@@ -1,21 +1,22 @@
1
- import { y as VERSION } from "./output-CiELrN8w.js";
2
- import "./telemetry-BuCbmoux.js";
3
- import "./update-DnGfpCD7.js";
4
- import "./token-mju3Q-vc.js";
5
- import { r as ApiError, t as defineCommand } from "./command-DMoMn7uc.js";
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
6
  import { n as ui } from "./ui-4gLyfrgl.js";
7
- import "./skills-grTDuHlc.js";
7
+ import "./skills-AxAf7bDB.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import "./login-Bjj8QvIN.js";
10
- import "./scan-CAObNRgc.js";
11
- import "./hosted-Cjekn8oJ.js";
9
+ import "./login-Bhxgqwtm.js";
10
+ import "./scan-BmAW413l.js";
11
+ import "./hosted-BeGVAntr.js";
12
12
  import "./spinner-DFctF_Jw.js";
13
13
  import { S as promotePaywallVersion, v as livePaywallVersion } from "./resources-Bf9O1JNM.js";
14
- import "./org-CV8c849b.js";
15
- import "./bind-BSTAinn6.js";
16
- import { A as requireApi, D as collectProjectDeclarations, E as loadFramework, P as resolveApps, _ as parsePlatformFlags, a as projectDir, b as wantedPlatforms, c as selectSurfaces, i as pickApplicationOption, r as timed, t as group, u as transition, v as planTargets, x as resolveBinding, y as targetLabel } from "./pipeline-DSCHL9KA.js";
17
- import "./actions-Dt35nIi8.js";
18
- import "./app-BU27SLPX.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";
19
20
  import pc from "picocolors";
20
21
 
21
22
  //#region src/commands/paywalls/promote.ts
@@ -0,0 +1,35 @@
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 };
@@ -0,0 +1,35 @@
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 };