@superwall/cli 2.5.0 → 2.6.0-beta.1
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 +7 -0
- package/dist/{apple-Dyr7OFBx.js → apple-Bmt_iywx.js} +14 -14
- package/dist/{approve-Czs1-JO9.js → approve-D2UgqaRx.js} +31 -27
- package/dist/{assets-BrB9jQPQ.js → assets-B_quADds.js} +3 -3
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/{session-D3fgXQBt.js → base-ChTi42M0.js} +35 -35
- package/dist/{billing-D5qqIlVb.js → billing-ZIETn0j4.js} +3 -3
- package/dist/{bind-B3eEcRyp.js → bind-ClFjTt0U.js} +4 -4
- package/dist/{build-DD9pSwHX.js → build-BWjXurjs.js} +11 -9
- package/dist/{client-AI9H4GGB.js → client-CyrYJzBF.js} +3 -3
- package/dist/create-7HDW3DCl.js +20 -0
- package/dist/{create-B4m-IKlr.js → create-BCIgjRHn.js} +6 -6
- package/dist/{create-ChfgWpiM.js → create-C3uklw-U.js} +31 -31
- package/dist/design-lint-CiFc78aM.js +158 -0
- package/dist/{doctor-XtXW6tKE.js → doctor-D2Q1EZe8.js} +6 -6
- package/dist/{drivers-CMEL13gp.js → drivers-BQkO5tHs.js} +3 -3
- package/dist/entry.js +20 -20
- package/dist/{environment-BWT2S4qC.js → environment-BocmdvZ-.js} +3 -3
- package/dist/{existing-b0GxFcnc.js → existing-Cl5x6_5u.js} +2 -2
- package/dist/{selection-BltBpyp5.js → framework-CLmf4swr.js} +50 -50
- package/dist/{held-D3PUNky2.js → held-Bykbwy-m.js} +6 -6
- package/dist/held-Chw3BtBV.js +17 -0
- package/dist/install-dXZZ79Oe.js +109 -0
- package/dist/{integrate-qvKd9pVW.js → integrate-DiSjlOjC.js} +23 -23
- package/dist/{types-JdxmnCko.js → lock-DgSx-p8Y.js} +79 -79
- package/dist/{login-PMoXUGqq.js → login-5sWIKDI2.js} +6 -6
- package/dist/login-DZ8Pipf6.js +17 -0
- package/dist/{login-COmGHrU5.js → login-Jp6E6d2e.js} +1 -1
- package/dist/{lookup-gjcKIZvh.js → lookup-CWzVfPpq.js} +3 -3
- package/dist/{migrate-SkkLLdmr.js → migrate-BKiOUsMY.js} +29 -29
- package/dist/{migration-DS44-3Zr.js → migration-Z69tLeHC.js} +29 -11
- package/dist/{notification-url-BjQPLf4-.js → notification-url-BDBxbwZq.js} +2 -2
- package/dist/{open-DQpm2yVs.js → open-DNd49kT-.js} +2 -2
- package/dist/{org-C04eAO-j.js → org-Dud1rF9f.js} +3 -3
- package/dist/{organization-BOECL3vZ.js → organization-7vJA3uy1.js} +8 -8
- package/dist/{orgs-D6Kk96mG.js → orgs-Z0H9WOs1.js} +1 -1
- package/dist/{paths-REb-GrbX.js → paths-CzTJVpfi.js} +1 -1
- package/dist/{playbook-Du4Oydbf.js → playbook-DJ__edOW.js} +10 -10
- package/dist/{project-CP6hiHra.js → project-NoMtbMyl.js} +9 -9
- package/dist/{promote-Dm2_b1WK.js → promote-DLtPSvmL.js} +23 -22
- package/dist/{pull-F6pvO4To.js → pull-AoUmaiMK.js} +8 -8
- package/dist/pull-C1xm2zqG.js +36 -0
- package/dist/pull-D-YuT3e0.js +106 -0
- package/dist/push-B42D8fKf.js +22 -0
- package/dist/{push-BIFLhAiO.js → push-BMblzg_6.js} +122 -22
- package/dist/{push-D_l9KJZN.js → push-BrzMFd4Z.js} +47 -47
- package/dist/push-Co5jk6Kr.js +30 -0
- package/dist/{registry-DIJB0mJa.js → registry-DDU10_Ix.js} +176 -155
- package/dist/resolve-DpOSDDdr.js +196 -0
- package/dist/{resources-BaP3p_LY.js → resources-CptT7HD6.js} +2 -2
- package/dist/{run-C5OPwhvS.js → run-c1O2_8pp.js} +2 -2
- package/dist/{run-CgLmD2vR.js → run-r3foWfhV.js} +93 -70
- package/dist/scan-D86kLtM7.js +4 -0
- package/dist/{scan-Bj5y0zTZ.js → scan-nVQO7JLx.js} +1 -1
- package/dist/{scope-CCb_7UvN.js → scope-ehZ7L1nj.js} +25 -11
- package/dist/{scope-Bp_zwJOo.js → scope-l1qGLsgz.js} +5 -5
- package/dist/{sdk-TvT0p_nO.js → sdk-DEfQttek.js} +7 -7
- package/dist/{series-TAixFBWW.js → series-D2ZpZ8cx.js} +96 -63
- package/dist/server-BEcsQaPu.js +29 -0
- package/dist/{server-CdVIboQn.js → server-DLARhh1k.js} +9 -9
- package/dist/session-Csuaw6RU.js +6 -0
- package/dist/{session-Ywim-P8M.js → session-Z0BeaJPf.js} +1 -1
- package/dist/{setup-zzjtTy8k.js → setup-C6NFy14d.js} +9 -9
- package/dist/skills/index.json +2 -2
- package/dist/skills/{superwall-workspaces → superwall-artifacts}/SKILL.md +41 -31
- package/dist/skills/{superwall-workspaces → superwall-artifacts}/references/cli.md +31 -28
- package/dist/skills/{superwall-workspaces → superwall-artifacts}/references/slots.md +9 -9
- package/dist/{skills-2qYaUXGE.js → skills-421SFEyF.js} +4 -4
- package/dist/{skills-8um2fBPS.js → skills-CdKwaTRS.js} +8 -8
- package/dist/{git-D7AVdugb.js → source-BccdO4aL.js} +111 -102
- package/dist/{source-push-kAep4gPe.js → source-push-B4s6r9bB.js} +43 -26
- package/dist/{spinner-BANVLncC.js → spinner-DPdBlZe2.js} +3 -3
- package/dist/{starter-CiLrp1cN.js → starter-0OdVPH4l.js} +27 -27
- package/dist/{status-CoYMK7QL.js → status-Dsc7d3z2.js} +42 -39
- package/dist/{storage-DzP22xKn.js → storage-DT_wxwJ8.js} +1 -1
- package/dist/{storekit-n1x0bWkQ.js → storekit-B9M2raxe.js} +3 -3
- package/dist/storekit-BWZf-fNE.js +17 -0
- package/dist/{telemetry-CXN6f-ZX.js → telemetry-ovPiseFm.js} +1 -1
- package/dist/{token-FmeHywYt.js → token-Bu3FaRkv.js} +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +148 -128
- package/dist/{try-BWbzgelb.js → try-B8FYkTvQ.js} +29 -29
- package/dist/{upgrade-Bk5boOgW.js → upgrade-B7TmvEPP.js} +2 -2
- package/dist/{upgrade-CoWCEnoi.js → upgrade-CAHyrWUL.js} +2 -2
- package/package.json +2 -2
- package/dist/create-CJljlkJK.js +0 -20
- package/dist/held-CX7Zf8u-.js +0 -17
- package/dist/install-CVUXsx8c.js +0 -103
- package/dist/login-ClnJi1Ea.js +0 -17
- package/dist/pull-DsdOoG-D.js +0 -36
- package/dist/pull-zYAbqo9n.js +0 -106
- package/dist/push-CJVfvFZq.js +0 -29
- package/dist/push-SVzv7fzE.js +0 -22
- package/dist/resolve--GsHj0Q1.js +0 -171
- package/dist/scan-v_WTE722.js +0 -4
- package/dist/server-CvJVusw3.js +0 -29
- package/dist/session-B8JNXkwN.js +0 -6
- package/dist/storekit-D5eopLM0.js +0 -17
- /package/dist/{download-2Zu2I_Og.js → download-DhGd4hOB.js} +0 -0
- /package/dist/{reports-CuhB1_ub.js → reports-HYVp169R.js} +0 -0
- /package/dist/{storage-BjQCiTuz.d.ts → storage-Bdz5AmqS.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
2
|
-
import {
|
|
3
|
-
import { a as classifyPath, c as isSurfaceRoot,
|
|
2
|
+
import { i as formatSharedLock, v as TYPES_FILE } from "./lock-DgSx-p8Y.js";
|
|
3
|
+
import { a as classifyPath, c as isSurfaceRoot, i as LOCK_FILE$1, l as mergeLockText, o as derivedFilesOf, r as DERIVED_FILES, s as isOtherSurfaceDir } from "./scope-ehZ7L1nj.js";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as os$1 from "node:os";
|
|
@@ -8,93 +8,25 @@ import * as path from "node:path";
|
|
|
8
8
|
import { promisify } from "node:util";
|
|
9
9
|
import fg from "fast-glob";
|
|
10
10
|
|
|
11
|
-
//#region src/core/paywalls/source/source.ts
|
|
12
|
-
const HARD_EXCLUDES = [
|
|
13
|
-
".superwall/**",
|
|
14
|
-
"**/node_modules/**",
|
|
15
|
-
".git/**",
|
|
16
|
-
"**/.env*",
|
|
17
|
-
"**/.DS_Store",
|
|
18
|
-
"**/.npmrc",
|
|
19
|
-
"**/.netrc",
|
|
20
|
-
"**/*.pem",
|
|
21
|
-
"**/*.p8",
|
|
22
|
-
"**/*.p12",
|
|
23
|
-
"**/*.key",
|
|
24
|
-
"**/*.keystore",
|
|
25
|
-
"**/*.jks",
|
|
26
|
-
"**/google-services.json",
|
|
27
|
-
"**/GoogleService-Info.plist"
|
|
28
|
-
];
|
|
29
|
-
const LOCK_FILE$1 = "superwall.lock";
|
|
30
|
-
const SOURCE_LIMIT_BYTES = 250 * 1024 * 1024;
|
|
31
|
-
const LARGEST_SHOWN = 3;
|
|
32
|
-
const megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
33
|
-
function gitignoreExcludes(superwallDir) {
|
|
34
|
-
let text;
|
|
35
|
-
try {
|
|
36
|
-
text = fs.readFileSync(path.join(superwallDir, ".gitignore"), "utf8");
|
|
37
|
-
} catch {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
const excludes = [];
|
|
41
|
-
for (const raw of text.split("\n")) {
|
|
42
|
-
const line = raw.trim();
|
|
43
|
-
if (line === "" || line.startsWith("#") || line.startsWith("!")) continue;
|
|
44
|
-
const anchored = line.startsWith("/");
|
|
45
|
-
const body = (anchored ? line.slice(1) : line).replace(/\/+$/, "");
|
|
46
|
-
if (body === "") continue;
|
|
47
|
-
const base = anchored || body.includes("/") ? body : `**/${body}`;
|
|
48
|
-
excludes.push(base, `${base}/**`);
|
|
49
|
-
}
|
|
50
|
-
return excludes;
|
|
51
|
-
}
|
|
52
|
-
const readFramework = (superwallDir, relative$1) => relative$1 === LOCK_FILE$1 ? Buffer.from(formatSharedLock(superwallDir)) : fs.readFileSync(path.join(superwallDir, relative$1));
|
|
53
|
-
async function collectSourceFiles(superwallDir, read = readFramework) {
|
|
54
|
-
const entries = await fg("**/*", {
|
|
55
|
-
cwd: superwallDir,
|
|
56
|
-
dot: true,
|
|
57
|
-
onlyFiles: true,
|
|
58
|
-
followSymbolicLinks: false,
|
|
59
|
-
ignore: [...HARD_EXCLUDES, ...gitignoreExcludes(superwallDir)]
|
|
60
|
-
});
|
|
61
|
-
if (entries.length === 0) return {
|
|
62
|
-
ok: false,
|
|
63
|
-
reason: `No source files found in ${superwallDir}.`
|
|
64
|
-
};
|
|
65
|
-
const sizes = entries.map((relative$1) => ({
|
|
66
|
-
path: relative$1,
|
|
67
|
-
bytes: fs.statSync(path.join(superwallDir, relative$1)).size
|
|
68
|
-
}));
|
|
69
|
-
const total = sizes.reduce((sum, entry) => sum + entry.bytes, 0);
|
|
70
|
-
if (total > SOURCE_LIMIT_BYTES) {
|
|
71
|
-
const largest = sizes.sort((a, b) => b.bytes - a.bytes).slice(0, LARGEST_SHOWN).map((entry) => `${entry.path} (${megabytes(entry.bytes)})`).join(", ");
|
|
72
|
-
return {
|
|
73
|
-
ok: false,
|
|
74
|
-
reason: `The source in ${superwallDir} is ${megabytes(total)}, over the ${SOURCE_LIMIT_BYTES / 1024 / 1024} MB limit. Largest: ${largest}. Add what doesn't belong to .gitignore, then push again.`
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
ok: true,
|
|
79
|
-
files: entries.sort().map((relative$1) => ({
|
|
80
|
-
path: relative$1,
|
|
81
|
-
content: read(superwallDir, relative$1)
|
|
82
|
-
}))
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
//#endregion
|
|
87
11
|
//#region src/core/paywalls/source/commit.ts
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
12
|
+
const noteBody = (note) => {
|
|
13
|
+
const text = note?.replace(/\r\n?/g, "\n").trim();
|
|
14
|
+
return text ? `\n${text}\n` : "";
|
|
15
|
+
};
|
|
16
|
+
const artifactCommitMessage = (input) => {
|
|
17
|
+
const surface = `artifact/${input.surface}`;
|
|
18
|
+
const trailers = [`Superwall-Artifact: ${input.artifactId}`, `Superwall-Surface: ${surface}`];
|
|
19
|
+
if (input.sdk) trailers.push(`Superwall-Artifact-Sdk: ${input.sdk}`);
|
|
92
20
|
if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
|
|
93
|
-
|
|
94
|
-
return `push ${surface}\n${note ? `\n${note}\n` : ""}\n${trailers.join("\n")}\n`;
|
|
21
|
+
return `push ${surface}\n${noteBody(input.note)}\n${trailers.join("\n")}\n`;
|
|
95
22
|
};
|
|
96
23
|
const buildCommitMessage = (input) => {
|
|
97
|
-
if (input.kind === "
|
|
24
|
+
if (input.kind === "artifact") return artifactCommitMessage(input);
|
|
25
|
+
if (input.kind === "project") {
|
|
26
|
+
const trailers$1 = [`Superwall-Application: ${input.applicationId}`, `Superwall-Framework: ${input.framework}`];
|
|
27
|
+
if (input.cli) trailers$1.push(`Superwall-Cli: ${input.cli}`);
|
|
28
|
+
return `publish project source\n${noteBody(input.note)}\n${trailers$1.join("\n")}\n`;
|
|
29
|
+
}
|
|
98
30
|
const surface = `${input.kind}/${input.surface}`;
|
|
99
31
|
const subject = `publish ${surface} v${input.version}`;
|
|
100
32
|
const external = (input.external ?? []).filter((entry) => entry.trim() !== "");
|
|
@@ -109,8 +41,7 @@ const buildCommitMessage = (input) => {
|
|
|
109
41
|
if (input.snapshotSha) trailers.push(`Superwall-Snapshot: ${input.snapshotSha}`);
|
|
110
42
|
trailers.push(`Superwall-Framework: ${input.framework}`);
|
|
111
43
|
if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
|
|
112
|
-
|
|
113
|
-
return `${subject}\n${note ? `\n${note}\n` : ""}\n${trailers.join("\n")}\n`;
|
|
44
|
+
return `${subject}\n${noteBody(input.note)}\n${trailers.join("\n")}\n`;
|
|
114
45
|
};
|
|
115
46
|
const tokenSecret = (token) => token.split("?")[0] ?? token;
|
|
116
47
|
const redact = (text, ...secrets) => {
|
|
@@ -228,12 +159,12 @@ function materializeSourceTree(dir, files, scope, options = {}) {
|
|
|
228
159
|
for (const file of files) {
|
|
229
160
|
if (classifyPath(file.path, scope) === "other") continue;
|
|
230
161
|
if (file.content.byteLength > LARGE_FILE_BYTES) large.push(file.path);
|
|
231
|
-
if (file.path === LOCK_FILE && scope.kind !== "
|
|
162
|
+
if (file.path === LOCK_FILE$1 && scope.kind !== "artifact") write(file.path, mergeLockText(theirs.get(LOCK_FILE$1)?.toString("utf8"), file.content.toString("utf8"), scope, { replaceUnreadable: options.overwrite }));
|
|
232
163
|
else write(file.path, file.content);
|
|
233
164
|
theirs.delete(file.path);
|
|
234
165
|
}
|
|
235
166
|
for (const [derived, content] of theirs) write(derived, content);
|
|
236
|
-
if (large.length > 0) ui.warn(`Committing ${large.length > 1 ? `${large.length} files` : large[0]} over 50 MB — every future clone of this ${scope.kind === "
|
|
167
|
+
if (large.length > 0) ui.warn(`Committing ${large.length > 1 ? `${large.length} files` : large[0]} over 50 MB — every future clone of this ${scope.kind === "artifact" ? "artifact's" : "app's"} source repo pays for it.`);
|
|
237
168
|
}
|
|
238
169
|
const SHOWN_FILES = 5;
|
|
239
170
|
const listFiles = (files) => {
|
|
@@ -241,15 +172,16 @@ const listFiles = (files) => {
|
|
|
241
172
|
const rest = files.length - SHOWN_FILES;
|
|
242
173
|
return rest > 0 ? `${shown} and ${rest} more` : shown;
|
|
243
174
|
};
|
|
175
|
+
const replaced = (kind) => kind === "project" ? "the project's shared files" : "this paywall's source";
|
|
244
176
|
var SourceConflictError = class extends Error {
|
|
245
177
|
constructor(files, kind = "paywall") {
|
|
246
|
-
super(kind === "
|
|
178
|
+
super(kind === "artifact" ? `Someone else pushed changes to ${listFiles(files)} since this project last synced. Run \`superwall artifacts pull\` to bring their changes into this project, then push again, or rerun with --overwrite-source to replace this artifact's source with yours.` : `Someone else published changes to ${listFiles(files)} since this project last synced. Run \`superwall pull\` to bring their changes into this project, then publish again — or rerun with --overwrite-source to replace ${replaced(kind)} with yours.`);
|
|
247
179
|
this.files = files;
|
|
248
180
|
}
|
|
249
181
|
};
|
|
250
182
|
var SourceDivergedError = class extends Error {
|
|
251
183
|
constructor(files, kind = "paywall") {
|
|
252
|
-
super(kind === "
|
|
184
|
+
super(kind === "artifact" ? `The source repo differs from this project in ${listFiles(files)}, and this project records no sync point to merge from. Run \`superwall artifacts pull\` to merge the source repo into this project, then push again, or rerun with --overwrite-source to replace this artifact's source with yours.` : `The source repo differs from this project in ${listFiles(files)}, and superwall.lock records no sync point to merge from. Run \`superwall pull\` to merge the source repo into this project, then publish again — or rerun with --overwrite-source to replace ${replaced(kind)} with yours.`);
|
|
253
185
|
this.files = files;
|
|
254
186
|
}
|
|
255
187
|
};
|
|
@@ -316,7 +248,7 @@ async function pushSourceTree(input) {
|
|
|
316
248
|
env,
|
|
317
249
|
secrets
|
|
318
250
|
});
|
|
319
|
-
const scope = {
|
|
251
|
+
const scope = input.message.kind === "project" ? { kind: "project" } : {
|
|
320
252
|
kind: input.message.kind,
|
|
321
253
|
id: input.message.surface
|
|
322
254
|
};
|
|
@@ -332,8 +264,9 @@ async function pushSourceTree(input) {
|
|
|
332
264
|
fs.writeFileSync(messageFile, buildCommitMessage(input.message));
|
|
333
265
|
const onRemote = head !== void 0 && !base;
|
|
334
266
|
const local = onRemote ? await snapshotLocal(run$1, dir, input.files, scope, head, committing) : void 0;
|
|
267
|
+
const unsynced = onRemote && scope.kind === "project";
|
|
335
268
|
materializeSourceTree(dir, input.files, scope, {
|
|
336
|
-
onRemote: onRemote && scope.kind !== "
|
|
269
|
+
onRemote: onRemote && scope.kind !== "artifact",
|
|
337
270
|
overwrite: input.overwrite
|
|
338
271
|
});
|
|
339
272
|
await run$1(["add", "-A"]);
|
|
@@ -343,7 +276,7 @@ async function pushSourceTree(input) {
|
|
|
343
276
|
return finished({
|
|
344
277
|
commitSha: head ?? "",
|
|
345
278
|
status: "unchanged",
|
|
346
|
-
syncedTo: base ?? head
|
|
279
|
+
syncedTo: unsynced ? void 0 : base ?? head
|
|
347
280
|
});
|
|
348
281
|
}
|
|
349
282
|
if (onRemote && !input.overwrite) {
|
|
@@ -381,7 +314,7 @@ async function pushSourceTree(input) {
|
|
|
381
314
|
], { env: committing });
|
|
382
315
|
const own = await revParse("HEAD");
|
|
383
316
|
if (!own) throw new Error("The source commit was not created.");
|
|
384
|
-
const syncedTo = local ?? own;
|
|
317
|
+
const syncedTo = unsynced ? void 0 : local ?? own;
|
|
385
318
|
const status = dirty === "" ? "unchanged" : "committed";
|
|
386
319
|
const isAncestor = (ancestor, of) => run$1([
|
|
387
320
|
"merge-base",
|
|
@@ -566,12 +499,12 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
|
|
|
566
499
|
}
|
|
567
500
|
if (!merging) return;
|
|
568
501
|
const show = (ref, file) => run$1(["show", `${ref}:${file}`]).then((text) => text, () => void 0);
|
|
569
|
-
if (scope.kind !== "
|
|
570
|
-
const theirsLock = await show(upstream, LOCK_FILE);
|
|
571
|
-
const mineLock = await show(own, LOCK_FILE);
|
|
572
|
-
await settle(run$1, dir, LOCK_FILE, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
|
|
502
|
+
if (scope.kind !== "artifact") {
|
|
503
|
+
const theirsLock = await show(upstream, LOCK_FILE$1);
|
|
504
|
+
const mineLock = await show(own, LOCK_FILE$1);
|
|
505
|
+
await settle(run$1, dir, LOCK_FILE$1, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
|
|
573
506
|
}
|
|
574
|
-
for (const file of derived) if (file !== LOCK_FILE) await settle(run$1, dir, file, await show(own, file));
|
|
507
|
+
for (const file of derived) if (file !== LOCK_FILE$1) await settle(run$1, dir, file, await show(own, file));
|
|
575
508
|
await run$1([
|
|
576
509
|
"commit",
|
|
577
510
|
"--quiet",
|
|
@@ -732,7 +665,7 @@ async function pullSourceTree(input) {
|
|
|
732
665
|
status: "pulled",
|
|
733
666
|
head,
|
|
734
667
|
changes,
|
|
735
|
-
lock: await shown(LOCK_FILE),
|
|
668
|
+
lock: await shown(LOCK_FILE$1),
|
|
736
669
|
types: await shown(TYPES_FILE)
|
|
737
670
|
};
|
|
738
671
|
} finally {
|
|
@@ -757,4 +690,80 @@ function replaceTree(dir, files) {
|
|
|
757
690
|
const isRejected = (error) => error instanceof GitError && /rejected|non-fast-forward|fetch first|stale info|failed to push some refs/i.test(error.message);
|
|
758
691
|
|
|
759
692
|
//#endregion
|
|
760
|
-
|
|
693
|
+
//#region src/core/paywalls/source/source.ts
|
|
694
|
+
const HARD_EXCLUDES = [
|
|
695
|
+
".superwall/**",
|
|
696
|
+
"**/node_modules/**",
|
|
697
|
+
".git/**",
|
|
698
|
+
"**/.env*",
|
|
699
|
+
"**/.DS_Store",
|
|
700
|
+
"**/.npmrc",
|
|
701
|
+
"**/.netrc",
|
|
702
|
+
"**/*.pem",
|
|
703
|
+
"**/*.p8",
|
|
704
|
+
"**/*.p12",
|
|
705
|
+
"**/*.key",
|
|
706
|
+
"**/*.keystore",
|
|
707
|
+
"**/*.jks",
|
|
708
|
+
"**/google-services.json",
|
|
709
|
+
"**/GoogleService-Info.plist"
|
|
710
|
+
];
|
|
711
|
+
const LOCK_FILE = "superwall.lock";
|
|
712
|
+
const SOURCE_LIMIT_BYTES = 250 * 1024 * 1024;
|
|
713
|
+
const LARGEST_SHOWN = 3;
|
|
714
|
+
const megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
715
|
+
function gitignoreExcludes(superwallDir) {
|
|
716
|
+
let text;
|
|
717
|
+
try {
|
|
718
|
+
text = fs.readFileSync(path.join(superwallDir, ".gitignore"), "utf8");
|
|
719
|
+
} catch {
|
|
720
|
+
return [];
|
|
721
|
+
}
|
|
722
|
+
const excludes = [];
|
|
723
|
+
for (const raw of text.split("\n")) {
|
|
724
|
+
const line = raw.trim();
|
|
725
|
+
if (line === "" || line.startsWith("#") || line.startsWith("!")) continue;
|
|
726
|
+
const anchored = line.startsWith("/");
|
|
727
|
+
const body = (anchored ? line.slice(1) : line).replace(/\/+$/, "");
|
|
728
|
+
if (body === "") continue;
|
|
729
|
+
const base = anchored || body.includes("/") ? body : `**/${body}`;
|
|
730
|
+
excludes.push(base, `${base}/**`);
|
|
731
|
+
}
|
|
732
|
+
return excludes;
|
|
733
|
+
}
|
|
734
|
+
const readFramework = (superwallDir, relative$1) => relative$1 === LOCK_FILE ? Buffer.from(formatSharedLock(superwallDir)) : fs.readFileSync(path.join(superwallDir, relative$1));
|
|
735
|
+
async function collectSourceFiles(superwallDir, read = readFramework) {
|
|
736
|
+
const entries = await fg("**/*", {
|
|
737
|
+
cwd: superwallDir,
|
|
738
|
+
dot: true,
|
|
739
|
+
onlyFiles: true,
|
|
740
|
+
followSymbolicLinks: false,
|
|
741
|
+
ignore: [...HARD_EXCLUDES, ...gitignoreExcludes(superwallDir)]
|
|
742
|
+
});
|
|
743
|
+
if (entries.length === 0) return {
|
|
744
|
+
ok: false,
|
|
745
|
+
reason: `No source files found in ${superwallDir}.`
|
|
746
|
+
};
|
|
747
|
+
const sizes = entries.map((relative$1) => ({
|
|
748
|
+
path: relative$1,
|
|
749
|
+
bytes: fs.statSync(path.join(superwallDir, relative$1)).size
|
|
750
|
+
}));
|
|
751
|
+
const total = sizes.reduce((sum, entry) => sum + entry.bytes, 0);
|
|
752
|
+
if (total > SOURCE_LIMIT_BYTES) {
|
|
753
|
+
const largest = sizes.sort((a, b) => b.bytes - a.bytes).slice(0, LARGEST_SHOWN).map((entry) => `${entry.path} (${megabytes(entry.bytes)})`).join(", ");
|
|
754
|
+
return {
|
|
755
|
+
ok: false,
|
|
756
|
+
reason: `The source in ${superwallDir} is ${megabytes(total)}, over the ${SOURCE_LIMIT_BYTES / 1024 / 1024} MB limit. Largest: ${largest}. Add what doesn't belong to .gitignore, then push again.`
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
ok: true,
|
|
761
|
+
files: entries.sort().map((relative$1) => ({
|
|
762
|
+
path: relative$1,
|
|
763
|
+
content: read(superwallDir, relative$1)
|
|
764
|
+
}))
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
//#endregion
|
|
769
|
+
export { statIfPresent as a, pushSourceTree as i, gitAvailable as n, pullSourceTree as r, collectSourceFiles as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as ApiUnreachableError, t as ApiError } from "./client-
|
|
1
|
+
import { n as ApiUnreachableError, t as ApiError } from "./client-CyrYJzBF.js";
|
|
2
2
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
3
|
-
import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-
|
|
4
|
-
import { n as findApplication } from "./lookup-
|
|
5
|
-
import { f as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-CptT7HD6.js";
|
|
4
|
+
import { n as findApplication } from "./lookup-CWzVfPpq.js";
|
|
5
|
+
import { f as writeBinding, l as readLock } from "./lock-DgSx-p8Y.js";
|
|
6
|
+
import { n as writeSourceBase, t as readSourceBase } from "./base-ChTi42M0.js";
|
|
7
|
+
import { i as pushSourceTree, n as gitAvailable } from "./source-BccdO4aL.js";
|
|
8
8
|
import { setTimeout } from "node:timers/promises";
|
|
9
9
|
import { productVariables } from "@superwall/studio/products";
|
|
10
10
|
|
|
@@ -155,28 +155,35 @@ var GitRequiredError = class extends Error {
|
|
|
155
155
|
async function assertGit(hasGit = gitAvailable) {
|
|
156
156
|
if (!await hasGit()) throw new GitRequiredError();
|
|
157
157
|
}
|
|
158
|
+
async function syncSource(input, message) {
|
|
159
|
+
const access = await mintSourceAccess(input.api, input.paywallId);
|
|
160
|
+
const pushed = await pushSourceTree({
|
|
161
|
+
access,
|
|
162
|
+
base: readSourceBase(input.superwallDir, access.repo),
|
|
163
|
+
overwrite: input.overwrite,
|
|
164
|
+
files: input.files,
|
|
165
|
+
message
|
|
166
|
+
});
|
|
167
|
+
if (pushed.syncedTo) writeSourceBase(input.superwallDir, access.repo, pushed.syncedTo);
|
|
168
|
+
return {
|
|
169
|
+
access,
|
|
170
|
+
pushed
|
|
171
|
+
};
|
|
172
|
+
}
|
|
158
173
|
async function pushSource(input) {
|
|
159
174
|
for (let attempt = 0;; attempt++) {
|
|
160
|
-
const access = await
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
applicationId: input.applicationId,
|
|
172
|
-
snapshotSha: input.snapshotId,
|
|
173
|
-
framework: input.framework,
|
|
174
|
-
cli: input.cli,
|
|
175
|
-
note: input.note,
|
|
176
|
-
external: input.external
|
|
177
|
-
}
|
|
175
|
+
const { access, pushed } = await syncSource(input, {
|
|
176
|
+
kind: input.kind,
|
|
177
|
+
surface: input.surface,
|
|
178
|
+
version: input.version,
|
|
179
|
+
paywallId: input.paywallId,
|
|
180
|
+
applicationId: input.applicationId,
|
|
181
|
+
snapshotSha: input.snapshotId,
|
|
182
|
+
framework: input.framework,
|
|
183
|
+
cli: input.cli,
|
|
184
|
+
note: input.note,
|
|
185
|
+
external: input.external
|
|
178
186
|
});
|
|
179
|
-
if (pushed.syncedTo) writeSourceBase(input.superwallDir, access.repo, pushed.syncedTo);
|
|
180
187
|
try {
|
|
181
188
|
await linkCommit(input, access, pushed.commitSha);
|
|
182
189
|
return pushed;
|
|
@@ -186,6 +193,16 @@ async function pushSource(input) {
|
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
195
|
}
|
|
196
|
+
async function pushProjectSource(input) {
|
|
197
|
+
const { pushed } = await syncSource(input, {
|
|
198
|
+
kind: "project",
|
|
199
|
+
applicationId: input.applicationId,
|
|
200
|
+
framework: input.framework,
|
|
201
|
+
cli: input.cli,
|
|
202
|
+
note: input.note
|
|
203
|
+
});
|
|
204
|
+
return pushed;
|
|
205
|
+
}
|
|
189
206
|
const LINK_ATTEMPTS = 2;
|
|
190
207
|
const LINK_RETRY_DELAY_MS = 300;
|
|
191
208
|
async function linkCommit(input, access, commitSha) {
|
|
@@ -203,4 +220,4 @@ async function linkCommit(input, access, commitSha) {
|
|
|
203
220
|
const isTransient = (error) => error instanceof ApiUnreachableError || error instanceof ApiError && error.status >= 500;
|
|
204
221
|
|
|
205
222
|
//#endregion
|
|
206
|
-
export {
|
|
223
|
+
export { listApplicationCatalogue as a, projectForApplication as c, warnNotPortable as i, requireProducts as l, pushProjectSource as n, listProjectCatalogue as o, pushSource as r, listProjectProducts as s, assertGit as t, resolveBinding as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as NotLoggedInError } from "./token-
|
|
1
|
+
import { r as NotLoggedInError } from "./token-Bu3FaRkv.js";
|
|
2
2
|
import { i as writeJson, n as createCommandOutput } from "./output-Ggzq5_-t.js";
|
|
3
|
-
import { s as CHANNEL } from "./environment-
|
|
4
|
-
import { t as ApiError } from "./client-
|
|
3
|
+
import { s as CHANNEL } from "./environment-BocmdvZ-.js";
|
|
4
|
+
import { t as ApiError } from "./client-CyrYJzBF.js";
|
|
5
5
|
import { n as ui, r as useRenderer } from "./ui-D_qf3Gvw.js";
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as compareVersions, r as vendoredVersion, t as STARTER_DIR } from "./sdk-
|
|
1
|
+
import { n as MANIFEST_FILE, o as readManifest, r as VENDORED_SDK, t as ArtifactError } from "./project-NoMtbMyl.js";
|
|
2
|
+
import { i as downloadRepoDir, n as PUBLIC_REPO, r as RepoDownloadError } from "./download-DhGd4hOB.js";
|
|
3
|
+
import { n as compareVersions, r as vendoredVersion, t as STARTER_DIR } from "./sdk-DEfQttek.js";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as os$1 from "node:os";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { promisify } from "node:util";
|
|
9
9
|
|
|
10
|
-
//#region src/core/
|
|
10
|
+
//#region src/core/artifacts/starter.ts
|
|
11
11
|
const run = promisify(execFile);
|
|
12
12
|
const npmInstall = async (root) => {
|
|
13
13
|
await run("npm", [
|
|
@@ -20,7 +20,7 @@ const npmInstall = async (root) => {
|
|
|
20
20
|
timeout: 3e5
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
const packageNameOf = (dir) => path.basename(dir).toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "my-
|
|
23
|
+
const packageNameOf = (dir) => path.basename(dir).toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "my-artifact";
|
|
24
24
|
const titleOf = (name) => {
|
|
25
25
|
const words = name.split("-").join(" ");
|
|
26
26
|
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
@@ -43,14 +43,14 @@ function adoptStarter(target, name) {
|
|
|
43
43
|
for (const entrypoint of value.entrypoints ?? []) if (entrypoint.slot === "org.page@1") entrypoint.title = titleOf(name);
|
|
44
44
|
});
|
|
45
45
|
const wrangler = path.join(target, "wrangler.jsonc");
|
|
46
|
-
fs.writeFileSync(wrangler, fs.readFileSync(wrangler, "utf8").replace("superwall-
|
|
46
|
+
fs.writeFileSync(wrangler, fs.readFileSync(wrangler, "utf8").replace("superwall-artifact-starter", name));
|
|
47
47
|
}
|
|
48
|
-
async function
|
|
49
|
-
const target = path.resolve(input.dir ?? "my-
|
|
48
|
+
async function runArtifactCreate(ctx, input, runtime = {}) {
|
|
49
|
+
const target = path.resolve(input.dir ?? "my-artifact");
|
|
50
50
|
const existed = fs.existsSync(target);
|
|
51
|
-
if (existed && !fs.statSync(target).isDirectory()) throw new
|
|
52
|
-
if (existed && fs.readdirSync(target).length > 0) throw new
|
|
53
|
-
ctx.ui.intro("New
|
|
51
|
+
if (existed && !fs.statSync(target).isDirectory()) throw new ArtifactError(`${target} is a file. Pick an empty directory.`);
|
|
52
|
+
if (existed && fs.readdirSync(target).length > 0) throw new ArtifactError(`${target} already has files in it. Pick an empty directory.`);
|
|
53
|
+
ctx.ui.intro("New artifact");
|
|
54
54
|
const spin = ctx.ui.spinner();
|
|
55
55
|
spin.start(`Downloading the starter from github.com/${PUBLIC_REPO}`);
|
|
56
56
|
try {
|
|
@@ -84,14 +84,14 @@ async function runWorkspaceCreate(ctx, input, runtime = {}) {
|
|
|
84
84
|
const next = [
|
|
85
85
|
`cd ${path.relative(process.cwd(), target) || "."}`,
|
|
86
86
|
...installed ? [] : ["npm install"],
|
|
87
|
-
"superwall
|
|
87
|
+
"superwall artifacts dev"
|
|
88
88
|
];
|
|
89
89
|
ctx.ui.note(next.join("\n"), "Next");
|
|
90
90
|
}
|
|
91
91
|
async function downloadSdk(fetchImpl) {
|
|
92
|
-
const stage = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-
|
|
92
|
+
const stage = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-artifact-sdk-"));
|
|
93
93
|
try {
|
|
94
|
-
await downloadRepoDir(`${STARTER_DIR}/vendor/
|
|
94
|
+
await downloadRepoDir(`${STARTER_DIR}/vendor/artifact-sdk`, stage, `No artifact SDK at ${STARTER_DIR} in github.com/${PUBLIC_REPO}. Update the CLI with \`superwall upgrade\`.`, fetchImpl);
|
|
95
95
|
return {
|
|
96
96
|
stage,
|
|
97
97
|
version: readStageVersion(stage)
|
|
@@ -107,7 +107,7 @@ async function downloadSdk(fetchImpl) {
|
|
|
107
107
|
function replaceDirectory(stage, target, rename = fs.renameSync) {
|
|
108
108
|
const parent = path.dirname(target);
|
|
109
109
|
fs.mkdirSync(parent, { recursive: true });
|
|
110
|
-
const incoming = fs.mkdtempSync(path.join(parent, ".
|
|
110
|
+
const incoming = fs.mkdtempSync(path.join(parent, ".artifact-sdk-new-"));
|
|
111
111
|
const outgoing = `${incoming}-old`;
|
|
112
112
|
fs.cpSync(stage, incoming, { recursive: true });
|
|
113
113
|
const hadTarget = fs.existsSync(target);
|
|
@@ -130,39 +130,39 @@ function replaceDirectory(stage, target, rename = fs.renameSync) {
|
|
|
130
130
|
function pointPackageAtSdk(file) {
|
|
131
131
|
const text = fs.readFileSync(file, "utf8");
|
|
132
132
|
const parsed = JSON.parse(text);
|
|
133
|
-
if (parsed.dependencies?.["@superwall/
|
|
133
|
+
if (parsed.dependencies?.["@superwall/artifact-sdk"] === "file:vendor/artifact-sdk") return;
|
|
134
134
|
parsed.dependencies = {
|
|
135
135
|
...parsed.dependencies,
|
|
136
|
-
"@superwall/
|
|
136
|
+
"@superwall/artifact-sdk": "file:vendor/artifact-sdk"
|
|
137
137
|
};
|
|
138
138
|
const indent = /^([ \t]+)"/m.exec(text)?.[1] ?? " ";
|
|
139
139
|
fs.writeFileSync(file, `${JSON.stringify(parsed, null, indent)}${text.endsWith("\n") ? "\n" : ""}`);
|
|
140
140
|
}
|
|
141
141
|
function readStageVersion(stage) {
|
|
142
142
|
const { version } = JSON.parse(fs.readFileSync(path.join(stage, "package.json"), "utf8"));
|
|
143
|
-
if (typeof version !== "string") throw new RepoDownloadError("The downloaded
|
|
143
|
+
if (typeof version !== "string") throw new RepoDownloadError("The downloaded artifact SDK has no version.");
|
|
144
144
|
return version;
|
|
145
145
|
}
|
|
146
|
-
async function
|
|
146
|
+
async function runArtifactUpdate(ctx, input, runtime = {}) {
|
|
147
147
|
const root = path.resolve(input.dir ?? process.cwd());
|
|
148
148
|
readManifest(root);
|
|
149
149
|
const packageFile = path.join(root, "package.json");
|
|
150
|
-
if (!fs.existsSync(packageFile)) throw new
|
|
150
|
+
if (!fs.existsSync(packageFile)) throw new ArtifactError(`No package.json in ${root}, so nothing was changed. An artifact needs one to depend on the SDK.`);
|
|
151
151
|
const before = vendoredVersion(root);
|
|
152
152
|
const spin = ctx.ui.spinner();
|
|
153
|
-
spin.start("Downloading the
|
|
153
|
+
spin.start("Downloading the artifact SDK");
|
|
154
154
|
let downloaded;
|
|
155
155
|
try {
|
|
156
156
|
downloaded = await downloadSdk(runtime.fetch ?? fetch);
|
|
157
157
|
} catch (error) {
|
|
158
|
-
spin.stop("The
|
|
158
|
+
spin.stop("The artifact SDK didn't download");
|
|
159
159
|
throw error;
|
|
160
160
|
}
|
|
161
161
|
const { stage, version } = downloaded;
|
|
162
162
|
try {
|
|
163
163
|
if (before !== void 0 && compareVersions(before, version) > 0 && !input.force) {
|
|
164
164
|
spin.stop(`Yours is newer than the latest published one, ${version}`);
|
|
165
|
-
ctx.ui.warn(`Left
|
|
165
|
+
ctx.ui.warn(`Left artifact SDK ${before} alone. Pass --force to replace it with ${version}.`);
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
replaceDirectory(stage, path.join(root, VENDORED_SDK), runtime.rename);
|
|
@@ -172,19 +172,19 @@ async function runWorkspaceUpdate(ctx, input, runtime = {}) {
|
|
|
172
172
|
force: true
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
spin.stop(before === version ? `Already on the latest
|
|
175
|
+
spin.stop(before === version ? `Already on the latest artifact SDK, ${version}` : `Artifact SDK ${version}`);
|
|
176
176
|
pointPackageAtSdk(packageFile);
|
|
177
177
|
if (!input.install) {
|
|
178
|
-
ctx.ui.info("Run `npm install` to update package-lock.json, then commit vendor/
|
|
178
|
+
ctx.ui.info("Run `npm install` to update package-lock.json, then commit vendor/artifact-sdk and the lockfile.");
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
try {
|
|
182
182
|
await (runtime.install ?? npmInstall)(root);
|
|
183
|
-
ctx.ui.success("Updated package-lock.json. Commit vendor/
|
|
183
|
+
ctx.ui.success("Updated package-lock.json. Commit vendor/artifact-sdk and the lockfile.");
|
|
184
184
|
} catch {
|
|
185
185
|
ctx.ui.warn("`npm install` failed. Run it yourself to update package-lock.json.");
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
//#endregion
|
|
190
|
-
export {
|
|
190
|
+
export { runArtifactCreate, runArtifactUpdate };
|