@superwall/cli 1.6.1 → 1.7.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 +116 -3
- package/dist/{actions-BdZ-7BJd.js → actions-B7ym3oVS.js} +2 -2
- package/dist/{api-FjrCPu6r.js → api-CZzirVMj.js} +8 -8
- package/dist/{app-YeJj35Ia.js → app-DH6U8yuI.js} +11 -10
- package/dist/{asa-4nk7HHy8.js → asa-C-sQzPPn.js} +10 -10
- package/dist/{asc-2TZOQuK1.js → asc-1ZBJ6DwS.js} +282 -43
- package/dist/asc-Bf7zBbyS.js +65 -0
- package/dist/{asc-products-1e1DoGeL.js → asc-products-9JXtDxI4.js} +2 -35
- package/dist/{auth-QUYfKdwk.js → auth-YRhlV3DE.js} +11 -10
- package/dist/auth.js +2 -2
- package/dist/{billing-BK7bpv1t.js → billing-CCYHdApx.js} +1 -1
- package/dist/{bind-Ch4VR2EY.js → bind-YrJvuRF9.js} +3 -3
- package/dist/build-DLoCW5Ri.js +87 -0
- package/dist/bundle-id-CKxl_026.js +121 -0
- package/dist/{command-BJ_6850A.js → command-CMIz81Da.js} +5 -5
- package/dist/{create-vSQxQlEP.js → create-pkANt1Gs.js} +22 -21
- package/dist/dev-DZy6pOnB.js +22 -0
- package/dist/{dev-DEss5dwo.js → dev-DmB3XqaJ.js} +16 -8
- package/dist/{doctor-BYTfekBr.js → doctor-H-hf-Yww.js} +10 -10
- package/dist/{drivers-DGml3OlF.js → drivers-Qx9LxmRN.js} +2 -2
- package/dist/entry.js +453 -43
- package/dist/{existing-DgSo639M.js → existing-AVEfZu2A.js} +2 -2
- package/dist/feedback-CKf-rpBW.js +152 -0
- package/dist/{hosted-DqGp6oV2.js → hosted-CXe9TrWx.js} +2 -2
- package/dist/{integrate-Cl9eKHoF.js → integrate-brmhPG-S.js} +23 -22
- package/dist/{login-DS3MPeW2.js → login-Do4wFuLv.js} +31 -16
- package/dist/{migrate-WiTO71PE.js → migrate-C9ERDR6y.js} +24 -23
- package/dist/notification-url-DuKF2659.js +1273 -0
- package/dist/{open-studio-CbMUL5Va.js → open-studio-DOw-6ydc.js} +17 -14
- package/dist/{org-CV8c849b.js → org-sj7uyvp-.js} +2 -2
- package/dist/{output-XKuoEEjP.js → output-C4o2gJ1K.js} +12 -2
- package/dist/{pipeline-J9-nENTS.js → pipeline-BqzqZhX1.js} +10 -495
- package/dist/{print-skill-BOGm5Szi.js → print-skill-ZojRSybs.js} +7 -7
- package/dist/{promote-Ci085QxU.js → promote-BG8X4Nv_.js} +17 -16
- package/dist/publish-sxLh-G4G.js +35 -0
- package/dist/push-bQ6Vxtg8.js +35 -0
- package/dist/{query-BZStoGLM.js → query-_FbybaH-.js} +9 -9
- package/dist/{resource-ClLHSXi6.js → resource-CGIwSd29.js} +17 -177
- package/dist/revenue-provider-ebsRINY8.js +100 -0
- package/dist/{run-CiaWn78U.js → run-DsVZ5snL.js} +2 -2
- package/dist/{scan-DEgX5HxV.js → scan-zKsddO72.js} +1 -1
- package/dist/scope-BvzD-kO4.js +223 -0
- package/dist/selection-CxZoX4NT.js +496 -0
- package/dist/setup-Bxj22rYi.js +189 -0
- package/dist/skills/superwall-framework/SKILL.md +109 -36
- package/dist/skills/superwall-framework/references/cli.md +45 -5
- package/dist/skills/superwall-framework/references/mobile-design.md +60 -181
- package/dist/{skills-DsBAVRTE.js → skills-DPzlnfCK.js} +78 -9
- package/dist/{skills-DjPCmUMU.js → skills-D_R-lEsK.js} +8 -8
- package/dist/{spinner-DFctF_Jw.js → spinner-TWa0hia6.js} +1 -1
- package/dist/{telemetry-EzV7cA7s.js → telemetry-DeA1mvnT.js} +1 -1
- package/dist/{token-r5g876aI.js → token-C0it-Xh7.js} +1 -1
- package/dist/{ui-4gLyfrgl.js → ui-Dy0b-9L8.js} +4 -3
- package/dist/{update-Cz3Q3MFj.js → update-B2fWIc4q.js} +2 -2
- package/dist/{upgrade-BA_4sdnh.js → upgrade-BmzkTKrh.js} +6 -6
- package/package.json +2 -2
- package/dist/dev-B9qmPH1W.js +0 -21
- package/dist/feedback-4LsBpZZx.js +0 -73
- package/dist/publish--TV-j8Zd.js +0 -34
- package/dist/push-CpGetsJF.js +0 -34
- package/dist/skills/superwall-framework/references/responsive.md +0 -162
- /package/dist/{api-output-CEhN-U_N.js → api-output-aJNw7Syy.js} +0 -0
- /package/dist/{params-BxgTuCzr.js → params-l3CrvRtR.js} +0 -0
- /package/dist/{reports-C0xHCLnt.js → reports-CfJqoava.js} +0 -0
- /package/dist/{storekit-Dlpbq5Wv.js → storekit-Cj9Cpjcz.js} +0 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { s as ASSET_HOST } from "./output-C4o2gJ1K.js";
|
|
2
|
+
import { r as ApiError } from "./command-CMIz81Da.js";
|
|
3
|
+
import { C as pushPaywallAssets } from "./resources-Bf9O1JNM.js";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import pc from "picocolors";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import { globSync, readFileSync, statSync } from "node:fs";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
11
|
+
|
|
12
|
+
//#region src/core/paywalls/assets.ts
|
|
13
|
+
const assetBaseUrl = (applicationId) => `${ASSET_HOST()}/${applicationId}`;
|
|
14
|
+
function requireAssets(built) {
|
|
15
|
+
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.");
|
|
16
|
+
return built.assets;
|
|
17
|
+
}
|
|
18
|
+
var AssetSyncError = class extends Error {};
|
|
19
|
+
const assetName = (asset) => asset.path.split(/[\\/]/).pop() || asset.fileName;
|
|
20
|
+
function uploadFailure(asset, response) {
|
|
21
|
+
const name = assetName(asset);
|
|
22
|
+
if (!response) return new AssetSyncError(`Couldn't upload ${name} — the asset store is unreachable. Check your network, then push again.`);
|
|
23
|
+
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.`);
|
|
24
|
+
return new AssetSyncError(`Couldn't upload ${name} — the asset store returned HTTP ${response.status}.`);
|
|
25
|
+
}
|
|
26
|
+
const CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
27
|
+
const UPLOAD_CONCURRENCY = 4;
|
|
28
|
+
const pool = async (items, limit, work) => {
|
|
29
|
+
const queue = [...items];
|
|
30
|
+
const runners = Array.from({ length: Math.min(limit, queue.length) }, async () => {
|
|
31
|
+
for (let item = queue.shift(); item !== void 0; item = queue.shift()) await work(item);
|
|
32
|
+
});
|
|
33
|
+
await Promise.all(runners);
|
|
34
|
+
};
|
|
35
|
+
async function syncAssets(input) {
|
|
36
|
+
const { api, paywallId, assets } = input;
|
|
37
|
+
const put = input.put ?? fetch;
|
|
38
|
+
const read = input.read ?? ((path$1) => fs.readFileSync(path$1));
|
|
39
|
+
const totalBytes = assets.reduce((total, asset) => total + asset.bytes, 0);
|
|
40
|
+
if (assets.length === 0) return {
|
|
41
|
+
assets: [],
|
|
42
|
+
uploaded: 0,
|
|
43
|
+
uploadedBytes: 0,
|
|
44
|
+
totalBytes: 0
|
|
45
|
+
};
|
|
46
|
+
const resolved = await pushPaywallAssets(api, paywallId, assets.map((asset) => ({
|
|
47
|
+
sha256: asset.sha256,
|
|
48
|
+
bytes: asset.bytes,
|
|
49
|
+
mime: asset.mime,
|
|
50
|
+
file_name: asset.fileName
|
|
51
|
+
}))).catch((error) => {
|
|
52
|
+
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.");
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
const bySha = new Map(resolved.map((entry) => [entry.sha256, entry]));
|
|
56
|
+
const missing = [];
|
|
57
|
+
const hosted = /* @__PURE__ */ new Map();
|
|
58
|
+
for (const asset of assets) {
|
|
59
|
+
const entry = bySha.get(asset.sha256);
|
|
60
|
+
if (!entry) throw new AssetSyncError(`Superwall did not return a URL for ${assetName(asset)} — asset sync is incomplete.`);
|
|
61
|
+
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.`);
|
|
62
|
+
hosted.set(asset.sha256, entry.url);
|
|
63
|
+
if (entry.uploadUrl !== void 0) missing.push(asset);
|
|
64
|
+
}
|
|
65
|
+
let uploadedBytes = 0;
|
|
66
|
+
await pool(missing, UPLOAD_CONCURRENCY, async (asset) => {
|
|
67
|
+
const uploadUrl = bySha.get(asset.sha256)?.uploadUrl;
|
|
68
|
+
if (uploadUrl === void 0) return;
|
|
69
|
+
const body = read(asset.path);
|
|
70
|
+
const send = () => put(uploadUrl, {
|
|
71
|
+
method: "PUT",
|
|
72
|
+
headers: {
|
|
73
|
+
"content-type": asset.mime,
|
|
74
|
+
"cache-control": CACHE_CONTROL
|
|
75
|
+
},
|
|
76
|
+
body: new Uint8Array(body)
|
|
77
|
+
});
|
|
78
|
+
let response = await send().catch(() => void 0);
|
|
79
|
+
if (!response?.ok) response = await send().catch(() => void 0);
|
|
80
|
+
if (!response?.ok) throw uploadFailure(asset, response);
|
|
81
|
+
uploadedBytes += asset.bytes;
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
assets: assets.map((asset) => ({
|
|
85
|
+
url: hosted.get(asset.sha256) ?? "",
|
|
86
|
+
mime_type: asset.mime
|
|
87
|
+
})),
|
|
88
|
+
uploaded: missing.length,
|
|
89
|
+
uploadedBytes,
|
|
90
|
+
totalBytes
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/core/paywalls/project/framework.ts
|
|
96
|
+
var FrameworkNotFoundError = class extends Error {
|
|
97
|
+
constructor(dir) {
|
|
98
|
+
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.`);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
async function importSubpath(packageDir, subpath) {
|
|
102
|
+
return import(pathToFileURL(createRequire(join(packageDir, "package.json")).resolve(subpath)).href);
|
|
103
|
+
}
|
|
104
|
+
function fn(mod, name, subpath) {
|
|
105
|
+
if (typeof mod !== "object" || mod === null) throw new Error(`superwall ${subpath} did not load as a module`);
|
|
106
|
+
const candidate = mod[name];
|
|
107
|
+
if (typeof candidate !== "function") throw new Error(`This project's superwall version does not export ${name} from ${subpath} — update the project's superwall dependency.`);
|
|
108
|
+
return candidate;
|
|
109
|
+
}
|
|
110
|
+
function resolveFrameworkDir(cwd) {
|
|
111
|
+
for (const anchor of [join(cwd, "superwall", "package.json"), join(cwd, "package.json")]) try {
|
|
112
|
+
return join(createRequire(anchor).resolve("superwall/package.json"), "..");
|
|
113
|
+
} catch {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
throw new FrameworkNotFoundError(cwd);
|
|
117
|
+
}
|
|
118
|
+
function frameworkVersion(cwd) {
|
|
119
|
+
try {
|
|
120
|
+
const parsed = JSON.parse(readFileSync(join(resolveFrameworkDir(cwd), "package.json"), "utf8"));
|
|
121
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
122
|
+
const version = parsed.version;
|
|
123
|
+
if (typeof version === "string" && version !== "") return version;
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
return "unknown";
|
|
127
|
+
}
|
|
128
|
+
return "unknown";
|
|
129
|
+
}
|
|
130
|
+
async function loadFramework(cwd) {
|
|
131
|
+
const dir = resolveFrameworkDir(cwd);
|
|
132
|
+
const [discover, build, preview] = await Promise.all([
|
|
133
|
+
importSubpath(dir, "superwall/discover"),
|
|
134
|
+
importSubpath(dir, "superwall/build"),
|
|
135
|
+
importSubpath(dir, "superwall/preview")
|
|
136
|
+
]);
|
|
137
|
+
const studioProject = typeof preview === "object" && preview !== null && typeof preview.buildStudioProject === "function" ? preview.buildStudioProject : void 0;
|
|
138
|
+
return {
|
|
139
|
+
discoverProject: fn(discover, "discoverProject", "superwall/discover"),
|
|
140
|
+
buildSnapshot: fn(build, "buildSnapshot", "superwall/build"),
|
|
141
|
+
startPreviewServer: fn(preview, "startPreviewServer", "superwall/preview"),
|
|
142
|
+
studioProject
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/core/paywalls/project/lock.ts
|
|
148
|
+
const isScreenOrigin = (origin) => "path" in origin;
|
|
149
|
+
const isFileName = (value) => typeof value === "string" && value !== "" && !/[\\/]/.test(value) && !value.startsWith(".");
|
|
150
|
+
const SCREEN_FRAMEWORKS = new Set([
|
|
151
|
+
"swiftui",
|
|
152
|
+
"uikit",
|
|
153
|
+
"compose",
|
|
154
|
+
"android-views",
|
|
155
|
+
"react-native",
|
|
156
|
+
"flutter"
|
|
157
|
+
]);
|
|
158
|
+
const readOrigin = (candidate) => {
|
|
159
|
+
if (typeof candidate.paywallId === "string" && typeof candidate.url === "string") return {
|
|
160
|
+
paywallId: candidate.paywallId,
|
|
161
|
+
url: candidate.url
|
|
162
|
+
};
|
|
163
|
+
if (typeof candidate.path === "string" && typeof candidate.framework === "string" && SCREEN_FRAMEWORKS.has(candidate.framework)) {
|
|
164
|
+
const framework = candidate.framework;
|
|
165
|
+
return isFileName(candidate.screenshot) ? {
|
|
166
|
+
path: candidate.path,
|
|
167
|
+
framework,
|
|
168
|
+
screenshot: candidate.screenshot
|
|
169
|
+
} : {
|
|
170
|
+
path: candidate.path,
|
|
171
|
+
framework
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
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.";
|
|
176
|
+
const emptyLock = () => ({
|
|
177
|
+
version: 1,
|
|
178
|
+
apps: {},
|
|
179
|
+
paywalls: {},
|
|
180
|
+
funnels: {}
|
|
181
|
+
});
|
|
182
|
+
const originKey = (kind, surfaceId) => `${kind}/${surfaceId}`;
|
|
183
|
+
const readOrigins = (value) => {
|
|
184
|
+
if (!isRecord(value)) return void 0;
|
|
185
|
+
const origins = {};
|
|
186
|
+
for (const [key, candidate] of Object.entries(value)) {
|
|
187
|
+
if (!isRecord(candidate)) continue;
|
|
188
|
+
const origin = readOrigin(candidate);
|
|
189
|
+
if (origin) origins[key] = origin;
|
|
190
|
+
}
|
|
191
|
+
return Object.keys(origins).length > 0 ? origins : void 0;
|
|
192
|
+
};
|
|
193
|
+
const lockPath = (superwallDir) => path.join(superwallDir, "superwall.lock");
|
|
194
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
195
|
+
const readBinding = (value) => {
|
|
196
|
+
if (!isRecord(value) || typeof value.paywallId !== "string") return void 0;
|
|
197
|
+
return typeof value.snapshot === "string" ? {
|
|
198
|
+
paywallId: value.paywallId,
|
|
199
|
+
snapshot: value.snapshot
|
|
200
|
+
} : { paywallId: value.paywallId };
|
|
201
|
+
};
|
|
202
|
+
const readSection = (value) => {
|
|
203
|
+
const section = {};
|
|
204
|
+
if (!isRecord(value)) return section;
|
|
205
|
+
for (const [surfaceId, entry] of Object.entries(value)) {
|
|
206
|
+
if (!isRecord(entry)) continue;
|
|
207
|
+
const bindings = {};
|
|
208
|
+
for (const [platform, candidate] of Object.entries(entry)) {
|
|
209
|
+
const binding = readBinding(candidate);
|
|
210
|
+
if (binding) bindings[platform] = binding;
|
|
211
|
+
}
|
|
212
|
+
if (Object.keys(bindings).length > 0) section[surfaceId] = bindings;
|
|
213
|
+
}
|
|
214
|
+
return section;
|
|
215
|
+
};
|
|
216
|
+
function readLock(superwallDir) {
|
|
217
|
+
const file = lockPath(superwallDir);
|
|
218
|
+
if (!fs.existsSync(file)) return emptyLock();
|
|
219
|
+
try {
|
|
220
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
221
|
+
if (!isRecord(parsed) || parsed.version !== 1) return emptyLock();
|
|
222
|
+
const lock = emptyLock();
|
|
223
|
+
if (isRecord(parsed.apps)) {
|
|
224
|
+
for (const [platform, id] of Object.entries(parsed.apps)) if (typeof id === "string") lock.apps[platform] = id;
|
|
225
|
+
}
|
|
226
|
+
lock.paywalls = readSection(parsed.paywalls);
|
|
227
|
+
lock.funnels = readSection(parsed.funnels);
|
|
228
|
+
const origins = readOrigins(parsed.origins);
|
|
229
|
+
if (origins) lock.origins = origins;
|
|
230
|
+
return lock;
|
|
231
|
+
} catch {}
|
|
232
|
+
return emptyLock();
|
|
233
|
+
}
|
|
234
|
+
function writeLock(superwallDir, lock) {
|
|
235
|
+
const annotated = {
|
|
236
|
+
"//": EXPLAINER,
|
|
237
|
+
version: lock.version,
|
|
238
|
+
apps: lock.apps,
|
|
239
|
+
paywalls: lock.paywalls,
|
|
240
|
+
funnels: lock.funnels,
|
|
241
|
+
...lock.origins && Object.keys(lock.origins).length > 0 ? { origins: lock.origins } : {}
|
|
242
|
+
};
|
|
243
|
+
fs.writeFileSync(lockPath(superwallDir), `${JSON.stringify(annotated, null, 2)}\n`);
|
|
244
|
+
}
|
|
245
|
+
function writeOrigin(superwallDir, kind, surfaceId, origin) {
|
|
246
|
+
const lock = readLock(superwallDir);
|
|
247
|
+
lock.origins = {
|
|
248
|
+
...lock.origins,
|
|
249
|
+
[originKey(kind, surfaceId)]: origin
|
|
250
|
+
};
|
|
251
|
+
writeLock(superwallDir, lock);
|
|
252
|
+
}
|
|
253
|
+
const sectionOf = (lock, kind) => kind === "paywall" ? lock.paywalls : lock.funnels;
|
|
254
|
+
function writeApp(superwallDir, platform, applicationId) {
|
|
255
|
+
const lock = readLock(superwallDir);
|
|
256
|
+
lock.apps[platform] = applicationId;
|
|
257
|
+
writeLock(superwallDir, lock);
|
|
258
|
+
}
|
|
259
|
+
function writeBinding(superwallDir, kind, surfaceId, platform, binding) {
|
|
260
|
+
const lock = readLock(superwallDir);
|
|
261
|
+
const section = sectionOf(lock, kind);
|
|
262
|
+
section[surfaceId] = {
|
|
263
|
+
...section[surfaceId],
|
|
264
|
+
[platform]: binding
|
|
265
|
+
};
|
|
266
|
+
writeLock(superwallDir, lock);
|
|
267
|
+
}
|
|
268
|
+
function writeBindings(superwallDir, kind, surfaceId, bindings) {
|
|
269
|
+
const lock = readLock(superwallDir);
|
|
270
|
+
sectionOf(lock, kind)[surfaceId] = { ...bindings };
|
|
271
|
+
writeLock(superwallDir, lock);
|
|
272
|
+
}
|
|
273
|
+
function writeSnapshot(superwallDir, kind, surfaceId, platform, snapshot) {
|
|
274
|
+
const lock = readLock(superwallDir);
|
|
275
|
+
const section = sectionOf(lock, kind);
|
|
276
|
+
const binding = section[surfaceId]?.[platform];
|
|
277
|
+
if (!binding || binding.snapshot === snapshot) return;
|
|
278
|
+
section[surfaceId] = {
|
|
279
|
+
...section[surfaceId],
|
|
280
|
+
[platform]: {
|
|
281
|
+
...binding,
|
|
282
|
+
snapshot
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
writeLock(superwallDir, lock);
|
|
286
|
+
}
|
|
287
|
+
function removeBinding(superwallDir, kind, surfaceId) {
|
|
288
|
+
const lock = readLock(superwallDir);
|
|
289
|
+
const section = sectionOf(lock, kind);
|
|
290
|
+
if (!(surfaceId in section)) return false;
|
|
291
|
+
delete section[surfaceId];
|
|
292
|
+
writeLock(superwallDir, lock);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
const describeBindings = (bindings) => {
|
|
296
|
+
const entries = Object.entries(bindings);
|
|
297
|
+
if (entries.length === 1 && entries[0] !== void 0) return `paywall ${entries[0][1].paywallId}`;
|
|
298
|
+
return `paywalls ${entries.map(([platform, binding]) => `${binding.paywallId} (${platform})`).join(", ")}`;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/core/paywalls/project/types.ts
|
|
303
|
+
const TYPES_FILE = "superwall.d.ts";
|
|
304
|
+
const SUPERSEDED = ["superwall-env.d.ts", "superwall-routes.d.ts"];
|
|
305
|
+
const HEADER = `// Generated by the Superwall CLI. Commit it; don't edit it, and don't delete it.
|
|
306
|
+
// It is what makes \`import hero from "./assets/hero.jpg"\` typecheck and what
|
|
307
|
+
// makes router.push("...") autocomplete and reject typos. \`superwall dev\`
|
|
308
|
+
// rewrites it whenever your app/ directories change.
|
|
309
|
+
|
|
310
|
+
/// <reference types="superwall/assets" />
|
|
311
|
+
`;
|
|
312
|
+
const routeBlock = (names) => [
|
|
313
|
+
"declare module \"superwall/navigation\" {",
|
|
314
|
+
" interface SuperwallRoutes {",
|
|
315
|
+
...names.map((name) => ` ${JSON.stringify(name)}: true;`),
|
|
316
|
+
" }",
|
|
317
|
+
"}",
|
|
318
|
+
"",
|
|
319
|
+
"export type SuperwallRouteName = keyof import(\"superwall/navigation\").SuperwallRoutes;"
|
|
320
|
+
].join("\n");
|
|
321
|
+
const isStripeIdentifier = (identifier) => /^(test|live):price_[^:]+/.test(identifier);
|
|
322
|
+
const productBlock = (references, stripe) => [
|
|
323
|
+
"declare module \"superwall/hooks\" {",
|
|
324
|
+
" interface SuperwallProducts {",
|
|
325
|
+
...references.map((name) => ` ${JSON.stringify(name)}: true;`),
|
|
326
|
+
" }",
|
|
327
|
+
"",
|
|
328
|
+
" interface SuperwallStripeProducts {",
|
|
329
|
+
...stripe.map((name) => ` ${JSON.stringify(name)}: true;`),
|
|
330
|
+
" }",
|
|
331
|
+
"}"
|
|
332
|
+
].join("\n");
|
|
333
|
+
const productIdsOf = (surface) => surface.productIds ?? Object.fromEntries(Object.entries(surface.products).map(([reference, id]) => [reference, [id]]));
|
|
334
|
+
const declaredPlatforms = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : void 0;
|
|
335
|
+
async function collectProjectDeclarations(framework, root) {
|
|
336
|
+
const declarations = {
|
|
337
|
+
products: {},
|
|
338
|
+
platforms: {}
|
|
339
|
+
};
|
|
340
|
+
if (!framework.studioProject) return declarations;
|
|
341
|
+
try {
|
|
342
|
+
const payload = await framework.studioProject(root);
|
|
343
|
+
for (const surface of payload.surfaces) {
|
|
344
|
+
for (const [reference, ids] of Object.entries(productIdsOf(surface))) declarations.products[reference] = [...new Set([...declarations.products[reference] ?? [], ...ids])];
|
|
345
|
+
if (typeof surface.kind === "string" && typeof surface.id === "string") declarations.platforms[`${surface.kind}/${surface.id}`] = declaredPlatforms(surface.platforms);
|
|
346
|
+
}
|
|
347
|
+
return declarations;
|
|
348
|
+
} catch {
|
|
349
|
+
return declarations;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function projectTypes(project, products = {}) {
|
|
353
|
+
const names = /* @__PURE__ */ new Set();
|
|
354
|
+
for (const surface of project.surfaces) for (const route of surface.routes) names.add(route.name);
|
|
355
|
+
const sorted = [...names].sort();
|
|
356
|
+
const sortedProducts = Object.keys(products).sort();
|
|
357
|
+
const sortedStripe = sortedProducts.filter((name) => (products[name] ?? []).some((identifier) => isStripeIdentifier(identifier)));
|
|
358
|
+
const blocks = [sorted.length > 0 ? routeBlock(sorted) : "", sortedProducts.length > 0 ? productBlock(sortedProducts, sortedStripe) : ""].filter(Boolean);
|
|
359
|
+
return blocks.length === 0 ? `${HEADER}\nexport {};\n` : `${HEADER}\n${blocks.join("\n\n")}\n`;
|
|
360
|
+
}
|
|
361
|
+
function writeProjectTypes(project, products = {}) {
|
|
362
|
+
const file = path.join(project.superwallDir, TYPES_FILE);
|
|
363
|
+
const next = projectTypes(project, products);
|
|
364
|
+
try {
|
|
365
|
+
if (!fs.existsSync(file) || fs.readFileSync(file, "utf8") !== next) fs.writeFileSync(file, next);
|
|
366
|
+
} catch {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
for (const name of SUPERSEDED) {
|
|
370
|
+
const stale = path.join(project.superwallDir, name);
|
|
371
|
+
try {
|
|
372
|
+
if (fs.readFileSync(stale, "utf8").includes("Superwall CLI")) fs.rmSync(stale);
|
|
373
|
+
} catch {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/commands/paywalls/pipeline/report.ts
|
|
381
|
+
const kb = (bytes) => `${(bytes / 1024).toFixed(1)} kB`;
|
|
382
|
+
const weight = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : kb(bytes);
|
|
383
|
+
const SHORT_SHA = 7;
|
|
384
|
+
const shortSha = (sha) => typeof sha === "string" && sha.length >= SHORT_SHA ? sha.slice(0, SHORT_SHA) : void 0;
|
|
385
|
+
function pushedLine(input) {
|
|
386
|
+
const sha = shortSha(input.snapshotId);
|
|
387
|
+
const pushed = `Pushed ${input.promoting ? `version ${input.version}` : pc.yellow(`version ${input.version}`)}${sha ? ` ${pc.dim(`(${sha})`)}` : ""}`;
|
|
388
|
+
return input.promoting || input.live === void 0 ? pushed : `${pushed} · ${pc.dim(`live ${input.live}`)}`;
|
|
389
|
+
}
|
|
390
|
+
function transition(before, after) {
|
|
391
|
+
if (before === void 0) return `Promoted ${pc.green(`version ${after}`)}`;
|
|
392
|
+
if (before === after) return `Version ${pc.green(String(after))} already live`;
|
|
393
|
+
if (after < before) return `Rolled back ${pc.green(`version ${before} → ${after}`)}`;
|
|
394
|
+
return `Promoted ${pc.green(`version ${before} → ${after}`)}`;
|
|
395
|
+
}
|
|
396
|
+
const BIND_VERB = {
|
|
397
|
+
lock: "Linked to",
|
|
398
|
+
matched: "Linked to",
|
|
399
|
+
created: "Created",
|
|
400
|
+
renamed: "Rebound after rename to"
|
|
401
|
+
};
|
|
402
|
+
const LAYOUT_HINT = "expected superwall/{paywalls,funnels}/<id>/ with config.ts and app/index.tsx";
|
|
403
|
+
const NOTE_LIMIT = 2e3;
|
|
404
|
+
const PENDING_NAMES = 10;
|
|
405
|
+
function pendingPromoteWarning(pending, multi = false) {
|
|
406
|
+
if (pending.length === 0) return void 0;
|
|
407
|
+
const entries = pending.map((entry) => typeof entry === "string" ? { id: entry } : entry);
|
|
408
|
+
const ids = [...new Set(entries.map((entry) => entry.id))];
|
|
409
|
+
const platforms = new Set(entries.flatMap((entry) => entry.platform ? [entry.platform] : []));
|
|
410
|
+
const platformFlag = multi && platforms.size === 1 ? ` --platform ${[...platforms][0]}` : "";
|
|
411
|
+
const command = `superwall promote --id ${ids.join(",")}${platformFlag}`;
|
|
412
|
+
const labels = entries.map((entry) => multi && entry.platform ? `${entry.id} · ${entry.platform}` : entry.id);
|
|
413
|
+
if (labels.length === 1) return `${labels[0]} is pushed but not live — run \`${command}\` to publish it.`;
|
|
414
|
+
const shown = labels.slice(0, PENDING_NAMES).map((label) => ` ${label}`);
|
|
415
|
+
const rest = labels.length - shown.length;
|
|
416
|
+
return [
|
|
417
|
+
`These ${labels.length} paywalls are pushed but not live:`,
|
|
418
|
+
...shown,
|
|
419
|
+
...rest > 0 ? [` …and ${rest} more`] : [],
|
|
420
|
+
"",
|
|
421
|
+
` ${command}`
|
|
422
|
+
].join("\n");
|
|
423
|
+
}
|
|
424
|
+
function resolveNote(message) {
|
|
425
|
+
if (typeof message !== "string") return void 0;
|
|
426
|
+
if (message.length > NOTE_LIMIT) throw new Error(`Publish note is ${message.length} characters (limit ${NOTE_LIMIT}).`);
|
|
427
|
+
return message;
|
|
428
|
+
}
|
|
429
|
+
const took = (since) => {
|
|
430
|
+
const seconds = (Date.now() - since) / 1e3;
|
|
431
|
+
return pc.dim(seconds < 10 ? `(${seconds.toFixed(1)}s)` : `(${Math.round(seconds)}s)`);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/commands/paywalls/pipeline/selection.ts
|
|
436
|
+
function projectDir(context) {
|
|
437
|
+
const [first] = projectDirs(context);
|
|
438
|
+
return first ?? process.cwd();
|
|
439
|
+
}
|
|
440
|
+
function projectDirs(context) {
|
|
441
|
+
const raw = context.argv.dir;
|
|
442
|
+
const list = (Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw]).filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
443
|
+
if (list.length === 0) return [process.cwd()];
|
|
444
|
+
const expanded = list.flatMap((entry) => entry.includes("*") ? expandGlob(entry) : [entry]);
|
|
445
|
+
return [...new Set(expanded.map((entry) => resolve(entry)))];
|
|
446
|
+
}
|
|
447
|
+
function expandGlob(pattern) {
|
|
448
|
+
try {
|
|
449
|
+
return [...globSync(pattern)].filter((entry) => statSync(entry, { throwIfNoEntry: false })?.isDirectory() ?? false).sort();
|
|
450
|
+
} catch {
|
|
451
|
+
return [pattern];
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function requireProject(project, dir) {
|
|
455
|
+
if (!project.marker) throw new Error(`Not a superwall project: ${dir}\nExpected a package.json here (or in superwall/) that depends on superwall.`);
|
|
456
|
+
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.`);
|
|
457
|
+
return project;
|
|
458
|
+
}
|
|
459
|
+
function parseIds(value) {
|
|
460
|
+
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);
|
|
461
|
+
}
|
|
462
|
+
function selectSurfaces(project, ids) {
|
|
463
|
+
const wanted = parseIds(ids);
|
|
464
|
+
const known = project.surfaces.map((surface) => surface.id).join(", ");
|
|
465
|
+
if (wanted.length === 0) {
|
|
466
|
+
if (project.surfaces.length === 0) throw new Error(`No paywalls or funnels found — ${LAYOUT_HINT}.`);
|
|
467
|
+
return [...project.surfaces];
|
|
468
|
+
}
|
|
469
|
+
const selected = [];
|
|
470
|
+
for (const id of wanted) {
|
|
471
|
+
const matches = project.surfaces.filter((surface$1) => surface$1.id === id);
|
|
472
|
+
if (matches.length === 0) throw new Error(`No paywall or funnel named "${id}"` + (known ? ` — this project has: ${known}.` : ` — ${LAYOUT_HINT}.`));
|
|
473
|
+
if (matches.length > 1) {
|
|
474
|
+
const kinds = matches.map((surface$1) => `${surface$1.kind}/${surface$1.id}`).join(" and ");
|
|
475
|
+
throw new Error(`"${id}" is ambiguous — this project has ${kinds}.`);
|
|
476
|
+
}
|
|
477
|
+
const surface = matches[0];
|
|
478
|
+
if (surface && !selected.includes(surface)) selected.push(surface);
|
|
479
|
+
}
|
|
480
|
+
return selected;
|
|
481
|
+
}
|
|
482
|
+
function requireClean(surfaces) {
|
|
483
|
+
const problems = surfaces.flatMap((surface) => surface.diagnostics ?? []);
|
|
484
|
+
if (problems.length === 0) return;
|
|
485
|
+
throw new Error([
|
|
486
|
+
...problems,
|
|
487
|
+
"",
|
|
488
|
+
"Publishing is immutable — fix these first, then push again."
|
|
489
|
+
].join("\n"));
|
|
490
|
+
}
|
|
491
|
+
function needsWork(built, pushed, live) {
|
|
492
|
+
return built !== pushed && built !== live;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
//#endregion
|
|
496
|
+
export { assetBaseUrl as A, writeApp as C, writeSnapshot as D, writeOrigin as E, syncAssets as M, frameworkVersion as O, removeBinding as S, writeBindings as T, collectProjectDeclarations as _, requireClean as a, isScreenOrigin as b, BIND_VERB as c, pendingPromoteWarning as d, pushedLine as f, weight as g, transition as h, projectDirs as i, requireAssets as j, loadFramework as k, LAYOUT_HINT as l, took as m, parseIds as n, requireProject as o, resolveNote as p, projectDir as r, selectSurfaces as s, needsWork as t, kb as u, writeProjectTypes as v, writeBinding as w, readLock as x, describeBindings as y };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { t as blocks } from "./output-C4o2gJ1K.js";
|
|
2
|
+
import "./telemetry-DeA1mvnT.js";
|
|
3
|
+
import "./update-B2fWIc4q.js";
|
|
4
|
+
import "./token-C0it-Xh7.js";
|
|
5
|
+
import { r as ApiError, t as defineCommand } from "./command-CMIz81Da.js";
|
|
6
|
+
import "./ui-Dy0b-9L8.js";
|
|
7
|
+
import "./scan-zKsddO72.js";
|
|
8
|
+
import "./existing-AVEfZu2A.js";
|
|
9
|
+
import "./spinner-TWa0hia6.js";
|
|
10
|
+
import "./resources-Bf9O1JNM.js";
|
|
11
|
+
import { t as requireOrg } from "./org-sj7uyvp-.js";
|
|
12
|
+
import { n as emitJson, t as apiCall } from "./api-output-aJNw7Syy.js";
|
|
13
|
+
import "./asc-Bf7zBbyS.js";
|
|
14
|
+
import { S as appleDeps, _ as chooseAppIntent, a as KEY_KINDS, b as resolveApp, c as chooseTeam, d as keyAccess, g as text, h as signIn, l as createAndSaveKey, m as savedKey, n as ensureNotificationUrl, o as KEY_LABEL, p as keyRole, r as environmentLines, s as appFlags, t as describeNotificationUrl } from "./notification-url-DuKF2659.js";
|
|
15
|
+
import { c as getIntegrations, f as saveBundleId, i as RefusedByApi } from "./scope-BvzD-kO4.js";
|
|
16
|
+
import { n as testModeWarning } from "./bundle-id-CKxl_026.js";
|
|
17
|
+
|
|
18
|
+
//#region src/commands/platform/apple.ts
|
|
19
|
+
const STEPS = [
|
|
20
|
+
...KEY_KINDS,
|
|
21
|
+
"bundle_id",
|
|
22
|
+
"notification_url"
|
|
23
|
+
];
|
|
24
|
+
const STEP_LABEL = {
|
|
25
|
+
...KEY_LABEL,
|
|
26
|
+
bundle_id: "Bundle ID",
|
|
27
|
+
notification_url: "Server notification URL"
|
|
28
|
+
};
|
|
29
|
+
async function saveAppBundleId(ctx, app) {
|
|
30
|
+
try {
|
|
31
|
+
await apiCall(ctx, `Saving the bundle ID on ${app.name}`, () => saveBundleId(ctx.api, app.applicationId, {
|
|
32
|
+
bundleId: app.bundleId,
|
|
33
|
+
replace: false
|
|
34
|
+
}));
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (!(error instanceof ApiError) && !(error instanceof RefusedByApi)) throw error;
|
|
37
|
+
ctx.output.render(blocks.warning(`${STEP_LABEL.bundle_id}: ${error.message}`));
|
|
38
|
+
return {
|
|
39
|
+
status: "failed",
|
|
40
|
+
detail: error.message
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
ctx.output.render(blocks.info(`Saved the bundle ID ${app.bundleId} on \`${app.name}\``));
|
|
44
|
+
return {
|
|
45
|
+
status: "done",
|
|
46
|
+
detail: `${app.bundleId} (saved)`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function setupApple(ctx, deps) {
|
|
50
|
+
const { api } = ctx;
|
|
51
|
+
const role = keyRole(ctx);
|
|
52
|
+
const skip = {
|
|
53
|
+
api_key: ctx.argv["skip-api-key"] === true,
|
|
54
|
+
purchase_key: ctx.argv["skip-purchase-key"] === true,
|
|
55
|
+
bundle_id: false,
|
|
56
|
+
notification_url: ctx.argv["skip-notification-url"] === true
|
|
57
|
+
};
|
|
58
|
+
const flags = appFlags(ctx);
|
|
59
|
+
ctx.output.render(blocks.intro("Set up Apple"));
|
|
60
|
+
await requireOrg(api, ctx.interactive);
|
|
61
|
+
const intent = ctx.dryRun ? void 0 : await chooseAppIntent(ctx, api, flags);
|
|
62
|
+
const session = await signIn(ctx, deps, "setup apple");
|
|
63
|
+
if (!session) return;
|
|
64
|
+
const team = await chooseTeam(ctx, session, text(ctx, "team"));
|
|
65
|
+
ctx.output.render(blocks.info(`Apple team \`${team.name}\``));
|
|
66
|
+
if (ctx.dryRun || !intent) {
|
|
67
|
+
const access = {
|
|
68
|
+
api_key: await keyAccess(ctx, session, "api_key"),
|
|
69
|
+
purchase_key: await keyAccess(ctx, session, "purchase_key")
|
|
70
|
+
};
|
|
71
|
+
if (ctx.json) return emitJson(ctx, {
|
|
72
|
+
dryRun: true,
|
|
73
|
+
team,
|
|
74
|
+
access
|
|
75
|
+
});
|
|
76
|
+
ctx.ui.report(KEY_KINDS.map((kind) => `${access[kind] === "ok" ? "✓" : "✗"} ${KEY_LABEL[kind]} ${access[kind]}`).join("\n"));
|
|
77
|
+
ctx.ui.info("[dry-run] nothing was created or changed.");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const app = await resolveApp(ctx, api, session, intent, flags);
|
|
81
|
+
const appRef = {
|
|
82
|
+
projectId: app.projectId,
|
|
83
|
+
applicationId: app.applicationId
|
|
84
|
+
};
|
|
85
|
+
ctx.output.render(blocks.info(`${app.created ? "Created" : "Using"} \`${app.name}\` ${app.bundleId}`));
|
|
86
|
+
const results = {
|
|
87
|
+
api_key: { status: "skipped" },
|
|
88
|
+
purchase_key: { status: "skipped" },
|
|
89
|
+
bundle_id: {
|
|
90
|
+
status: "done",
|
|
91
|
+
detail: app.bundleId
|
|
92
|
+
},
|
|
93
|
+
notification_url: { status: "skipped" }
|
|
94
|
+
};
|
|
95
|
+
if (app.savedBundleId === null) {
|
|
96
|
+
const warning = await testModeWarning(ctx, api, app.applicationId, app.bundleId);
|
|
97
|
+
if (warning) ctx.output.render(blocks.warning(warning));
|
|
98
|
+
}
|
|
99
|
+
const saved = await getIntegrations(api, app.applicationId);
|
|
100
|
+
let bundleIdSaved = app.savedBundleId !== null;
|
|
101
|
+
for (const kind of KEY_KINDS) {
|
|
102
|
+
if (skip[kind]) continue;
|
|
103
|
+
const existing = savedKey(saved, kind);
|
|
104
|
+
results[kind] = existing ? {
|
|
105
|
+
status: "done",
|
|
106
|
+
detail: `${existing.key_id} (already saved)`
|
|
107
|
+
} : await createAndSaveKey(ctx, deps, api, session, app, kind, role);
|
|
108
|
+
if (kind === "purchase_key" && !existing && results[kind].status === "done" && !bundleIdSaved) {
|
|
109
|
+
bundleIdSaved = true;
|
|
110
|
+
results.bundle_id = {
|
|
111
|
+
status: "done",
|
|
112
|
+
detail: `${app.bundleId} (saved with the key)`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!bundleIdSaved) results.bundle_id = await saveAppBundleId(ctx, app);
|
|
117
|
+
let notificationUrl;
|
|
118
|
+
if (!skip.notification_url) try {
|
|
119
|
+
const outcome = await ensureNotificationUrl(ctx, deps.sleep, api, appRef, { setRevenueProvider: false });
|
|
120
|
+
notificationUrl = outcome.url;
|
|
121
|
+
if (outcome.status === "set" || outcome.status === "already_set") results.notification_url = {
|
|
122
|
+
status: "done",
|
|
123
|
+
detail: outcome.status === "set" ? "set" : "already set"
|
|
124
|
+
};
|
|
125
|
+
else {
|
|
126
|
+
results.notification_url = {
|
|
127
|
+
status: "failed",
|
|
128
|
+
detail: [describeNotificationUrl(outcome), ...environmentLines(outcome)].join(" ")
|
|
129
|
+
};
|
|
130
|
+
if (!ctx.json) {
|
|
131
|
+
const shown = [describeNotificationUrl(outcome), ...environmentLines(outcome).map((line) => ` ${line}`)].join("\n");
|
|
132
|
+
ctx.ui.error(outcome.status === "conflict" ? `${shown}\nApple allows one URL per environment. To switch, clear it in App Store Connect → App Information → App Store Server Notifications, then run this again.` : shown);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (!(error instanceof ApiError) && !(error instanceof RefusedByApi)) throw error;
|
|
137
|
+
results.notification_url = {
|
|
138
|
+
status: "failed",
|
|
139
|
+
detail: error.message
|
|
140
|
+
};
|
|
141
|
+
ctx.output.render(blocks.warning(`${STEP_LABEL.notification_url}: ${error.message}`));
|
|
142
|
+
}
|
|
143
|
+
const failed = STEPS.filter((step) => results[step].status === "failed");
|
|
144
|
+
if (ctx.json) emitJson(ctx, {
|
|
145
|
+
status: failed.length === 0 ? "ok" : "partial",
|
|
146
|
+
team,
|
|
147
|
+
app: {
|
|
148
|
+
id: app.applicationId,
|
|
149
|
+
project_id: app.projectId,
|
|
150
|
+
name: app.name,
|
|
151
|
+
bundle_id: app.bundleId,
|
|
152
|
+
created: app.created
|
|
153
|
+
},
|
|
154
|
+
steps: results,
|
|
155
|
+
notification_url: notificationUrl ?? null,
|
|
156
|
+
failed
|
|
157
|
+
});
|
|
158
|
+
else {
|
|
159
|
+
const mark = {
|
|
160
|
+
done: "✓",
|
|
161
|
+
skipped: "–",
|
|
162
|
+
failed: "✗"
|
|
163
|
+
};
|
|
164
|
+
ctx.ui.report(STEPS.map((step) => {
|
|
165
|
+
const result = results[step];
|
|
166
|
+
const value = result.status === "failed" ? "not done" : result.detail ?? result.status;
|
|
167
|
+
return `${mark[result.status]} ${STEP_LABEL[step]} ${value}`;
|
|
168
|
+
}).join("\n"));
|
|
169
|
+
if (failed.length === 0) ctx.ui.success(`Apple is connected for \`${app.name}\`.`);
|
|
170
|
+
else ctx.ui.warn("Partly done. What succeeded was saved; fix the items above and run it again.");
|
|
171
|
+
}
|
|
172
|
+
if (failed.length > 0) process.exitCode = 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/commands/platform/setup.ts
|
|
177
|
+
const runSetup = defineCommand({
|
|
178
|
+
name: "setup",
|
|
179
|
+
auth: "required",
|
|
180
|
+
output: "both",
|
|
181
|
+
async run(ctx) {
|
|
182
|
+
const target = String(ctx.argv.target ?? "");
|
|
183
|
+
if (target === "apple") return setupApple(ctx, appleDeps);
|
|
184
|
+
throw new Error(`Unknown "setup ${target}". Use: setup apple`);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
export { runSetup };
|