@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.
- package/README.md +281 -34
- package/dist/apple-CkKlHBZ9.js +195 -0
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-H7f6knyY.js → billing-XCZU_T46.js} +98 -28
- package/dist/{bind-BIzaGq8K.js → bind-drne__Ys.js} +38 -33
- package/dist/{build-B7BS1rF2.js → build-Gpdq5QXP.js} +20 -26
- package/dist/client-BZ1UbpXz.js +66 -0
- package/dist/client-DP6Rc0t_.js +176 -0
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BBrtgUgS.js +969 -0
- package/dist/{create-CwnnNqv4.js → create-Cwc3SRWJ.js} +194 -168
- package/dist/create-Yvf2gStM.js +19 -0
- package/dist/doctor-C9ldpPFC.js +83 -0
- package/dist/{drivers-6RMOPIdn.js → drivers-DNrx4LWA.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28083 -801
- package/dist/environment-DF1qKlny.js +58 -0
- package/dist/{existing-DHpPn1y6.js → existing-78LWSsqS.js} +12 -6
- package/dist/held-Cy8Wl4D1.js +1112 -0
- package/dist/held-Ddw1XSsr.js +16 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-BR2LR-EK.js → integrate-DcJhpXy8.js} +277 -253
- package/dist/kinds-GFXB3sYu.js +11 -0
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-B2TsCE2H.js +53 -0
- package/dist/login-BoBe8Psl.js +16 -0
- package/dist/{login-Bhxgqwtm.js → login-D0lh3_JI.js} +144 -66
- package/dist/lookup-D-nmmAbw.js +71 -0
- package/dist/migrate-Cfec564E.js +274 -0
- package/dist/notification-url-YDbq6FMA.js +100 -0
- package/dist/{open-studio-BnVD6tJ9.js → open-Ba2vBl1_.js} +34 -43
- package/dist/org-D0g_q3mv.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-DxSLdpOI.js +29 -0
- package/dist/playbook-DIeb7hne.js +53 -0
- package/dist/{asc-products-Dvcyef3_.js → products-DH_fK9tY.js} +6 -39
- package/dist/promote-COD4fYdz.js +91 -0
- package/dist/push-CncywhkQ.js +482 -0
- package/dist/push-CtD4FZQV.js +22 -0
- package/dist/registry-DSrosOYs.js +10228 -0
- package/dist/{reports-DqMs9xNR.js → reports-DdPq4blM.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
- package/dist/{run-D-NbZLpj.js → run-C9qg_QlC.js} +16 -22
- package/dist/scan-Cv5uOwVY.js +4 -0
- package/dist/{scan-BmAW413l.js → scan-DLrsrFS9.js} +48 -37
- package/dist/scope-V336uz8j.js +198 -0
- package/dist/screenshot-file-0UETadF8.js +16 -0
- package/dist/{selection-BGi6GyxC.js → selection-Rdw-ZUoG.js} +94 -51
- package/dist/send-BxD9yf6F.js +150 -0
- package/dist/{dev-CgGAb5Al.js → server-D0tGG8C4.js} +82 -87
- package/dist/server-z1LH94R_.js +22 -0
- package/dist/session-1AV_Bs_d.js +6 -0
- package/dist/session-CFAmMhem.js +40 -0
- package/dist/session-D_nEWKXT.js +768 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +78 -28
- package/dist/skills/superwall-framework/references/cli.md +58 -28
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +30 -8
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/{skills-AxAf7bDB.js → skills-BvFOa4y6.js} +99 -122
- package/dist/skills-DMG4bpKk.js +14 -0
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-CneRK5rk.js +294 -0
- package/dist/storage-DYvmIOHa.d.ts +16 -0
- package/dist/storage-s2Dnz-yl.js +31 -0
- package/dist/storekit-DafAnGkM.js +16 -0
- package/dist/storekit-yY_kS2iR.js +47 -0
- package/dist/telemetry-DtG92m5O.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-BGAVPSQc.js → token-DzRh7dI1.js} +6 -38
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11178 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-Bt4Ouw1y.js +117 -0
- package/dist/upgrade-Cqy5orjb.js +7 -0
- package/package.json +10 -5
- package/dist/api-Dv3LyZ5m.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-mJC5NDtW.js +0 -189
- package/dist/asa-D6H7Pjae.js +0 -1194
- package/dist/asc-xCin0akG.js +0 -539
- package/dist/auth-ZlLL-Gko.js +0 -139
- package/dist/billing-C8kBge_S.js +0 -80
- package/dist/command-3fGYyC8r.js +0 -301
- package/dist/dev-Dx99K183.js +0 -22
- package/dist/doctor-CyUvut31.js +0 -88
- package/dist/feedback-RKyGuQ8_.js +0 -152
- package/dist/hosted-BeGVAntr.js +0 -32
- package/dist/migrate-C-4ISELN.js +0 -284
- package/dist/org-CQduIOic.js +0 -40
- package/dist/output-C-4UKMot.js +0 -136
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-CHX0Syre.js +0 -977
- package/dist/print-skill-BiZLdCKv.js +0 -74
- package/dist/promote-Pgpz-3xl.js +0 -88
- package/dist/publish-BPeuc3lq.js +0 -35
- package/dist/push-DcSQ4odB.js +0 -35
- package/dist/query-CWLaZkdm.js +0 -53
- package/dist/resource-jwASPCrw.js +0 -483
- package/dist/skills-FK5aDuNV.js +0 -64
- package/dist/spinner-DFctF_Jw.js +0 -18
- package/dist/storekit-CC4gnTI6.js +0 -29
- package/dist/telemetry-Ch9cCTI-.js +0 -169
- package/dist/ui-4gLyfrgl.js +0 -27737
- package/dist/update-DIXbL-H9.js +0 -59
- package/dist/upgrade-De7JMI1g.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/core/state/reports.ts
|
|
5
5
|
function dir(appPath) {
|
|
@@ -8,20 +8,21 @@ function dir(appPath) {
|
|
|
8
8
|
function path(appPath, id) {
|
|
9
9
|
return join(dir(appPath), `${id}.md`);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function writeReport(appPath, id, text) {
|
|
12
12
|
try {
|
|
13
13
|
mkdirSync(dir(appPath), { recursive: true });
|
|
14
14
|
writeFileSync(path(appPath, id), text, "utf8");
|
|
15
15
|
} catch {}
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function readReport(appPath, id) {
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const file = path(appPath, id);
|
|
20
|
+
if (!existsSync(file)) return void 0;
|
|
21
|
+
return readFileSync(file, "utf8");
|
|
21
22
|
} catch {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
//#endregion
|
|
27
|
-
export {
|
|
28
|
+
export { writeReport as n, readReport as t };
|
|
@@ -1,3 +1,108 @@
|
|
|
1
|
+
import { n as ApiUnreachableError, t as ApiError } from "./client-DP6Rc0t_.js";
|
|
2
|
+
import { o as readOpenedOrgs, p as writeOpenedOrgs } from "./config-BO1Y87kV.js";
|
|
3
|
+
|
|
4
|
+
//#region src/core/api/orgs.ts
|
|
5
|
+
async function listOrganizations(api) {
|
|
6
|
+
const res = await api.get("/v2/me/organizations");
|
|
7
|
+
return [...new Map((res.data ?? []).map((org) => [String(org.id), org])).values()];
|
|
8
|
+
}
|
|
9
|
+
function orgProjects(api, orgId) {
|
|
10
|
+
return api.list(`/v2/projects?organization_id=${encodeURIComponent(orgId)}`).then((projects) => projects.map((project) => ({
|
|
11
|
+
organization_id: orgId,
|
|
12
|
+
...project
|
|
13
|
+
})));
|
|
14
|
+
}
|
|
15
|
+
function orgIdOf(project) {
|
|
16
|
+
return project.organization_id === void 0 ? void 0 : String(project.organization_id);
|
|
17
|
+
}
|
|
18
|
+
function asksForOrg(error) {
|
|
19
|
+
return error instanceof ApiError && error.status === 400 && /organization_id/.test(error.message);
|
|
20
|
+
}
|
|
21
|
+
async function listReachableProjects(api) {
|
|
22
|
+
let members = await api.list("/v2/projects").catch(async (error) => {
|
|
23
|
+
if (!asksForOrg(error)) throw error;
|
|
24
|
+
const orgs = await listOrganizations(api);
|
|
25
|
+
return (await Promise.all(orgs.map((org) => orgProjects(api, String(org.id))))).flat();
|
|
26
|
+
});
|
|
27
|
+
members = unique(members);
|
|
28
|
+
const seen = new Set(members.map(orgIdOf).filter((id) => id !== void 0));
|
|
29
|
+
const opened = readOpenedOrgs().filter((id) => !seen.has(id));
|
|
30
|
+
if (opened.length === 0) return members;
|
|
31
|
+
const reached = await Promise.all(opened.map((id) => {
|
|
32
|
+
return orgProjects(api, id).catch((error) => {
|
|
33
|
+
if (error instanceof ApiError && [
|
|
34
|
+
400,
|
|
35
|
+
403,
|
|
36
|
+
404
|
|
37
|
+
].includes(error.status)) return [];
|
|
38
|
+
throw error;
|
|
39
|
+
});
|
|
40
|
+
}));
|
|
41
|
+
writeOpenedOrgs(opened.filter((_, index) => (reached[index]?.length ?? 0) > 0));
|
|
42
|
+
return [...members, ...reached.flat()];
|
|
43
|
+
}
|
|
44
|
+
function unique(projects) {
|
|
45
|
+
return [...new Map(projects.map((project) => [String(project.id), project])).values()];
|
|
46
|
+
}
|
|
47
|
+
function rememberOrg(project) {
|
|
48
|
+
const id = project && orgIdOf(project);
|
|
49
|
+
if (id) writeOpenedOrgs([...readOpenedOrgs(), id]);
|
|
50
|
+
}
|
|
51
|
+
async function listOrgGroups(api) {
|
|
52
|
+
const [projects, memberships] = await Promise.all([listReachableProjects(api), listOrganizations(api).catch(() => [])]);
|
|
53
|
+
const members = new Map(memberships.map((org) => [String(org.id), org]));
|
|
54
|
+
const groups = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const project of projects) {
|
|
56
|
+
const id = orgIdOf(project) ?? "";
|
|
57
|
+
const name = members.get(id)?.name;
|
|
58
|
+
const group = groups.get(id) ?? {
|
|
59
|
+
id,
|
|
60
|
+
name: typeof name === "string" ? name : void 0,
|
|
61
|
+
member: members.has(id) || id === "",
|
|
62
|
+
projects: []
|
|
63
|
+
};
|
|
64
|
+
group.projects.push(project);
|
|
65
|
+
groups.set(id, group);
|
|
66
|
+
}
|
|
67
|
+
await Promise.all([...groups.values()].filter((group) => !group.member && !group.name).map(async (group) => {
|
|
68
|
+
const org = await api.get(`/v2/organizations/${encodeURIComponent(group.id)}`).catch(() => void 0);
|
|
69
|
+
if (typeof org?.name === "string") group.name = org.name;
|
|
70
|
+
}));
|
|
71
|
+
return [...groups.values()].sort((a, b) => Number(b.member) - Number(a.member));
|
|
72
|
+
}
|
|
73
|
+
async function organizationOf(api, projectId, known) {
|
|
74
|
+
const local = known?.find((project) => String(project.id) === projectId);
|
|
75
|
+
const id = (local && orgIdOf(local)) ?? orgIdOf(await api.get(`/v2/projects/${encodeURIComponent(projectId)}`));
|
|
76
|
+
if (!id) throw new Error(`Couldn't tell which account project ${projectId} belongs to.`);
|
|
77
|
+
return id;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/core/json.ts
|
|
82
|
+
function isRecord(value) {
|
|
83
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
84
|
+
}
|
|
85
|
+
function parseJson(body) {
|
|
86
|
+
if (body.trim() === "") return void 0;
|
|
87
|
+
try {
|
|
88
|
+
return JSON.parse(body);
|
|
89
|
+
} catch {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function field(value, key) {
|
|
94
|
+
return typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
|
|
95
|
+
}
|
|
96
|
+
function textField(value, key) {
|
|
97
|
+
const found = field(value, key);
|
|
98
|
+
return typeof found === "string" && found.trim() !== "" ? found.trim() : void 0;
|
|
99
|
+
}
|
|
100
|
+
function listField(value, key) {
|
|
101
|
+
const found = field(value, key);
|
|
102
|
+
return Array.isArray(found) ? found : [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
1
106
|
//#region src/core/api/resources.ts
|
|
2
107
|
const RESOURCES = {
|
|
3
108
|
products: "/v2/products",
|
|
@@ -15,7 +120,7 @@ function isAppScoped(name) {
|
|
|
15
120
|
return RESOURCE_SCOPE[name] === "application";
|
|
16
121
|
}
|
|
17
122
|
function titleCase(s) {
|
|
18
|
-
return s
|
|
123
|
+
return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
|
19
124
|
}
|
|
20
125
|
function platformLabel(platform) {
|
|
21
126
|
switch ((platform ?? "").toLowerCase()) {
|
|
@@ -25,12 +130,11 @@ function platformLabel(platform) {
|
|
|
25
130
|
case "react_native":
|
|
26
131
|
case "react-native": return "React Native";
|
|
27
132
|
case "web": return "Web";
|
|
28
|
-
default: return platform ? platform
|
|
133
|
+
default: return platform ? platform.charAt(0).toUpperCase() + platform.slice(1) : "?";
|
|
29
134
|
}
|
|
30
135
|
}
|
|
31
136
|
async function listProjects(api) {
|
|
32
|
-
|
|
33
|
-
return api.list(org ? `/v2/projects?organization_id=${encodeURIComponent(org)}` : "/v2/projects");
|
|
137
|
+
return listReachableProjects(api);
|
|
34
138
|
}
|
|
35
139
|
async function listApplications(api) {
|
|
36
140
|
return (await listProjects(api)).flatMap((p) => p.applications ?? []);
|
|
@@ -51,6 +155,7 @@ function createEntitlement(api, scope, identifier) {
|
|
|
51
155
|
function createProduct(api, scope, identifier, opts = {}) {
|
|
52
156
|
return api.post("/v2/products", {
|
|
53
157
|
project_id: scope.projectId,
|
|
158
|
+
...opts.applicationId ? { application_id: opts.applicationId } : {},
|
|
54
159
|
identifier,
|
|
55
160
|
...opts.name ? { name: opts.name } : {},
|
|
56
161
|
...opts.price ? { price: opts.price } : {},
|
|
@@ -58,15 +163,10 @@ function createProduct(api, scope, identifier, opts = {}) {
|
|
|
58
163
|
...opts.entitlements?.length ? { entitlements: opts.entitlements } : {}
|
|
59
164
|
});
|
|
60
165
|
}
|
|
61
|
-
|
|
62
|
-
return (await api.get("/v2/me/organizations")).data ?? [];
|
|
63
|
-
}
|
|
64
|
-
function createProject(api, name) {
|
|
65
|
-
const orgId = api.org.id;
|
|
66
|
-
if (!orgId) throw new Error("No organization selected - run `superwall orgs use <id|name>` first.");
|
|
166
|
+
function createProject(api, name, organizationId) {
|
|
67
167
|
return api.post("/v2/projects", {
|
|
68
168
|
name,
|
|
69
|
-
organization_id: Number(
|
|
169
|
+
organization_id: Number(organizationId)
|
|
70
170
|
});
|
|
71
171
|
}
|
|
72
172
|
function createApplication(api, scope, opts) {
|
|
@@ -89,9 +189,6 @@ function createCampaign(api, scope, description, placement) {
|
|
|
89
189
|
}] }]
|
|
90
190
|
});
|
|
91
191
|
}
|
|
92
|
-
function addPlacement(api, campaignId, placement) {
|
|
93
|
-
return api.post(`/v2/campaigns/${campaignId}/placements`, { event_name: placement });
|
|
94
|
-
}
|
|
95
192
|
function rowName(row) {
|
|
96
193
|
for (const key of [
|
|
97
194
|
"name",
|
|
@@ -108,25 +205,24 @@ function rowName(row) {
|
|
|
108
205
|
return String(row.id ?? " - ");
|
|
109
206
|
}
|
|
110
207
|
async function listAppPaywalls(api, applicationId, options = {}) {
|
|
111
|
-
return (await api.list(`/v2/paywalls?application_id=${encodeURIComponent(applicationId)}` + (options.archived ? "&archived=true" : ""))).map((row) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
208
|
+
return (await api.list(`/v2/paywalls?application_id=${encodeURIComponent(applicationId)}` + (options.archived ? "&archived=true" : ""))).map((row) => ({
|
|
209
|
+
id: String(row.id),
|
|
210
|
+
identifier: typeof row.identifier === "string" ? row.identifier : void 0,
|
|
211
|
+
archived: options.archived === true,
|
|
212
|
+
metadata: parseMetadata(row.metadata)
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
function parseMetadata(value) {
|
|
216
|
+
const metadata = {};
|
|
217
|
+
if (!isRecord(value)) return metadata;
|
|
218
|
+
for (const [key, entry] of Object.entries(value)) if (typeof entry === "string") metadata[key] = entry;
|
|
219
|
+
return metadata;
|
|
123
220
|
}
|
|
124
|
-
|
|
221
|
+
function parseProductRefs(value) {
|
|
125
222
|
if (!Array.isArray(value)) return [];
|
|
126
223
|
const refs = [];
|
|
127
|
-
for (const
|
|
128
|
-
if (
|
|
129
|
-
const row = entry;
|
|
224
|
+
for (const row of value) {
|
|
225
|
+
if (!isRecord(row)) continue;
|
|
130
226
|
if (typeof row.reference_name !== "string" || typeof row.identifier !== "string") continue;
|
|
131
227
|
refs.push({
|
|
132
228
|
reference: row.reference_name,
|
|
@@ -135,20 +231,16 @@ const productRefsOf = (value) => {
|
|
|
135
231
|
});
|
|
136
232
|
}
|
|
137
233
|
return refs;
|
|
138
|
-
}
|
|
139
|
-
async function
|
|
234
|
+
}
|
|
235
|
+
async function findPaywall(api, paywallId) {
|
|
140
236
|
const row = await api.get(`/v2/paywalls/${encodeURIComponent(paywallId)}`);
|
|
141
|
-
const metadata = {};
|
|
142
|
-
if (typeof row.metadata === "object" && row.metadata !== null) {
|
|
143
|
-
for (const [key, value] of Object.entries(row.metadata)) if (typeof value === "string") metadata[key] = value;
|
|
144
|
-
}
|
|
145
237
|
const applicationId = row.application_id;
|
|
146
238
|
return {
|
|
147
239
|
id: String(row.id ?? paywallId),
|
|
148
240
|
identifier: typeof row.identifier === "string" ? row.identifier : void 0,
|
|
149
241
|
name: typeof row.name === "string" ? row.name : void 0,
|
|
150
242
|
archived: row.archived === true,
|
|
151
|
-
metadata,
|
|
243
|
+
metadata: parseMetadata(row.metadata),
|
|
152
244
|
applicationId: typeof applicationId === "string" || typeof applicationId === "number" ? String(applicationId) : void 0,
|
|
153
245
|
projectId: typeof row.project_id === "string" || typeof row.project_id === "number" ? String(row.project_id) : void 0,
|
|
154
246
|
platform: typeof row.application_platform === "string" ? row.application_platform : void 0,
|
|
@@ -158,28 +250,23 @@ async function getPaywall(api, paywallId) {
|
|
|
158
250
|
headless: row.headless === true,
|
|
159
251
|
presentationStyle: typeof row.presentation_style === "string" ? row.presentation_style : void 0,
|
|
160
252
|
featureGating: typeof row.feature_gating === "string" ? row.feature_gating : void 0,
|
|
161
|
-
products:
|
|
253
|
+
products: parseProductRefs(row.products)
|
|
162
254
|
};
|
|
163
255
|
}
|
|
164
|
-
async function projectOrganizationId(api, projectId) {
|
|
165
|
-
const organization = (await api.get(`/v2/projects/${encodeURIComponent(projectId)}`)).organization_id;
|
|
166
|
-
return typeof organization === "string" || typeof organization === "number" ? String(organization) : void 0;
|
|
167
|
-
}
|
|
168
256
|
const SNAPSHOT_IN_URL = /([a-f0-9]{64})\.html/;
|
|
169
257
|
async function livePaywall(api, paywallId) {
|
|
170
|
-
return
|
|
258
|
+
return findPaywall(api, paywallId).then((paywall) => ({
|
|
171
259
|
version: paywall.version,
|
|
172
260
|
snapshotId: paywall.url?.match(SNAPSHOT_IN_URL)?.[1]
|
|
173
|
-
}), () =>
|
|
261
|
+
}), (error) => {
|
|
262
|
+
if (error instanceof ApiUnreachableError) return {};
|
|
263
|
+
if (error instanceof ApiError && error.status >= 500) return {};
|
|
264
|
+
throw error;
|
|
265
|
+
});
|
|
174
266
|
}
|
|
175
267
|
async function livePaywallVersion(api, paywallId) {
|
|
176
268
|
return livePaywall(api, paywallId).then((live) => live.version);
|
|
177
269
|
}
|
|
178
|
-
async function getPaywallApplicationId(api, paywallId) {
|
|
179
|
-
const { applicationId } = await getPaywall(api, paywallId);
|
|
180
|
-
if (applicationId !== void 0) return applicationId;
|
|
181
|
-
throw new Error(`Superwall returned no application for paywall ${paywallId}.`);
|
|
182
|
-
}
|
|
183
270
|
async function createHeadlessPaywall(api, opts) {
|
|
184
271
|
const row = await api.post("/v2/paywalls", {
|
|
185
272
|
application_id: opts.applicationId,
|
|
@@ -194,11 +281,19 @@ async function createHeadlessPaywall(api, opts) {
|
|
|
194
281
|
metadata: {}
|
|
195
282
|
};
|
|
196
283
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
284
|
+
function resolveStore(identifier, platform) {
|
|
285
|
+
if (/^(test|live):price_[^:]+/.test(identifier)) return "stripe";
|
|
286
|
+
return platform === "android" ? "play-store" : "app-store";
|
|
287
|
+
}
|
|
288
|
+
function versionProducts(products, platform) {
|
|
289
|
+
return Object.entries(products ?? {}).map(([reference, identifier]) => {
|
|
290
|
+
return {
|
|
291
|
+
store: resolveStore(identifier, platform),
|
|
292
|
+
identifier,
|
|
293
|
+
reference_name: reference
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
202
297
|
function pushPaywallVersion(api, paywallId, opts) {
|
|
203
298
|
return api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/versions`, {
|
|
204
299
|
html: opts.html,
|
|
@@ -257,4 +352,4 @@ function promotePaywallVersion(api, paywallId, opts = {}) {
|
|
|
257
352
|
}
|
|
258
353
|
|
|
259
354
|
//#endregion
|
|
260
|
-
export {
|
|
355
|
+
export { listOrgGroups as A, titleCase as C, listField as D, isRecord as E, rememberOrg as F, orgIdOf as M, orgProjects as N, parseJson as O, organizationOf as P, rowName as S, field as T, mintSourceAccess as _, createHeadlessPaywall as a, pushPaywallAssets as b, findPaywall as c, listAppPaywalls as d, listApplications as f, livePaywallVersion as g, livePaywall as h, createEntitlement as i, listOrganizations as j, textField as k, isAppScoped as l, listResource as m, createApplication as n, createProduct as o, listProjects as p, createCampaign as r, createProject as s, RESOURCES as t, linkSourceCommit as u, platformLabel as v, versionProducts as w, pushPaywallVersion as x, promotePaywallVersion as y };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
1
|
+
import { c as DASHBOARD_URL } from "./environment-DF1qKlny.js";
|
|
2
|
+
import { i as packagedDir } from "./paths-DxSLdpOI.js";
|
|
5
3
|
import { spawn } from "node:child_process";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
6
|
|
|
7
|
-
//#region src/clipboard.ts
|
|
7
|
+
//#region src/ui/clipboard.ts
|
|
8
8
|
async function copyToClipboard(text) {
|
|
9
|
-
const cmd =
|
|
10
|
-
if (!cmd) return false;
|
|
9
|
+
const cmd = resolveClipboardCommand();
|
|
11
10
|
return new Promise((resolve$1) => {
|
|
12
11
|
try {
|
|
13
12
|
const child = spawn(cmd.command, cmd.args, { stdio: [
|
|
@@ -25,7 +24,7 @@ async function copyToClipboard(text) {
|
|
|
25
24
|
}
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
|
-
function
|
|
27
|
+
function resolveClipboardCommand() {
|
|
29
28
|
switch (process.platform) {
|
|
30
29
|
case "darwin": return {
|
|
31
30
|
command: "pbcopy",
|
|
@@ -43,14 +42,9 @@ function clipboardCommand() {
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
//#endregion
|
|
46
|
-
//#region src/core/agent/prompt.ts
|
|
45
|
+
//#region src/core/workflows/agent/prompt.ts
|
|
47
46
|
const cache = /* @__PURE__ */ new Map();
|
|
48
|
-
|
|
49
|
-
* Load a prompt from prompts/ and interpolate it.
|
|
50
|
-
* `{{#var}}…{{/var}}` blocks are kept only when `vars[var]` is non-empty;
|
|
51
|
-
* `{{var}}` is a plain substitution and throws when the variable is missing.
|
|
52
|
-
*/
|
|
53
|
-
function loadPrompt(rel, vars = {}) {
|
|
47
|
+
function readPrompt(rel, vars = {}) {
|
|
54
48
|
let raw = cache.get(rel);
|
|
55
49
|
if (raw === void 0) {
|
|
56
50
|
raw = readFileSync(join(packagedDir("prompts"), rel), "utf8");
|
|
@@ -62,11 +56,11 @@ function loadPrompt(rel, vars = {}) {
|
|
|
62
56
|
return value;
|
|
63
57
|
}).replace(/\n{3,}/g, "\n\n").trim();
|
|
64
58
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
59
|
+
function readCommandments() {
|
|
60
|
+
return readPrompt("commandments.xml");
|
|
67
61
|
}
|
|
68
62
|
function buildActionPrompt(action, ctx) {
|
|
69
|
-
return `${
|
|
63
|
+
return `${readPrompt("context.xml", {
|
|
70
64
|
platform: `${ctx.app.framework.name}${ctx.app.details ? ` (${ctx.app.details})` : ""}`,
|
|
71
65
|
app_dir: ctx.app.path,
|
|
72
66
|
api_key: ctx.apiKey || "(not provided)",
|
|
@@ -74,19 +68,19 @@ function buildActionPrompt(action, ctx) {
|
|
|
74
68
|
configure_present: ctx.existing.configureFound ? "yes" : "no",
|
|
75
69
|
docs_url: ctx.app.framework.docsUrl,
|
|
76
70
|
dashboard_url: DASHBOARD_URL
|
|
77
|
-
})}\n\n${
|
|
71
|
+
})}\n\n${readPrompt(`actions/${action.id}.xml`, action.vars(ctx))}`;
|
|
78
72
|
}
|
|
79
73
|
function buildCopyPrompt(action, ctx) {
|
|
80
74
|
return buildActionPrompt(action, ctx).split("\n").filter((line) => !line.includes("[STATUS]")).join("\n").trimEnd();
|
|
81
75
|
}
|
|
82
76
|
|
|
83
77
|
//#endregion
|
|
84
|
-
//#region src/core/agent/run.ts
|
|
78
|
+
//#region src/core/workflows/agent/run.ts
|
|
85
79
|
async function runAction(opts) {
|
|
86
80
|
return runWithDriverFallback([opts.driver, ...opts.fallbackDrivers ?? []], {
|
|
87
81
|
prompt: buildActionPrompt(opts.action, opts.ctx),
|
|
88
82
|
cwd: opts.ctx.app.path,
|
|
89
|
-
systemAppend:
|
|
83
|
+
systemAppend: readCommandments(),
|
|
90
84
|
capabilities: opts.action.capabilities,
|
|
91
85
|
onEvent: opts.onEvent,
|
|
92
86
|
signal: opts.signal
|
|
@@ -103,4 +97,4 @@ async function runWithDriverFallback(drivers, options) {
|
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
//#endregion
|
|
106
|
-
export { copyToClipboard as a,
|
|
100
|
+
export { copyToClipboard as a, readPrompt as i, runWithDriverFallback as n, buildCopyPrompt as r, runAction as t };
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { basename, dirname, join, relative, sep } from "node:path";
|
|
1
|
+
import { f as Integration } from "./environment-DF1qKlny.js";
|
|
3
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, relative, sep } from "node:path";
|
|
4
4
|
import fg from "fast-glob";
|
|
5
5
|
|
|
6
|
-
//#region src/core/
|
|
6
|
+
//#region src/core/codebase/package.ts
|
|
7
|
+
function readPackageJson(dir) {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function allDeps(pkg) {
|
|
15
|
+
if (!pkg) return {};
|
|
16
|
+
return {
|
|
17
|
+
...pkg.dependencies ?? {},
|
|
18
|
+
...pkg.devDependencies ?? {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/core/codebase/frameworks.ts
|
|
7
24
|
const frameworkByIntegration = {
|
|
8
25
|
[Integration.swift]: {
|
|
9
26
|
integration: Integration.swift,
|
|
@@ -49,27 +66,10 @@ const frameworkByIntegration = {
|
|
|
49
66
|
}
|
|
50
67
|
};
|
|
51
68
|
const supportedNames = Object.values(frameworkByIntegration).filter((f) => f.supported).map((f) => f.name);
|
|
52
|
-
const SUPPORTED_LABEL =
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/core/project/package.ts
|
|
56
|
-
function readPackageJson(dir) {
|
|
57
|
-
try {
|
|
58
|
-
return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
59
|
-
} catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function allDeps(pkg) {
|
|
64
|
-
if (!pkg) return {};
|
|
65
|
-
return {
|
|
66
|
-
...pkg.dependencies ?? {},
|
|
67
|
-
...pkg.devDependencies ?? {}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
69
|
+
const SUPPORTED_LABEL = `${supportedNames.slice(0, -1).join(", ")}, or ${supportedNames.at(-1)}`;
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
|
-
//#region src/core/
|
|
72
|
+
//#region src/core/codebase/scan.ts
|
|
73
73
|
const IGNORE = [
|
|
74
74
|
"**/node_modules/**",
|
|
75
75
|
"**/.git/**",
|
|
@@ -130,9 +130,15 @@ function androidUiKind(dir, gradle) {
|
|
|
130
130
|
absolute: true,
|
|
131
131
|
deep: 8
|
|
132
132
|
});
|
|
133
|
-
for (const f of files.slice(0, 300))
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
for (const f of files.slice(0, 300)) {
|
|
134
|
+
let content;
|
|
135
|
+
try {
|
|
136
|
+
content = readFileSync(f, "utf8");
|
|
137
|
+
} catch {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (content.includes("@Composable")) return "Jetpack Compose";
|
|
141
|
+
}
|
|
136
142
|
return "Views";
|
|
137
143
|
}
|
|
138
144
|
const ANDROID_APP_PLUGIN = /com\.android\.application|alias\(libs\.plugins\.android\.application\)|libs\.plugins\.androidApplication/;
|
|
@@ -146,12 +152,17 @@ function swiftUiKind(dir) {
|
|
|
146
152
|
let swiftui = false;
|
|
147
153
|
let uikit = false;
|
|
148
154
|
for (const f of files.slice(0, 300)) {
|
|
155
|
+
let content;
|
|
149
156
|
try {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
if (
|
|
157
|
+
content = readFileSync(f, "utf8");
|
|
158
|
+
} catch {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (content.includes("import SwiftUI")) {
|
|
162
|
+
swiftui = true;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (content.includes("import UIKit")) uikit = true;
|
|
155
166
|
}
|
|
156
167
|
if (swiftui) return "SwiftUI";
|
|
157
168
|
if (uikit) return "UIKit";
|
|
@@ -172,7 +183,7 @@ function isGeneratedNative(swiftDir, jsRoots) {
|
|
|
172
183
|
function isLibraryPath(dir) {
|
|
173
184
|
return dir.includes(`${sep}packages${sep}`) || dir.includes(`${sep}libs${sep}`) || dir.includes(`${sep}node_modules${sep}`);
|
|
174
185
|
}
|
|
175
|
-
function
|
|
186
|
+
function createDetectedApp(root, dir, c) {
|
|
176
187
|
const rel = relative(root, dir) || ".";
|
|
177
188
|
return {
|
|
178
189
|
path: dir,
|
|
@@ -185,7 +196,7 @@ function makeApp(root, dir, c) {
|
|
|
185
196
|
};
|
|
186
197
|
}
|
|
187
198
|
function looksLikeMonorepoRoot(root) {
|
|
188
|
-
return existsSync(join(root, "turbo.json")) || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "nx.json")) || existsSync(join(root, "lerna.json")) ||
|
|
199
|
+
return existsSync(join(root, "turbo.json")) || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "nx.json")) || existsSync(join(root, "lerna.json")) || typeof readPackageJson(root)?.workspaces === "object";
|
|
189
200
|
}
|
|
190
201
|
async function scanProject(root) {
|
|
191
202
|
const opts = {
|
|
@@ -211,7 +222,7 @@ async function scanProject(root) {
|
|
|
211
222
|
for (const dir of jsRoots) {
|
|
212
223
|
if (isLibraryPath(dir)) continue;
|
|
213
224
|
const c = classifyJs(dir);
|
|
214
|
-
if (c) apps.push(
|
|
225
|
+
if (c) apps.push(createDetectedApp(root, dir, c));
|
|
215
226
|
else if (dir !== root) skipped.push(basename(dir));
|
|
216
227
|
}
|
|
217
228
|
const swiftDirs = /* @__PURE__ */ new Set();
|
|
@@ -224,7 +235,7 @@ async function scanProject(root) {
|
|
|
224
235
|
for (const t of tuistProjects) swiftDirs.add(dirname(join(root, t)));
|
|
225
236
|
for (const dir of swiftDirs) {
|
|
226
237
|
if (isGeneratedNative(dir, jsRootSet)) continue;
|
|
227
|
-
apps.push(
|
|
238
|
+
apps.push(createDetectedApp(root, dir, {
|
|
228
239
|
integration: Integration.swift,
|
|
229
240
|
details: swiftUiKind(dir),
|
|
230
241
|
score: .95
|
|
@@ -242,7 +253,7 @@ async function scanProject(root) {
|
|
|
242
253
|
if (!gradle.split("\n").some((line) => ANDROID_APP_PLUGIN.test(line) && !/apply\s+false/.test(line))) continue;
|
|
243
254
|
const moduleDir = dirname(file);
|
|
244
255
|
if (isGeneratedNative(moduleDir, nativeRoots)) continue;
|
|
245
|
-
apps.push(
|
|
256
|
+
apps.push(createDetectedApp(root, moduleDir, {
|
|
246
257
|
integration: Integration.android,
|
|
247
258
|
details: androidUiKind(moduleDir, gradle),
|
|
248
259
|
score: .95
|
|
@@ -250,7 +261,7 @@ async function scanProject(root) {
|
|
|
250
261
|
}
|
|
251
262
|
for (const p of pubspecs) {
|
|
252
263
|
const dir = dirname(join(root, p));
|
|
253
|
-
apps.push(
|
|
264
|
+
apps.push(createDetectedApp(root, dir, {
|
|
254
265
|
integration: Integration.flutter,
|
|
255
266
|
score: .9
|
|
256
267
|
}));
|
|
@@ -273,4 +284,4 @@ async function scanProject(root) {
|
|
|
273
284
|
}
|
|
274
285
|
|
|
275
286
|
//#endregion
|
|
276
|
-
export {
|
|
287
|
+
export { readPackageJson as i, SUPPORTED_LABEL as n, allDeps as r, scanProject as t };
|