flypod 0.15.0 → 0.16.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 +73 -13
- package/dist/bin/deploy.js +595 -244
- package/dist/{cli-xrnr1hed.js → cli-8h0vc7g2.js} +145 -16
- package/dist/src/cli/commands.d.ts +14 -0
- package/dist/src/cli/errors.d.ts +1 -0
- package/dist/src/cli/limits.d.ts +7 -0
- package/dist/src/cli/projects.d.ts +25 -1
- package/dist/src/cli/receipt.d.ts +10 -0
- package/dist/src/cli.d.ts +38 -2
- package/dist/src/cli.js +7 -1
- package/dist/src/ingest-error.d.ts +23 -0
- package/dist/src/ui.d.ts +27 -0
- package/dist/src/upload-limits.d.ts +25 -0
- package/package.json +9 -9
package/dist/bin/deploy.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
BUILD_DIR_CANDIDATES,
|
|
3
4
|
DeployError,
|
|
4
5
|
atomicWriteFile,
|
|
5
6
|
clearSession,
|
|
6
|
-
|
|
7
|
+
collectFiles,
|
|
7
8
|
createClient,
|
|
8
9
|
deploySite,
|
|
9
10
|
installSkill,
|
|
@@ -12,14 +13,37 @@ import {
|
|
|
12
13
|
resolveCredentials,
|
|
13
14
|
resolveDeployDir,
|
|
14
15
|
saveSession
|
|
15
|
-
} from "../cli-
|
|
16
|
+
} from "../cli-8h0vc7g2.js";
|
|
16
17
|
|
|
17
18
|
// bin/deploy.ts
|
|
18
|
-
import { readFile as readFile2 } from "node:fs/promises";
|
|
19
|
+
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
19
20
|
import { homedir } from "node:os";
|
|
20
21
|
import { relative } from "node:path";
|
|
21
22
|
import { fileURLToPath } from "node:url";
|
|
22
23
|
|
|
24
|
+
// src/upload-limits.ts
|
|
25
|
+
var HOSTED_UPLOAD_LIMITS = {
|
|
26
|
+
maxFiles: 200,
|
|
27
|
+
maxTotalBytes: 10 * 1024 * 1024,
|
|
28
|
+
maxZipBytes: 12 * 1024 * 1024
|
|
29
|
+
};
|
|
30
|
+
function uploadLimitsFor(baseUrl) {
|
|
31
|
+
try {
|
|
32
|
+
const host = new URL(baseUrl).hostname;
|
|
33
|
+
return host === "flypod.dev" || host.endsWith(".flypod.dev") ? HOSTED_UPLOAD_LIMITS : null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function storedZipBytes(files) {
|
|
39
|
+
const encoder = new TextEncoder;
|
|
40
|
+
let total = 22;
|
|
41
|
+
for (const [name, bytes] of Object.entries(files)) {
|
|
42
|
+
total += 76 + 2 * encoder.encode(name).byteLength + bytes.byteLength;
|
|
43
|
+
}
|
|
44
|
+
return total;
|
|
45
|
+
}
|
|
46
|
+
|
|
23
47
|
// src/cli/screen.ts
|
|
24
48
|
var WIDTH = 66;
|
|
25
49
|
var GUTTER = 10;
|
|
@@ -137,13 +161,13 @@ async function readServerMessage(res) {
|
|
|
137
161
|
try {
|
|
138
162
|
const body = JSON.parse(text);
|
|
139
163
|
const message = typeof body.error === "string" ? body.error : typeof body.message === "string" ? body.message : text;
|
|
140
|
-
return { message, code: typeof body.code === "string" ? body.code : undefined };
|
|
164
|
+
return { message, code: typeof body.code === "string" ? body.code : undefined, json: true };
|
|
141
165
|
} catch {
|
|
142
166
|
return { message: text.length > 200 ? `${text.slice(0, 200)}…` : text };
|
|
143
167
|
}
|
|
144
168
|
}
|
|
145
169
|
async function classifyResponse(res, ctx) {
|
|
146
|
-
const { message, code: serverCode } = await readServerMessage(res);
|
|
170
|
+
const { message, code: serverCode, json } = await readServerMessage(res);
|
|
147
171
|
const status = res.status;
|
|
148
172
|
const site = ctx.siteId ? ` ${ctx.siteId}` : "";
|
|
149
173
|
const base = { status, error: message };
|
|
@@ -166,7 +190,15 @@ async function classifyResponse(res, ctx) {
|
|
|
166
190
|
switch (status) {
|
|
167
191
|
case 401:
|
|
168
192
|
case 403:
|
|
169
|
-
if (
|
|
193
|
+
if (!json && message !== `HTTP ${status}`) {
|
|
194
|
+
return {
|
|
195
|
+
...base,
|
|
196
|
+
code: "network",
|
|
197
|
+
error: `Something between this machine and the server refused the request (HTTP ${status}): ${message}`,
|
|
198
|
+
fix: "Check the proxy or firewall settings (and DEPLOY_URL, if set), then retry."
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (serverCode === "blocked") {
|
|
170
202
|
return {
|
|
171
203
|
...base,
|
|
172
204
|
code: "blocked",
|
|
@@ -199,7 +231,7 @@ async function classifyResponse(res, ctx) {
|
|
|
199
231
|
return {
|
|
200
232
|
...base,
|
|
201
233
|
code: "too_large",
|
|
202
|
-
error:
|
|
234
|
+
error: /^upload too large\.?$/i.test(message) ? "The upload is larger than the server accepts." : `The server refused the upload: ${message}.`,
|
|
203
235
|
fix: "Shrink the build (fewer files, smaller assets) or split it. See flypod.dev/limits."
|
|
204
236
|
};
|
|
205
237
|
case 429:
|
|
@@ -264,6 +296,149 @@ function unexpectedError(e) {
|
|
|
264
296
|
return { code: "unexpected", error: `unexpected error: ${reason}` };
|
|
265
297
|
}
|
|
266
298
|
|
|
299
|
+
// src/ui.ts
|
|
300
|
+
var ESC = "\x1B[";
|
|
301
|
+
function envBool(name) {
|
|
302
|
+
const v = process.env[name];
|
|
303
|
+
return v !== undefined && v !== "" && v !== "0" && v !== "false";
|
|
304
|
+
}
|
|
305
|
+
function colorsEnabled(stream = process.stderr) {
|
|
306
|
+
if (envBool("NO_COLOR"))
|
|
307
|
+
return false;
|
|
308
|
+
if (envBool("FORCE_COLOR"))
|
|
309
|
+
return true;
|
|
310
|
+
return Boolean(stream.isTTY);
|
|
311
|
+
}
|
|
312
|
+
var FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
313
|
+
function paint(open, s) {
|
|
314
|
+
return `${ESC}${open}m${s}${ESC}0m`;
|
|
315
|
+
}
|
|
316
|
+
function makeStyle(enabled) {
|
|
317
|
+
if (!enabled) {
|
|
318
|
+
const id2 = (s) => s;
|
|
319
|
+
return { dim: id2, bold: id2, accent: id2, ok: id2, err: id2, warn: id2, muted: id2 };
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
dim: (s) => paint("2", s),
|
|
323
|
+
bold: (s) => paint("1", s),
|
|
324
|
+
accent: (s) => paint("38;5;191", s),
|
|
325
|
+
ok: (s) => paint("38;5;120", s),
|
|
326
|
+
err: (s) => paint("38;5;203", s),
|
|
327
|
+
warn: (s) => paint("38;5;221", s),
|
|
328
|
+
muted: (s) => paint("38;5;245", s)
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function makeSpinner(stream = process.stderr, style = makeStyle(false)) {
|
|
332
|
+
const tty = Boolean(stream.isTTY);
|
|
333
|
+
let timer;
|
|
334
|
+
let frame = 0;
|
|
335
|
+
let label = "";
|
|
336
|
+
let started = false;
|
|
337
|
+
const writeFrame = () => {
|
|
338
|
+
stream.write(`\r${ESC}2K ${style.accent(FRAMES[frame] ?? "·")} ${label}`);
|
|
339
|
+
};
|
|
340
|
+
const clearLine = () => {
|
|
341
|
+
if (tty)
|
|
342
|
+
stream.write(`\r${ESC}2K`);
|
|
343
|
+
};
|
|
344
|
+
return {
|
|
345
|
+
start(text) {
|
|
346
|
+
label = text;
|
|
347
|
+
started = true;
|
|
348
|
+
if (tty) {
|
|
349
|
+
writeFrame();
|
|
350
|
+
timer = setInterval(() => {
|
|
351
|
+
frame = (frame + 1) % FRAMES.length;
|
|
352
|
+
writeFrame();
|
|
353
|
+
}, 80);
|
|
354
|
+
} else {
|
|
355
|
+
stream.write(` ${style.dim("·")} ${label}
|
|
356
|
+
`);
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
update(text) {
|
|
360
|
+
label = text;
|
|
361
|
+
if (!started)
|
|
362
|
+
return;
|
|
363
|
+
if (tty)
|
|
364
|
+
writeFrame();
|
|
365
|
+
else
|
|
366
|
+
stream.write(` ${style.dim("·")} ${label}
|
|
367
|
+
`);
|
|
368
|
+
},
|
|
369
|
+
success(text) {
|
|
370
|
+
clearLine();
|
|
371
|
+
stream.write(` ${style.ok("✓")} ${text}
|
|
372
|
+
`);
|
|
373
|
+
this.stop();
|
|
374
|
+
},
|
|
375
|
+
fail(text) {
|
|
376
|
+
clearLine();
|
|
377
|
+
stream.write(` ${style.err("✗")} ${text}
|
|
378
|
+
`);
|
|
379
|
+
this.stop();
|
|
380
|
+
},
|
|
381
|
+
stop() {
|
|
382
|
+
if (started)
|
|
383
|
+
clearLine();
|
|
384
|
+
if (timer)
|
|
385
|
+
clearInterval(timer);
|
|
386
|
+
timer = undefined;
|
|
387
|
+
started = false;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function fmtBytes(n) {
|
|
392
|
+
if (n < 1024)
|
|
393
|
+
return `${n} B`;
|
|
394
|
+
if (n < 1024 * 1024)
|
|
395
|
+
return `${(n / 1024).toFixed(n < 10 * 1024 ? 1 : 0)} KB`;
|
|
396
|
+
return `${(n / (1024 * 1024)).toFixed(n < 10 * 1024 * 1024 ? 2 : 1)} MB`;
|
|
397
|
+
}
|
|
398
|
+
function fmtSeconds(ms) {
|
|
399
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
400
|
+
}
|
|
401
|
+
function fmtCount(n, singular) {
|
|
402
|
+
return `${n} ${singular}${n === 1 ? "" : "s"}`;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/cli/limits.ts
|
|
406
|
+
function checkUploadSize(files, limits) {
|
|
407
|
+
if (!limits)
|
|
408
|
+
return null;
|
|
409
|
+
const names = Object.keys(files);
|
|
410
|
+
const fix = "Remove or shrink the largest files (or list them in a .flypodignore), then deploy again.";
|
|
411
|
+
if (names.length > limits.maxFiles) {
|
|
412
|
+
return {
|
|
413
|
+
code: "too_large",
|
|
414
|
+
error: `This build has ${names.length} files; flypod accepts at most ${limits.maxFiles} per deploy.`,
|
|
415
|
+
fix: "Deploy only the build output, or list what the site does not need in a .flypodignore.",
|
|
416
|
+
extra: { files: names.length, limit_files: limits.maxFiles }
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
const total = names.reduce((sum, n) => sum + (files[n]?.byteLength ?? 0), 0);
|
|
420
|
+
const zipped = storedZipBytes(files);
|
|
421
|
+
const overTotal = total > limits.maxTotalBytes;
|
|
422
|
+
const overZip = zipped > limits.maxZipBytes;
|
|
423
|
+
if (!overTotal && !overZip)
|
|
424
|
+
return null;
|
|
425
|
+
const largest = names.map((name) => ({ path: name, bytes: files[name]?.byteLength ?? 0 })).sort((a, b) => b.bytes - a.bytes).slice(0, 3);
|
|
426
|
+
const listed = largest.map((f) => `${f.path} (${fmtBytes(f.bytes)})`).join(", ");
|
|
427
|
+
const limit = overZip ? limits.maxZipBytes : limits.maxTotalBytes;
|
|
428
|
+
const what = overZip ? "upload" : "site";
|
|
429
|
+
return {
|
|
430
|
+
code: "too_large",
|
|
431
|
+
error: `This build is ${fmtBytes(overZip ? zipped : total)}; flypod accepts at most ${fmtBytes(limit)} per ${what}. Largest files: ${listed}.`,
|
|
432
|
+
fix,
|
|
433
|
+
extra: {
|
|
434
|
+
bytes: total,
|
|
435
|
+
upload_bytes: zipped,
|
|
436
|
+
limit_bytes: limit,
|
|
437
|
+
largest
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
267
442
|
// src/cli/projects.ts
|
|
268
443
|
import { readFile } from "node:fs/promises";
|
|
269
444
|
var MAX_PROJECTS = 64;
|
|
@@ -308,15 +483,36 @@ async function saveProjects(projects, env) {
|
|
|
308
483
|
`);
|
|
309
484
|
return path;
|
|
310
485
|
}
|
|
486
|
+
var DETACHED_PREFIX = "detached:";
|
|
487
|
+
function holdsOnlyCredential(rec) {
|
|
488
|
+
return rec.expires_at !== null && typeof rec.manage_token === "string";
|
|
489
|
+
}
|
|
311
490
|
async function linkProject(dir, rec, env) {
|
|
312
491
|
const projects = await loadProjects(env);
|
|
492
|
+
const previous = projects[dir];
|
|
493
|
+
if (previous && previous.site_id !== rec.site_id && holdsOnlyCredential(previous)) {
|
|
494
|
+
projects[`${DETACHED_PREFIX}${previous.site_id}`] = previous;
|
|
495
|
+
}
|
|
313
496
|
projects[dir] = rec;
|
|
497
|
+
delete projects[`${DETACHED_PREFIX}${rec.site_id}`];
|
|
314
498
|
await saveProjects(projects, env);
|
|
315
499
|
}
|
|
316
500
|
async function projectForDir(dir, env) {
|
|
317
501
|
const projects = await loadProjects(env);
|
|
318
502
|
return projects[dir] ?? null;
|
|
319
503
|
}
|
|
504
|
+
async function projectForSite(site_id, env) {
|
|
505
|
+
const projects = await loadProjects(env);
|
|
506
|
+
let detached = null;
|
|
507
|
+
for (const [key, rec] of Object.entries(projects)) {
|
|
508
|
+
if (rec.site_id !== site_id)
|
|
509
|
+
continue;
|
|
510
|
+
if (!key.startsWith(DETACHED_PREFIX))
|
|
511
|
+
return rec;
|
|
512
|
+
detached = rec;
|
|
513
|
+
}
|
|
514
|
+
return detached;
|
|
515
|
+
}
|
|
320
516
|
async function forgetDir(dir, env) {
|
|
321
517
|
const projects = await loadProjects(env);
|
|
322
518
|
if (!(dir in projects))
|
|
@@ -439,6 +635,17 @@ function relinkNotice(prev, style) {
|
|
|
439
635
|
` ${s.bold("flypod update")}${s.dim(" ships there. This run makes a second site.")}`
|
|
440
636
|
];
|
|
441
637
|
}
|
|
638
|
+
function skippedRows(skipped, style) {
|
|
639
|
+
if (skipped.length === 0)
|
|
640
|
+
return [];
|
|
641
|
+
const s = style ?? PLAIN;
|
|
642
|
+
const shown = skipped.slice(0, 5).map((e) => e.path);
|
|
643
|
+
const more = skipped.length > shown.length ? `, and ${skipped.length - shown.length} more` : "";
|
|
644
|
+
const links = skipped.some((e) => e.reason.includes("symlink"));
|
|
645
|
+
const body = `${shown.join(", ")}${more}. ` + (links ? "Secrets, version control and dependencies never upload; links that point outside the folder (or nowhere) are not followed. " : "Secrets, version control and dependencies never upload. ") + "List more in a .flypodignore.";
|
|
646
|
+
const n = skipped.length;
|
|
647
|
+
return notice(`Left out ${n} path${n === 1 ? "" : "s"}`, body, s);
|
|
648
|
+
}
|
|
442
649
|
function unsavedLinkNotice(opts, style) {
|
|
443
650
|
const s = style ?? PLAIN;
|
|
444
651
|
return [
|
|
@@ -579,21 +786,57 @@ Flags:
|
|
|
579
786
|
-h, --help Show this help.`,
|
|
580
787
|
logout: `flypod logout [--json]
|
|
581
788
|
|
|
582
|
-
Forget the saved session token. Doesn't affect the server
|
|
789
|
+
Forget the saved session token. Doesn't affect the server.
|
|
790
|
+
|
|
791
|
+
Flags:
|
|
792
|
+
--json Emit JSON on stdout.
|
|
793
|
+
-h, --help Show this help.`,
|
|
583
794
|
list: `flypod list [--json]
|
|
584
795
|
|
|
585
796
|
List sites you own (requires login or FLYPOD_TOKEN). Outputs JSON on stdout —
|
|
586
|
-
{"ok":true,"sites":[]} when there are none yet
|
|
797
|
+
{"ok":true,"sites":[]} when there are none yet.
|
|
798
|
+
|
|
799
|
+
Flags:
|
|
800
|
+
--json Emit JSON on stdout.
|
|
801
|
+
-h, --help Show this help.`,
|
|
587
802
|
claim: `flypod claim <site_id> <claim_token> [--json]
|
|
588
803
|
|
|
589
|
-
Attach an anonymous deploy to your account (requires login or FLYPOD_TOKEN).
|
|
804
|
+
Attach an anonymous deploy to your account (requires login or FLYPOD_TOKEN).
|
|
805
|
+
Outputs JSON on stdout. 'flypod login' is the easier path: it keeps every
|
|
806
|
+
site this machine remembers.
|
|
807
|
+
|
|
808
|
+
Flags:
|
|
809
|
+
--json Emit JSON on stdout.
|
|
810
|
+
-h, --help Show this help.`,
|
|
811
|
+
install: `flypod install skill [targets] [flags]
|
|
812
|
+
|
|
813
|
+
Teach your coding agents (Claude Code, Codex, Cursor, …) how to deploy with
|
|
814
|
+
flypod by writing an Agent Skill into .claude/skills/ and .agents/skills/.
|
|
815
|
+
|
|
816
|
+
Targets (default: all, or a picker in a terminal):
|
|
817
|
+
--claude .claude/skills/flypod/ (Claude Code)
|
|
818
|
+
--agents .agents/skills/flypod/ (Codex, Cursor, Gemini CLI, Copilot)
|
|
819
|
+
|
|
820
|
+
Flags:
|
|
821
|
+
--global Install into your home directory instead of this project.
|
|
822
|
+
--list Show where each target would go, and write nothing.
|
|
823
|
+
--dry-run Print the files that would be written, and write nothing.
|
|
824
|
+
--all Write every target without the picker.
|
|
825
|
+
-y, --yes Same as --all: never prompt (for scripts and agents).
|
|
826
|
+
-h, --help Show this help.`
|
|
590
827
|
};
|
|
591
|
-
function
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
io.err(help);
|
|
828
|
+
function emitHelp(text, args, io) {
|
|
829
|
+
if (args.json)
|
|
830
|
+
io.out(JSON.stringify({ ok: true, help: text }));
|
|
595
831
|
else
|
|
596
|
-
io.
|
|
832
|
+
io.out(text);
|
|
833
|
+
return 0;
|
|
834
|
+
}
|
|
835
|
+
function subcommandHelp(name) {
|
|
836
|
+
return SUBCOMMAND_HELP[name];
|
|
837
|
+
}
|
|
838
|
+
function showSubHelp(name, io, args = {}) {
|
|
839
|
+
return emitHelp(SUBCOMMAND_HELP[name] ?? `No help available for "${name}". Run \`flypod --help\` for usage.`, args, io);
|
|
597
840
|
}
|
|
598
841
|
var POLL_MAX_ATTEMPTS = 120;
|
|
599
842
|
async function pollDeviceToken(client, deviceCode) {
|
|
@@ -613,6 +856,30 @@ async function pollDeviceToken(client, deviceCode) {
|
|
|
613
856
|
return { state: "expired" };
|
|
614
857
|
return { state: "error", res };
|
|
615
858
|
}
|
|
859
|
+
async function verifyToken(accessToken, baseUrl, args, io, env) {
|
|
860
|
+
const client = await createClient({
|
|
861
|
+
env,
|
|
862
|
+
fetch: io.fetch,
|
|
863
|
+
overrides: { token: accessToken, baseUrl }
|
|
864
|
+
});
|
|
865
|
+
let res;
|
|
866
|
+
try {
|
|
867
|
+
res = await client.listSites();
|
|
868
|
+
} catch (e) {
|
|
869
|
+
return emitError(networkError(e, baseUrl), args, io, { prefix: "flypod login" });
|
|
870
|
+
}
|
|
871
|
+
if (res.ok)
|
|
872
|
+
return null;
|
|
873
|
+
if (res.status === 401 || res.status === 403 || res.status === 404) {
|
|
874
|
+
return fail("token_rejected", res.status === 404 ? "This server has no accounts, so a session token cannot be used with it. Nothing was saved." : "The server did not accept that token. Nothing was saved.", args, io, {
|
|
875
|
+
status: res.status,
|
|
876
|
+
fix: "Run `flypod login` to sign in with the browser, or check the token and try again."
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
return emitError(await classifyResponse(res, { verb: "flypod login" }), args, io, {
|
|
880
|
+
prefix: "flypod login"
|
|
881
|
+
});
|
|
882
|
+
}
|
|
616
883
|
async function finishLogin(accessToken, baseUrl, args, io, env) {
|
|
617
884
|
await saveSession({ session_token: accessToken, base_url: baseUrl, created_at: Date.now() }, env);
|
|
618
885
|
if (!args.json)
|
|
@@ -623,13 +890,14 @@ async function finishLogin(accessToken, baseUrl, args, io, env) {
|
|
|
623
890
|
return 0;
|
|
624
891
|
}
|
|
625
892
|
async function login(args, io) {
|
|
626
|
-
if (args.help)
|
|
627
|
-
showSubHelp("login", io);
|
|
628
|
-
return 0;
|
|
629
|
-
}
|
|
893
|
+
if (args.help)
|
|
894
|
+
return showSubHelp("login", io, args);
|
|
630
895
|
const env = io.env ?? process.env;
|
|
631
896
|
const baseUrl = resolveCredentials(env, null).baseUrl;
|
|
632
897
|
if (args.token) {
|
|
898
|
+
const refused = await verifyToken(args.token, baseUrl, args, io, env);
|
|
899
|
+
if (refused !== null)
|
|
900
|
+
return refused;
|
|
633
901
|
return finishLogin(args.token, baseUrl, args, io, env);
|
|
634
902
|
}
|
|
635
903
|
const client = await createClient({ env, fetch: io.fetch, overrides: { baseUrl } });
|
|
@@ -767,7 +1035,10 @@ async function attachAnonymousSites(apiKey, baseUrl, args, io, env) {
|
|
|
767
1035
|
for (const [dir, rec] of candidates) {
|
|
768
1036
|
if (attached.has(rec.site_id)) {
|
|
769
1037
|
const { manage_token: _dead, ...owned } = rec;
|
|
770
|
-
|
|
1038
|
+
if (dir.startsWith(DETACHED_PREFIX))
|
|
1039
|
+
delete projects[dir];
|
|
1040
|
+
else
|
|
1041
|
+
projects[dir] = { ...owned, expires_at: null };
|
|
771
1042
|
}
|
|
772
1043
|
}
|
|
773
1044
|
await saveProjects(projects, env);
|
|
@@ -782,6 +1053,8 @@ async function attachAnonymousSites(apiKey, baseUrl, args, io, env) {
|
|
|
782
1053
|
return { attached: [...attached], skipped };
|
|
783
1054
|
}
|
|
784
1055
|
async function logout(args, io) {
|
|
1056
|
+
if (args.help)
|
|
1057
|
+
return showSubHelp("logout", io, args);
|
|
785
1058
|
const env = io.env ?? process.env;
|
|
786
1059
|
const ok = await clearSession(env);
|
|
787
1060
|
if (args.json) {
|
|
@@ -795,6 +1068,8 @@ async function logout(args, io) {
|
|
|
795
1068
|
return 0;
|
|
796
1069
|
}
|
|
797
1070
|
async function list(args, io) {
|
|
1071
|
+
if (args.help)
|
|
1072
|
+
return showSubHelp("list", io, args);
|
|
798
1073
|
const env = io.env ?? process.env;
|
|
799
1074
|
const client = await createClient({ env, fetch: io.fetch });
|
|
800
1075
|
if (!client.token)
|
|
@@ -819,6 +1094,8 @@ async function list(args, io) {
|
|
|
819
1094
|
return 0;
|
|
820
1095
|
}
|
|
821
1096
|
async function claim(args, io) {
|
|
1097
|
+
if (args.help)
|
|
1098
|
+
return showSubHelp("claim", io, args);
|
|
822
1099
|
const env = io.env ?? process.env;
|
|
823
1100
|
const client = await createClient({ env, fetch: io.fetch });
|
|
824
1101
|
if (!client.token)
|
|
@@ -842,7 +1119,10 @@ async function claim(args, io) {
|
|
|
842
1119
|
for (const [dir, r] of Object.entries(projects)) {
|
|
843
1120
|
if (r.site_id === body.site_id && (r.expires_at !== null || r.manage_token)) {
|
|
844
1121
|
const { manage_token: _dead, ...owned } = r;
|
|
845
|
-
|
|
1122
|
+
if (dir.startsWith(DETACHED_PREFIX))
|
|
1123
|
+
delete projects[dir];
|
|
1124
|
+
else
|
|
1125
|
+
projects[dir] = { ...owned, expires_at: null };
|
|
846
1126
|
changed = true;
|
|
847
1127
|
}
|
|
848
1128
|
}
|
|
@@ -860,17 +1140,17 @@ async function claim(args, io) {
|
|
|
860
1140
|
}
|
|
861
1141
|
async function resolveTarget(args, io) {
|
|
862
1142
|
const env = io.env ?? process.env;
|
|
863
|
-
if (args.site)
|
|
864
|
-
|
|
1143
|
+
if (args.site) {
|
|
1144
|
+
const known = await projectForSite(args.site, env).catch(() => null);
|
|
1145
|
+
return { site_id: args.site, rec: known, dir: null };
|
|
1146
|
+
}
|
|
865
1147
|
const cwd = io.cwd ?? process.cwd();
|
|
866
1148
|
const rec = await projectForDir(cwd, env);
|
|
867
1149
|
return rec ? { site_id: rec.site_id, rec, dir: cwd } : null;
|
|
868
1150
|
}
|
|
869
1151
|
async function withTarget(name, args, io) {
|
|
870
|
-
if (args.help)
|
|
871
|
-
showSubHelp(name, io);
|
|
872
|
-
return 0;
|
|
873
|
-
}
|
|
1152
|
+
if (args.help)
|
|
1153
|
+
return showSubHelp(name, io, args);
|
|
874
1154
|
const env = io.env ?? process.env;
|
|
875
1155
|
const target = await resolveTarget(args, io);
|
|
876
1156
|
if (!target)
|
|
@@ -925,12 +1205,21 @@ async function update(args, io) {
|
|
|
925
1205
|
return emitError(noBuildDir(e.message), args, io);
|
|
926
1206
|
}
|
|
927
1207
|
let files;
|
|
1208
|
+
let skipped;
|
|
928
1209
|
try {
|
|
929
|
-
files = await
|
|
1210
|
+
({ files, skipped } = await collectFiles(dir));
|
|
930
1211
|
} catch (e) {
|
|
931
1212
|
return fail("no_files", `Could not read ${dir}: ${e.message}`, args, io);
|
|
932
1213
|
}
|
|
1214
|
+
if (Object.keys(files).length === 0) {
|
|
1215
|
+
return fail("no_files", `No files to deploy in ${dir}.`, args, io, {
|
|
1216
|
+
fix: "Build the site first, then deploy the output folder."
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
933
1219
|
const client = await clientForTarget(target, args, io);
|
|
1220
|
+
const tooLarge = checkUploadSize(files, uploadLimitsFor(client.baseUrl));
|
|
1221
|
+
if (tooLarge)
|
|
1222
|
+
return emitError(tooLarge, args, io, { prefix: "flypod update" });
|
|
934
1223
|
let res;
|
|
935
1224
|
try {
|
|
936
1225
|
res = await client.redeploy(target.site_id, packDeploy(files));
|
|
@@ -953,6 +1242,7 @@ async function update(args, io) {
|
|
|
953
1242
|
healed: body.healed ?? [],
|
|
954
1243
|
warnings: body.warnings ?? [],
|
|
955
1244
|
expires_at: expiresAt,
|
|
1245
|
+
...skipped.length > 0 ? { skipped } : {},
|
|
956
1246
|
...switched ?? {},
|
|
957
1247
|
...(args.verbose ? agentNext : agentNextCommands)({
|
|
958
1248
|
siteId: target.site_id,
|
|
@@ -966,6 +1256,8 @@ async function update(args, io) {
|
|
|
966
1256
|
io.out(body.url);
|
|
967
1257
|
return 0;
|
|
968
1258
|
}
|
|
1259
|
+
for (const line of skippedRows(skipped, io.style))
|
|
1260
|
+
io.err(line);
|
|
969
1261
|
for (const line of updateScreen({
|
|
970
1262
|
versionId: body.version_id,
|
|
971
1263
|
url: body.url,
|
|
@@ -1101,7 +1393,7 @@ async function rollback(args, io) {
|
|
|
1101
1393
|
}
|
|
1102
1394
|
} else {
|
|
1103
1395
|
if (vers.length < 2) {
|
|
1104
|
-
return fail("no_such_version", "Only one version exists — nothing to roll back to.", args, io);
|
|
1396
|
+
return fail("no_such_version", "Only one version exists — nothing to roll back to.", args, io, { fix: "Ship a change with `flypod update` first; rollback needs a second version." });
|
|
1105
1397
|
}
|
|
1106
1398
|
const liveIdx = vers.findIndex((v) => v.version_id === live_version_id);
|
|
1107
1399
|
if (liveIdx <= 0) {
|
|
@@ -1144,10 +1436,8 @@ async function rollback(args, io) {
|
|
|
1144
1436
|
return 0;
|
|
1145
1437
|
}
|
|
1146
1438
|
async function token(args, io) {
|
|
1147
|
-
if (args.help)
|
|
1148
|
-
showSubHelp("token", io);
|
|
1149
|
-
return 0;
|
|
1150
|
-
}
|
|
1439
|
+
if (args.help)
|
|
1440
|
+
return showSubHelp("token", io, args);
|
|
1151
1441
|
const env = io.env ?? process.env;
|
|
1152
1442
|
const record = args.site ? Object.values(await loadProjects(env)).find((p) => p.site_id === args.site) : await projectForDir(io.cwd ?? process.cwd(), env);
|
|
1153
1443
|
if (!record) {
|
|
@@ -1170,10 +1460,8 @@ async function token(args, io) {
|
|
|
1170
1460
|
return 0;
|
|
1171
1461
|
}
|
|
1172
1462
|
async function forget(args, io) {
|
|
1173
|
-
if (args.help)
|
|
1174
|
-
showSubHelp("forget", io);
|
|
1175
|
-
return 0;
|
|
1176
|
-
}
|
|
1463
|
+
if (args.help)
|
|
1464
|
+
return showSubHelp("forget", io, args);
|
|
1177
1465
|
const env = io.env ?? process.env;
|
|
1178
1466
|
if (args.site) {
|
|
1179
1467
|
const n = await forgetSite(args.site, env);
|
|
@@ -1204,6 +1492,7 @@ function parseFlags(argv, spec) {
|
|
|
1204
1492
|
const flags = {};
|
|
1205
1493
|
const positionals = [];
|
|
1206
1494
|
const unknown = [];
|
|
1495
|
+
const missing = [];
|
|
1207
1496
|
let terminated = false;
|
|
1208
1497
|
for (let i = 0;i < argv.length; i++) {
|
|
1209
1498
|
const a = argv[i];
|
|
@@ -1226,10 +1515,12 @@ function parseFlags(argv, spec) {
|
|
|
1226
1515
|
}
|
|
1227
1516
|
const kind = spec[a];
|
|
1228
1517
|
if (kind === "value") {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1518
|
+
const next = argv[i + 1];
|
|
1519
|
+
if (next !== undefined && !(next.startsWith("-") && next.length > 1)) {
|
|
1520
|
+
flags[a] = next;
|
|
1521
|
+
i++;
|
|
1522
|
+
} else
|
|
1523
|
+
missing.push(a);
|
|
1233
1524
|
continue;
|
|
1234
1525
|
}
|
|
1235
1526
|
if (kind === "bool") {
|
|
@@ -1241,7 +1532,82 @@ function parseFlags(argv, spec) {
|
|
|
1241
1532
|
else
|
|
1242
1533
|
positionals.push(a);
|
|
1243
1534
|
}
|
|
1244
|
-
return { flags, positionals, unknown };
|
|
1535
|
+
return { flags, positionals, unknown, missing };
|
|
1536
|
+
}
|
|
1537
|
+
function editDistance(a, b) {
|
|
1538
|
+
let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
1539
|
+
for (let i = 1;i <= a.length; i++) {
|
|
1540
|
+
const cur = [i];
|
|
1541
|
+
for (let j = 1;j <= b.length; j++) {
|
|
1542
|
+
cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
1543
|
+
}
|
|
1544
|
+
prev = cur;
|
|
1545
|
+
}
|
|
1546
|
+
return prev[b.length];
|
|
1547
|
+
}
|
|
1548
|
+
function closest(word, candidates, maxDistance = 2) {
|
|
1549
|
+
let best;
|
|
1550
|
+
let bestDistance = maxDistance + 1;
|
|
1551
|
+
for (const c of candidates) {
|
|
1552
|
+
const d = editDistance(word, c);
|
|
1553
|
+
if (d < bestDistance) {
|
|
1554
|
+
best = c;
|
|
1555
|
+
bestDistance = d;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
return best;
|
|
1559
|
+
}
|
|
1560
|
+
function flagProblem(parsed, spec, helpCmd) {
|
|
1561
|
+
const missing = parsed.missing[0];
|
|
1562
|
+
if (missing) {
|
|
1563
|
+
return {
|
|
1564
|
+
code: "usage",
|
|
1565
|
+
error: `${missing} needs a value`,
|
|
1566
|
+
fix: `Pass it as \`${missing} <${valueName(missing)}>\` (or \`${missing}=<value>\` for a value that starts with -).`
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
const unknown = parsed.unknown[0];
|
|
1570
|
+
if (unknown) {
|
|
1571
|
+
const name = unknown.includes("=") && unknown.startsWith("--") ? unknown.split("=")[0] : unknown;
|
|
1572
|
+
const known = Object.keys(spec).filter((f) => f.startsWith("--"));
|
|
1573
|
+
const guess = name?.startsWith("--") ? closest(name, known) : undefined;
|
|
1574
|
+
return {
|
|
1575
|
+
code: "unknown_flag",
|
|
1576
|
+
error: guess ? `unknown flag "${unknown}" — did you mean ${guess}?` : `unknown flag "${unknown}"`,
|
|
1577
|
+
fix: guess ? `Use ${guess}. Run \`${helpCmd}\` for usage.` : `Run \`${helpCmd}\` for usage.`
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
return null;
|
|
1581
|
+
}
|
|
1582
|
+
function valueName(flag) {
|
|
1583
|
+
const names = {
|
|
1584
|
+
"--site": "id",
|
|
1585
|
+
"--token": "token",
|
|
1586
|
+
"--mode": "mode",
|
|
1587
|
+
"--device-code": "code",
|
|
1588
|
+
"--passcode": "passcode",
|
|
1589
|
+
"--page": "path",
|
|
1590
|
+
"--target": "json",
|
|
1591
|
+
"--body": "text",
|
|
1592
|
+
"--limit": "n"
|
|
1593
|
+
};
|
|
1594
|
+
return names[flag] ?? "value";
|
|
1595
|
+
}
|
|
1596
|
+
function firstPositionalIndex(argv, spec) {
|
|
1597
|
+
for (let i = 0;i < argv.length; i++) {
|
|
1598
|
+
const a = argv[i];
|
|
1599
|
+
if (a === "--")
|
|
1600
|
+
return i + 1 < argv.length ? i + 1 : -1;
|
|
1601
|
+
if (spec[a] === "value") {
|
|
1602
|
+
const next = argv[i + 1];
|
|
1603
|
+
if (next !== undefined && !(next.startsWith("-") && next.length > 1))
|
|
1604
|
+
i++;
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
if (!a.startsWith("-") || a === "-")
|
|
1608
|
+
return i;
|
|
1609
|
+
}
|
|
1610
|
+
return -1;
|
|
1245
1611
|
}
|
|
1246
1612
|
|
|
1247
1613
|
// src/cli/comments.ts
|
|
@@ -1452,8 +1818,6 @@ var COMMENTS_FLAG_SPEC = {
|
|
|
1452
1818
|
"--page": "value",
|
|
1453
1819
|
"--target": "value",
|
|
1454
1820
|
"--body": "value",
|
|
1455
|
-
"--url": "value",
|
|
1456
|
-
"--secret": "value",
|
|
1457
1821
|
"--passcode": "value",
|
|
1458
1822
|
"--limit": "value",
|
|
1459
1823
|
"--open": "bool",
|
|
@@ -1464,19 +1828,18 @@ var COMMENTS_FLAG_SPEC = {
|
|
|
1464
1828
|
"--help": "bool"
|
|
1465
1829
|
};
|
|
1466
1830
|
function parseCommentFlags(tail) {
|
|
1467
|
-
const { flags, positionals, unknown } = parseFlags(tail, COMMENTS_FLAG_SPEC);
|
|
1831
|
+
const { flags, positionals, unknown, missing } = parseFlags(tail, COMMENTS_FLAG_SPEC);
|
|
1468
1832
|
const limitRaw = flags["--limit"];
|
|
1469
1833
|
const status = flags["--all"] ? "all" : flags["--resolved"] ? "resolved" : flags["--open"] ? "open" : undefined;
|
|
1470
1834
|
return {
|
|
1471
1835
|
positionals,
|
|
1472
1836
|
unknown,
|
|
1837
|
+
missing,
|
|
1473
1838
|
site: flags["--site"],
|
|
1474
1839
|
mode: flags["--mode"],
|
|
1475
1840
|
page: flags["--page"],
|
|
1476
1841
|
target: flags["--target"],
|
|
1477
1842
|
body: flags["--body"],
|
|
1478
|
-
url: flags["--url"],
|
|
1479
|
-
secret: flags["--secret"],
|
|
1480
1843
|
passcode: flags["--passcode"],
|
|
1481
1844
|
limit: limitRaw ? Number(limitRaw) : undefined,
|
|
1482
1845
|
status,
|
|
@@ -1486,31 +1849,33 @@ function parseCommentFlags(tail) {
|
|
|
1486
1849
|
}
|
|
1487
1850
|
var VERBS = ["enable", "mode", "off", "list", "show", "post", "resolve", "reopen"];
|
|
1488
1851
|
async function commentsCommand(argv, io) {
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1852
|
+
const all = parseCommentFlags(argv);
|
|
1853
|
+
const json = all.json;
|
|
1854
|
+
const at = firstPositionalIndex(argv, COMMENTS_FLAG_SPEC);
|
|
1855
|
+
const verb = at === -1 ? undefined : argv[at];
|
|
1856
|
+
const overview = `Usage: flypod comments <${VERBS.join("|")}> [args]`;
|
|
1857
|
+
if (verb === undefined) {
|
|
1858
|
+
if (all.help)
|
|
1859
|
+
return emitHelp(overview, { json }, io);
|
|
1860
|
+
return fail("usage", overview, { json }, io, {
|
|
1861
|
+
fix: "Run `flypod comments --help`, or e.g. `flypod comments list`."
|
|
1862
|
+
});
|
|
1497
1863
|
}
|
|
1498
|
-
const verb = argv[0];
|
|
1499
|
-
const rest = argv.slice(1);
|
|
1500
1864
|
if (!VERBS.includes(verb)) {
|
|
1865
|
+
const guess = closest(verb, VERBS);
|
|
1501
1866
|
return fail("unknown_command", `flypod comments: unknown verb "${verb}"`, { json }, io, {
|
|
1502
|
-
fix: `Expected one of: ${VERBS.join(", ")}.`
|
|
1867
|
+
fix: guess ? `Did you mean \`flypod comments ${guess}\`?` : `Expected one of: ${VERBS.join(", ")}.`
|
|
1503
1868
|
});
|
|
1504
1869
|
}
|
|
1870
|
+
const rest = [...argv.slice(0, at), ...argv.slice(at + 1)];
|
|
1505
1871
|
const f = parseCommentFlags(rest);
|
|
1506
|
-
if (f.help)
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
return fail("unknown_flag", `unknown flag "${f.unknown[0]}"`, f, io, {
|
|
1872
|
+
if (f.help)
|
|
1873
|
+
return emitHelp(USAGE[verb] ?? `Usage: flypod comments ${verb}`, f, io);
|
|
1874
|
+
const problem = flagProblem(f, COMMENTS_FLAG_SPEC, `flypod comments ${verb} --help`);
|
|
1875
|
+
if (problem) {
|
|
1876
|
+
return fail(problem.code, problem.error, f, io, {
|
|
1512
1877
|
prefix: `flypod comments ${verb}`,
|
|
1513
|
-
fix:
|
|
1878
|
+
fix: problem.fix
|
|
1514
1879
|
});
|
|
1515
1880
|
}
|
|
1516
1881
|
switch (verb) {
|
|
@@ -1569,7 +1934,7 @@ async function commentsCommand(argv, io) {
|
|
|
1569
1934
|
}
|
|
1570
1935
|
|
|
1571
1936
|
// src/cli/select.ts
|
|
1572
|
-
var
|
|
1937
|
+
var ESC2 = "\x1B[";
|
|
1573
1938
|
function canPrompt(input = process.stdin, output = process.stderr) {
|
|
1574
1939
|
return Boolean(input.isTTY && output.isTTY && typeof input.setRawMode === "function");
|
|
1575
1940
|
}
|
|
@@ -1598,8 +1963,8 @@ function multiselect(opts) {
|
|
|
1598
1963
|
};
|
|
1599
1964
|
const draw = () => {
|
|
1600
1965
|
if (printed > 0)
|
|
1601
|
-
output.write(`${
|
|
1602
|
-
output.write(`${
|
|
1966
|
+
output.write(`${ESC2}${printed}A`);
|
|
1967
|
+
output.write(`${ESC2}0J`);
|
|
1603
1968
|
const lines = render();
|
|
1604
1969
|
output.write(`${lines.join(`
|
|
1605
1970
|
`)}
|
|
@@ -1608,10 +1973,10 @@ function multiselect(opts) {
|
|
|
1608
1973
|
};
|
|
1609
1974
|
const cleanup = () => {
|
|
1610
1975
|
if (printed > 0) {
|
|
1611
|
-
output.write(`${
|
|
1612
|
-
output.write(`${
|
|
1976
|
+
output.write(`${ESC2}${printed}A`);
|
|
1977
|
+
output.write(`${ESC2}0J`);
|
|
1613
1978
|
}
|
|
1614
|
-
output.write(`${
|
|
1979
|
+
output.write(`${ESC2}?25h`);
|
|
1615
1980
|
input.removeListener("data", onData);
|
|
1616
1981
|
if (typeof input.setRawMode === "function")
|
|
1617
1982
|
input.setRawMode(false);
|
|
@@ -1656,7 +2021,7 @@ function multiselect(opts) {
|
|
|
1656
2021
|
return;
|
|
1657
2022
|
}
|
|
1658
2023
|
};
|
|
1659
|
-
output.write(`${
|
|
2024
|
+
output.write(`${ESC2}?25l`);
|
|
1660
2025
|
if (typeof input.setRawMode === "function")
|
|
1661
2026
|
input.setRawMode(true);
|
|
1662
2027
|
input.resume();
|
|
@@ -1665,112 +2030,6 @@ function multiselect(opts) {
|
|
|
1665
2030
|
});
|
|
1666
2031
|
}
|
|
1667
2032
|
|
|
1668
|
-
// src/ui.ts
|
|
1669
|
-
var ESC2 = "\x1B[";
|
|
1670
|
-
function envBool(name) {
|
|
1671
|
-
const v = process.env[name];
|
|
1672
|
-
return v !== undefined && v !== "" && v !== "0" && v !== "false";
|
|
1673
|
-
}
|
|
1674
|
-
function colorsEnabled(stream = process.stderr) {
|
|
1675
|
-
if (envBool("NO_COLOR"))
|
|
1676
|
-
return false;
|
|
1677
|
-
if (envBool("FORCE_COLOR"))
|
|
1678
|
-
return true;
|
|
1679
|
-
return Boolean(stream.isTTY);
|
|
1680
|
-
}
|
|
1681
|
-
var FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
1682
|
-
function paint(open, s) {
|
|
1683
|
-
return `${ESC2}${open}m${s}${ESC2}0m`;
|
|
1684
|
-
}
|
|
1685
|
-
function makeStyle(enabled) {
|
|
1686
|
-
if (!enabled) {
|
|
1687
|
-
const id2 = (s) => s;
|
|
1688
|
-
return { dim: id2, bold: id2, accent: id2, ok: id2, err: id2, warn: id2, muted: id2 };
|
|
1689
|
-
}
|
|
1690
|
-
return {
|
|
1691
|
-
dim: (s) => paint("2", s),
|
|
1692
|
-
bold: (s) => paint("1", s),
|
|
1693
|
-
accent: (s) => paint("38;5;191", s),
|
|
1694
|
-
ok: (s) => paint("38;5;120", s),
|
|
1695
|
-
err: (s) => paint("38;5;203", s),
|
|
1696
|
-
warn: (s) => paint("38;5;221", s),
|
|
1697
|
-
muted: (s) => paint("38;5;245", s)
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
function makeSpinner(stream = process.stderr, style = makeStyle(false)) {
|
|
1701
|
-
const tty = Boolean(stream.isTTY);
|
|
1702
|
-
let timer;
|
|
1703
|
-
let frame = 0;
|
|
1704
|
-
let label = "";
|
|
1705
|
-
let started = false;
|
|
1706
|
-
const writeFrame = () => {
|
|
1707
|
-
stream.write(`\r${ESC2}2K ${style.accent(FRAMES[frame] ?? "·")} ${label}`);
|
|
1708
|
-
};
|
|
1709
|
-
const clearLine = () => {
|
|
1710
|
-
if (tty)
|
|
1711
|
-
stream.write(`\r${ESC2}2K`);
|
|
1712
|
-
};
|
|
1713
|
-
return {
|
|
1714
|
-
start(text) {
|
|
1715
|
-
label = text;
|
|
1716
|
-
started = true;
|
|
1717
|
-
if (tty) {
|
|
1718
|
-
writeFrame();
|
|
1719
|
-
timer = setInterval(() => {
|
|
1720
|
-
frame = (frame + 1) % FRAMES.length;
|
|
1721
|
-
writeFrame();
|
|
1722
|
-
}, 80);
|
|
1723
|
-
} else {
|
|
1724
|
-
stream.write(` ${style.dim("·")} ${label}
|
|
1725
|
-
`);
|
|
1726
|
-
}
|
|
1727
|
-
},
|
|
1728
|
-
update(text) {
|
|
1729
|
-
label = text;
|
|
1730
|
-
if (!started)
|
|
1731
|
-
return;
|
|
1732
|
-
if (tty)
|
|
1733
|
-
writeFrame();
|
|
1734
|
-
else
|
|
1735
|
-
stream.write(` ${style.dim("·")} ${label}
|
|
1736
|
-
`);
|
|
1737
|
-
},
|
|
1738
|
-
success(text) {
|
|
1739
|
-
clearLine();
|
|
1740
|
-
stream.write(` ${style.ok("✓")} ${text}
|
|
1741
|
-
`);
|
|
1742
|
-
this.stop();
|
|
1743
|
-
},
|
|
1744
|
-
fail(text) {
|
|
1745
|
-
clearLine();
|
|
1746
|
-
stream.write(` ${style.err("✗")} ${text}
|
|
1747
|
-
`);
|
|
1748
|
-
this.stop();
|
|
1749
|
-
},
|
|
1750
|
-
stop() {
|
|
1751
|
-
if (started)
|
|
1752
|
-
clearLine();
|
|
1753
|
-
if (timer)
|
|
1754
|
-
clearInterval(timer);
|
|
1755
|
-
timer = undefined;
|
|
1756
|
-
started = false;
|
|
1757
|
-
}
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
function fmtBytes(n) {
|
|
1761
|
-
if (n < 1024)
|
|
1762
|
-
return `${n} B`;
|
|
1763
|
-
if (n < 1024 * 1024)
|
|
1764
|
-
return `${(n / 1024).toFixed(n < 10 * 1024 ? 1 : 0)} KB`;
|
|
1765
|
-
return `${(n / (1024 * 1024)).toFixed(n < 10 * 1024 * 1024 ? 2 : 1)} MB`;
|
|
1766
|
-
}
|
|
1767
|
-
function fmtSeconds(ms) {
|
|
1768
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
1769
|
-
}
|
|
1770
|
-
function fmtCount(n, singular) {
|
|
1771
|
-
return `${n} ${singular}${n === 1 ? "" : "s"}`;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
2033
|
// bin/deploy.ts
|
|
1775
2034
|
var SUBCOMMANDS = new Set([
|
|
1776
2035
|
"deploy",
|
|
@@ -1805,6 +2064,9 @@ var INSTALL_FLAG_SPEC = {
|
|
|
1805
2064
|
"--print": "bool",
|
|
1806
2065
|
"--yes": "bool",
|
|
1807
2066
|
"-y": "bool",
|
|
2067
|
+
"--json": "bool",
|
|
2068
|
+
"-h": "bool",
|
|
2069
|
+
"--help": "bool",
|
|
1808
2070
|
...Object.fromEntries(Object.keys(TARGET_FLAGS).map((f) => [f, "bool"]))
|
|
1809
2071
|
};
|
|
1810
2072
|
function timelineFlag(flags) {
|
|
@@ -1812,6 +2074,17 @@ function timelineFlag(flags) {
|
|
|
1812
2074
|
return false;
|
|
1813
2075
|
return flags["--timeline"] || flags["--history"] ? true : undefined;
|
|
1814
2076
|
}
|
|
2077
|
+
var ANY_VALUE_FLAG = {
|
|
2078
|
+
"--site": "value",
|
|
2079
|
+
"--token": "value",
|
|
2080
|
+
"--mode": "value",
|
|
2081
|
+
"--device-code": "value",
|
|
2082
|
+
"--page": "value",
|
|
2083
|
+
"--target": "value",
|
|
2084
|
+
"--body": "value",
|
|
2085
|
+
"--passcode": "value",
|
|
2086
|
+
"--limit": "value"
|
|
2087
|
+
};
|
|
1815
2088
|
var TOP_LEVEL_FLAG_SPEC = {
|
|
1816
2089
|
"--json": "bool",
|
|
1817
2090
|
"-q": "bool",
|
|
@@ -1828,12 +2101,8 @@ var TOP_LEVEL_FLAG_SPEC = {
|
|
|
1828
2101
|
"--history": "bool",
|
|
1829
2102
|
"--no-history": "bool"
|
|
1830
2103
|
};
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
code: "unknown_flag",
|
|
1834
|
-
error: `unknown flag "${unknown}"`,
|
|
1835
|
-
fix: `Run \`${helpCmd}\` for usage.`
|
|
1836
|
-
};
|
|
2104
|
+
var COMMENT_MODES = ["anonymous", "passcode", "approved", "open", "review", "members"];
|
|
2105
|
+
function exitUsage(err, argv) {
|
|
1837
2106
|
if (argv.includes("--json")) {
|
|
1838
2107
|
process.stdout.write(`${JSON.stringify(errorEnvelope(err))}
|
|
1839
2108
|
`);
|
|
@@ -1845,18 +2114,33 @@ function rejectUnknownFlag(unknown, argv, helpCmd) {
|
|
|
1845
2114
|
}
|
|
1846
2115
|
process.exit(exitCodeFor(err.code));
|
|
1847
2116
|
}
|
|
2117
|
+
function rejectFlagProblems(parsed, spec, argv, helpCmd) {
|
|
2118
|
+
const problem = flagProblem(parsed, spec, helpCmd);
|
|
2119
|
+
if (problem)
|
|
2120
|
+
exitUsage(problem, argv);
|
|
2121
|
+
}
|
|
1848
2122
|
function parseArgs(argv) {
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1851
|
-
|
|
2123
|
+
const parsed = parseFlags(argv, TOP_LEVEL_FLAG_SPEC);
|
|
2124
|
+
const { flags, positionals } = parsed;
|
|
2125
|
+
const help = Boolean(flags["-h"] || flags["--help"]);
|
|
2126
|
+
if (!help)
|
|
2127
|
+
rejectFlagProblems(parsed, TOP_LEVEL_FLAG_SPEC, argv, "flypod --help");
|
|
2128
|
+
const mode = flags["--mode"];
|
|
2129
|
+
if (!help && mode !== undefined && !COMMENT_MODES.includes(mode)) {
|
|
2130
|
+
exitUsage({
|
|
2131
|
+
code: "usage",
|
|
2132
|
+
error: `--mode must be anonymous, passcode or approved, not "${mode}"`,
|
|
2133
|
+
fix: "Pass e.g. `--comments --mode approved`."
|
|
2134
|
+
}, argv);
|
|
2135
|
+
}
|
|
1852
2136
|
return {
|
|
1853
2137
|
path: positionals[0],
|
|
1854
2138
|
json: Boolean(flags["--json"]),
|
|
1855
2139
|
quiet: Boolean(flags["-q"] || flags["--quiet"]),
|
|
1856
|
-
help
|
|
2140
|
+
help,
|
|
1857
2141
|
version: Boolean(flags["-v"] || flags["--version"]),
|
|
1858
2142
|
comments: Boolean(flags["--comments"]),
|
|
1859
|
-
commentsMode:
|
|
2143
|
+
commentsMode: mode ?? "anonymous",
|
|
1860
2144
|
verbose: Boolean(flags["--verbose"]),
|
|
1861
2145
|
timeline: timelineFlag(flags)
|
|
1862
2146
|
};
|
|
@@ -1888,9 +2172,11 @@ var ACCOUNT_FLAG_SPEC = {
|
|
|
1888
2172
|
"--help": "bool"
|
|
1889
2173
|
};
|
|
1890
2174
|
function parseSub(name, argv) {
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1893
|
-
|
|
2175
|
+
const parsed = parseFlags(argv, SUB_FLAG_SPEC);
|
|
2176
|
+
const { flags, positionals } = parsed;
|
|
2177
|
+
if (!flags["-h"] && !flags["--help"]) {
|
|
2178
|
+
rejectFlagProblems(parsed, SUB_FLAG_SPEC, argv, `flypod ${name} --help`);
|
|
2179
|
+
}
|
|
1894
2180
|
return {
|
|
1895
2181
|
positionals,
|
|
1896
2182
|
site: flags["--site"],
|
|
@@ -1933,9 +2219,11 @@ async function runSubcommand(name, argv) {
|
|
|
1933
2219
|
return token({ site, json, help }, io);
|
|
1934
2220
|
}
|
|
1935
2221
|
case "login": {
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
|
|
2222
|
+
const parsed = parseFlags(argv, LOGIN_FLAG_SPEC);
|
|
2223
|
+
const { flags } = parsed;
|
|
2224
|
+
if (!flags["-h"] && !flags["--help"]) {
|
|
2225
|
+
rejectFlagProblems(parsed, LOGIN_FLAG_SPEC, argv, "flypod login --help");
|
|
2226
|
+
}
|
|
1939
2227
|
return login({
|
|
1940
2228
|
token: flags["--token"],
|
|
1941
2229
|
deviceCode: flags["--device-code"],
|
|
@@ -1943,49 +2231,61 @@ async function runSubcommand(name, argv) {
|
|
|
1943
2231
|
help: Boolean(flags["-h"] || flags["--help"])
|
|
1944
2232
|
}, io);
|
|
1945
2233
|
}
|
|
1946
|
-
case "logout":
|
|
1947
|
-
|
|
1948
|
-
if (unknown[0])
|
|
1949
|
-
rejectUnknownFlag(unknown[0], argv, "flypod --help");
|
|
1950
|
-
return logout({ json: Boolean(flags["--json"]) }, io);
|
|
1951
|
-
}
|
|
1952
|
-
case "list": {
|
|
1953
|
-
const { flags, unknown } = parseFlags(argv, ACCOUNT_FLAG_SPEC);
|
|
1954
|
-
if (unknown[0])
|
|
1955
|
-
rejectUnknownFlag(unknown[0], argv, "flypod --help");
|
|
1956
|
-
return list({ json: Boolean(flags["--json"]) }, io);
|
|
1957
|
-
}
|
|
2234
|
+
case "logout":
|
|
2235
|
+
case "list":
|
|
1958
2236
|
case "claim": {
|
|
1959
|
-
const
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2237
|
+
const parsed = parseFlags(argv, ACCOUNT_FLAG_SPEC);
|
|
2238
|
+
const { flags, positionals } = parsed;
|
|
2239
|
+
const help = Boolean(flags["-h"] || flags["--help"]);
|
|
2240
|
+
const json = Boolean(flags["--json"]);
|
|
2241
|
+
if (!help)
|
|
2242
|
+
rejectFlagProblems(parsed, ACCOUNT_FLAG_SPEC, argv, `flypod ${name} --help`);
|
|
2243
|
+
if (name === "logout")
|
|
2244
|
+
return logout({ json, help }, io);
|
|
2245
|
+
if (name === "list")
|
|
2246
|
+
return list({ json, help }, io);
|
|
2247
|
+
return claim({ site_id: positionals[0], token: positionals[1], json, help }, io);
|
|
1963
2248
|
}
|
|
1964
2249
|
case "install":
|
|
1965
2250
|
return runInstall(argv, io);
|
|
1966
2251
|
case "comments":
|
|
1967
2252
|
return commentsCommand(argv, io);
|
|
1968
2253
|
default:
|
|
1969
|
-
|
|
1970
|
-
|
|
2254
|
+
return emitCliError({
|
|
2255
|
+
code: "unknown_command",
|
|
2256
|
+
error: `unknown command "${name}"`,
|
|
2257
|
+
fix: "Run `flypod --help` for usage."
|
|
2258
|
+
}, argv.includes("--json"), io);
|
|
1971
2259
|
}
|
|
1972
2260
|
}
|
|
2261
|
+
function emitCliError(err, json, io) {
|
|
2262
|
+
if (json)
|
|
2263
|
+
io.out(JSON.stringify(errorEnvelope(err)));
|
|
2264
|
+
else
|
|
2265
|
+
for (const line of failure(err.error, err.fix, io.style ?? PLAIN))
|
|
2266
|
+
io.err(line);
|
|
2267
|
+
return exitCodeFor(err.code);
|
|
2268
|
+
}
|
|
1973
2269
|
function shortHome(path) {
|
|
1974
2270
|
const home = homedir();
|
|
1975
2271
|
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
1976
2272
|
}
|
|
1977
2273
|
async function runInstall(argv, io) {
|
|
1978
|
-
const
|
|
2274
|
+
const parsed = parseFlags(argv, INSTALL_FLAG_SPEC);
|
|
2275
|
+
const { flags, positionals } = parsed;
|
|
2276
|
+
const json = Boolean(flags["--json"]);
|
|
2277
|
+
if (flags["-h"] || flags["--help"]) {
|
|
2278
|
+
return emitHelp(subcommandHelp("install") ?? "", { json }, io);
|
|
2279
|
+
}
|
|
2280
|
+
const noun = positionals[0];
|
|
1979
2281
|
if (noun !== "skill" && noun !== "skills") {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2282
|
+
return emitCliError({
|
|
2283
|
+
code: "usage",
|
|
2284
|
+
error: noun === undefined ? "flypod install needs to know what to install." : `flypod install: unknown target "${noun}"`,
|
|
2285
|
+
fix: "Run `flypod install skill`, or `flypod install --help`."
|
|
2286
|
+
}, json, io);
|
|
1985
2287
|
}
|
|
1986
|
-
|
|
1987
|
-
if (unknown[0])
|
|
1988
|
-
rejectUnknownFlag(unknown[0], argv, "flypod install skill --list");
|
|
2288
|
+
rejectFlagProblems(parsed, INSTALL_FLAG_SPEC, argv, "flypod install --help");
|
|
1989
2289
|
const targets = [];
|
|
1990
2290
|
for (const [flag, id2] of Object.entries(TARGET_FLAGS)) {
|
|
1991
2291
|
if (flags[flag] && !targets.includes(id2))
|
|
@@ -2031,8 +2331,8 @@ async function readVersion() {
|
|
|
2031
2331
|
}
|
|
2032
2332
|
return "0.0.0";
|
|
2033
2333
|
}
|
|
2034
|
-
function
|
|
2035
|
-
|
|
2334
|
+
function helpText(version) {
|
|
2335
|
+
return `flypod v${version}
|
|
2036
2336
|
Drop files, get a live URL. Every deploy is versioned, so you can roll back.
|
|
2037
2337
|
|
|
2038
2338
|
THE LOOP (this is all most agents need):
|
|
@@ -2103,7 +2403,8 @@ Agents:
|
|
|
2103
2403
|
.claude/skills/flypod/ (Claude Code) and
|
|
2104
2404
|
.agents/skills/flypod/ (Codex, Cursor, Gemini
|
|
2105
2405
|
CLI, Copilot). Add --global for your home dir,
|
|
2106
|
-
--list to see the paths, --dry-run to preview
|
|
2406
|
+
--list to see the paths, --dry-run to preview,
|
|
2407
|
+
-y/--yes to write every target without asking.
|
|
2107
2408
|
|
|
2108
2409
|
Deploy flags:
|
|
2109
2410
|
--timeline Turn on History: a chip on the site's pages
|
|
@@ -2115,7 +2416,8 @@ Deploy flags:
|
|
|
2115
2416
|
--no-timeline Turn History off again.
|
|
2116
2417
|
--comments Enable comments on the new site (mode: anonymous).
|
|
2117
2418
|
--comments --mode <mode> Same, but choose the mode: anonymous|passcode|
|
|
2118
|
-
approved.
|
|
2419
|
+
approved. Needs a signed-in deploy: without
|
|
2420
|
+
one the receipt says comments_skipped.
|
|
2119
2421
|
|
|
2120
2422
|
Comments (off by default — enabling is one command):
|
|
2121
2423
|
Every verb below takes the site from --site, or from the folder->site link
|
|
@@ -2159,9 +2461,27 @@ When no path is given, flypod looks for a build folder in the current directory:
|
|
|
2159
2461
|
dist, build, out, .output/public, .vercel/output/static, public, _site
|
|
2160
2462
|
(each must contain an index.html)
|
|
2161
2463
|
|
|
2464
|
+
What is uploaded:
|
|
2465
|
+
Everything in the folder except .git, .hg, .svn, node_modules, .DS_Store,
|
|
2466
|
+
Thumbs.db, .env and .env.* — at any depth. Add gitignore-style patterns to
|
|
2467
|
+
a .flypodignore in the folder to leave out more. What was left out is
|
|
2468
|
+
listed after the deploy ("skipped" in --json). A deploy may be at most
|
|
2469
|
+
100 MB of files and 50 MB as an upload; flypod checks before uploading.
|
|
2470
|
+
|
|
2162
2471
|
Docs: https://flypod.dev
|
|
2163
2472
|
`;
|
|
2164
|
-
|
|
2473
|
+
}
|
|
2474
|
+
function showHelp(version, json) {
|
|
2475
|
+
emitHelp(helpText(version), { json }, { out: (line) => process.stdout.write(`${line}
|
|
2476
|
+
`) });
|
|
2477
|
+
}
|
|
2478
|
+
async function exists(path) {
|
|
2479
|
+
try {
|
|
2480
|
+
await stat(path);
|
|
2481
|
+
return true;
|
|
2482
|
+
} catch {
|
|
2483
|
+
return false;
|
|
2484
|
+
}
|
|
2165
2485
|
}
|
|
2166
2486
|
function shortDir(dir) {
|
|
2167
2487
|
const rel = relative(process.cwd(), dir);
|
|
@@ -2182,15 +2502,16 @@ function fail2(err, args, style) {
|
|
|
2182
2502
|
async function main() {
|
|
2183
2503
|
const rawArgv = process.argv.slice(2);
|
|
2184
2504
|
const version = await readVersion();
|
|
2185
|
-
const
|
|
2505
|
+
const at = firstPositionalIndex(rawArgv, ANY_VALUE_FLAG);
|
|
2506
|
+
const firstPositional = at === -1 ? undefined : rawArgv[at];
|
|
2507
|
+
const withoutVerb = at === -1 ? rawArgv : [...rawArgv.slice(0, at), ...rawArgv.slice(at + 1)];
|
|
2186
2508
|
if (firstPositional && SUBCOMMANDS.has(firstPositional) && firstPositional !== "deploy") {
|
|
2187
|
-
const
|
|
2188
|
-
const code = await runSubcommand(firstPositional, rest);
|
|
2509
|
+
const code = await runSubcommand(firstPositional, withoutVerb);
|
|
2189
2510
|
process.exit(code);
|
|
2190
2511
|
}
|
|
2191
|
-
const args = parseArgs(firstPositional === "deploy" ?
|
|
2512
|
+
const args = parseArgs(firstPositional === "deploy" ? withoutVerb : rawArgv);
|
|
2192
2513
|
if (args.help) {
|
|
2193
|
-
showHelp(version);
|
|
2514
|
+
showHelp(version, args.json);
|
|
2194
2515
|
return;
|
|
2195
2516
|
}
|
|
2196
2517
|
if (args.version) {
|
|
@@ -2202,13 +2523,18 @@ async function main() {
|
|
|
2202
2523
|
const { token: apiKey, baseUrl } = client;
|
|
2203
2524
|
const useUI = !args.json && !args.quiet;
|
|
2204
2525
|
const style = makeStyle(colorsEnabled(process.stderr) && useUI);
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
`
|
|
2526
|
+
if (args.path !== undefined && !await exists(args.path)) {
|
|
2527
|
+
const bareWord = /^[a-z]+$/i.test(args.path) && !BUILD_DIR_CANDIDATES.includes(args.path);
|
|
2528
|
+
const verb = bareWord ? closest(args.path, [...SUBCOMMANDS]) : undefined;
|
|
2529
|
+
fail2(verb ? {
|
|
2530
|
+
code: "unknown_command",
|
|
2531
|
+
error: `unknown command "${args.path}" — did you mean \`flypod ${verb}\`?`,
|
|
2532
|
+
fix: `flypod ${verb}`
|
|
2533
|
+
} : {
|
|
2534
|
+
code: "no_build_dir",
|
|
2535
|
+
error: `Nothing to deploy at ${args.path}: no such file or folder.`,
|
|
2536
|
+
fix: "Pass the folder of built files, e.g. `flypod ./dist`, or build the site first."
|
|
2537
|
+
}, args, style);
|
|
2212
2538
|
}
|
|
2213
2539
|
let dir;
|
|
2214
2540
|
try {
|
|
@@ -2217,8 +2543,9 @@ async function main() {
|
|
|
2217
2543
|
fail2(noBuildDir(error.message), args, style);
|
|
2218
2544
|
}
|
|
2219
2545
|
let files;
|
|
2546
|
+
let skipped;
|
|
2220
2547
|
try {
|
|
2221
|
-
files = await
|
|
2548
|
+
({ files, skipped } = await collectFiles(dir));
|
|
2222
2549
|
} catch (error) {
|
|
2223
2550
|
fail2({
|
|
2224
2551
|
code: "no_files",
|
|
@@ -2235,6 +2562,21 @@ async function main() {
|
|
|
2235
2562
|
fix: "Build the site first, then deploy the output folder."
|
|
2236
2563
|
}, args, style);
|
|
2237
2564
|
}
|
|
2565
|
+
const tooLarge = checkUploadSize(files, uploadLimitsFor(baseUrl));
|
|
2566
|
+
if (tooLarge)
|
|
2567
|
+
fail2(tooLarge, args, style);
|
|
2568
|
+
const priorLink = await projectForDir(process.cwd()).catch(() => null);
|
|
2569
|
+
if (priorLink && useUI) {
|
|
2570
|
+
for (const line of relinkNotice(priorLink, style))
|
|
2571
|
+
process.stderr.write(`${line}
|
|
2572
|
+
`);
|
|
2573
|
+
process.stderr.write(`
|
|
2574
|
+
`);
|
|
2575
|
+
}
|
|
2576
|
+
if (useUI)
|
|
2577
|
+
for (const line of skippedRows(skipped, style))
|
|
2578
|
+
process.stderr.write(`${line}
|
|
2579
|
+
`);
|
|
2238
2580
|
const spinner = useUI ? makeSpinner(process.stderr, style) : { start: () => {}, update: () => {}, success: () => {}, fail: () => {}, stop: () => {} };
|
|
2239
2581
|
spinner.start(`Uploading ${fmtBytes(totalBytes)}`);
|
|
2240
2582
|
const started = Date.now();
|
|
@@ -2264,16 +2606,17 @@ async function main() {
|
|
|
2264
2606
|
linkSaved = false;
|
|
2265
2607
|
}
|
|
2266
2608
|
let commentsEnabled = false;
|
|
2609
|
+
let commentsSkipped;
|
|
2267
2610
|
if (args.comments) {
|
|
2268
2611
|
if (!apiKey) {
|
|
2612
|
+
commentsSkipped = "not_signed_in";
|
|
2269
2613
|
if (useUI) {
|
|
2270
2614
|
process.stderr.write(` ${style.muted("comments")} ${style.dim("skipped — run `flypod login` to enable comments")}
|
|
2271
2615
|
`);
|
|
2272
2616
|
}
|
|
2273
2617
|
} else {
|
|
2274
2618
|
try {
|
|
2275
|
-
const
|
|
2276
|
-
const mode = allowed.has(args.commentsMode) ? args.commentsMode : "anonymous";
|
|
2619
|
+
const mode = args.commentsMode;
|
|
2277
2620
|
const cr = await client.setCommentsMode(result.site_id, { enabled: true, mode });
|
|
2278
2621
|
commentsEnabled = cr.ok;
|
|
2279
2622
|
if (useUI) {
|
|
@@ -2300,7 +2643,15 @@ async function main() {
|
|
|
2300
2643
|
warnings: result.warnings ?? [],
|
|
2301
2644
|
link_saved: linkSaved,
|
|
2302
2645
|
...priorLink && priorLink.site_id !== result.site_id ? { replaced_link: { site_id: priorLink.site_id, url: priorLink.url } } : {},
|
|
2303
|
-
...args.comments ? {
|
|
2646
|
+
...args.comments ? {
|
|
2647
|
+
comments_enabled: commentsEnabled,
|
|
2648
|
+
comments_mode: args.commentsMode,
|
|
2649
|
+
...commentsSkipped ? {
|
|
2650
|
+
comments_skipped: commentsSkipped,
|
|
2651
|
+
comments_fix: "Run `flypod login`, then `flypod comments enable`."
|
|
2652
|
+
} : {}
|
|
2653
|
+
} : {},
|
|
2654
|
+
...skipped.length > 0 ? { skipped } : {},
|
|
2304
2655
|
...switched ?? {}
|
|
2305
2656
|
};
|
|
2306
2657
|
const nextOpts = {
|
|
@@ -2334,7 +2685,7 @@ async function main() {
|
|
|
2334
2685
|
...shared,
|
|
2335
2686
|
...agentNextCommands(nextOpts)
|
|
2336
2687
|
};
|
|
2337
|
-
process.stdout.write(`${JSON.stringify(receipt
|
|
2688
|
+
process.stdout.write(`${JSON.stringify(receipt)}
|
|
2338
2689
|
`);
|
|
2339
2690
|
return;
|
|
2340
2691
|
}
|