flypod 0.10.0 → 0.11.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 +164 -35
- package/dist/bin/deploy.js +271 -156
- package/dist/{cli-198a0gkx.js → cli-nqpgfpnm.js} +31 -9
- package/dist/src/cli/commands.d.ts +10 -0
- package/dist/src/cli/errors.d.ts +8 -2
- package/dist/src/cli/receipt.d.ts +102 -68
- package/dist/src/cli/screen.d.ts +43 -0
- package/dist/src/cli.js +1 -1
- package/dist/src/deploy-source.d.ts +1 -1
- package/package.json +1 -1
package/dist/bin/deploy.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
resolveCredentials,
|
|
13
13
|
resolveDeployDir,
|
|
14
14
|
saveSession
|
|
15
|
-
} from "../cli-
|
|
15
|
+
} from "../cli-nqpgfpnm.js";
|
|
16
16
|
|
|
17
17
|
// bin/deploy.ts
|
|
18
18
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -20,6 +20,64 @@ import { homedir } from "node:os";
|
|
|
20
20
|
import { relative } from "node:path";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
|
|
23
|
+
// src/cli/screen.ts
|
|
24
|
+
var WIDTH = 66;
|
|
25
|
+
var GUTTER = 10;
|
|
26
|
+
var id = (s) => s;
|
|
27
|
+
var PLAIN = {
|
|
28
|
+
dim: id,
|
|
29
|
+
bold: id,
|
|
30
|
+
muted: id,
|
|
31
|
+
accent: id,
|
|
32
|
+
ok: id,
|
|
33
|
+
err: id,
|
|
34
|
+
warn: id
|
|
35
|
+
};
|
|
36
|
+
function wrap(text, width) {
|
|
37
|
+
const lines = [];
|
|
38
|
+
for (const paragraph of text.split(`
|
|
39
|
+
`)) {
|
|
40
|
+
let line = "";
|
|
41
|
+
for (const word of paragraph.split(/\s+/).filter(Boolean)) {
|
|
42
|
+
if (line && line.length + 1 + word.length > width) {
|
|
43
|
+
lines.push(line);
|
|
44
|
+
line = word;
|
|
45
|
+
} else {
|
|
46
|
+
line = line ? `${line} ${word}` : word;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
lines.push(line);
|
|
50
|
+
}
|
|
51
|
+
return lines;
|
|
52
|
+
}
|
|
53
|
+
function headline(text, detail, s) {
|
|
54
|
+
return ` ${s.ok("✓")} ${text}${detail ? s.dim(` · ${detail}`) : ""}`;
|
|
55
|
+
}
|
|
56
|
+
function hero(url, s) {
|
|
57
|
+
return ` ${s.bold(s.accent(url))}`;
|
|
58
|
+
}
|
|
59
|
+
function field(label, value, hint, s) {
|
|
60
|
+
return ` ${s.muted(label.padEnd(GUTTER))}${value}${hint ? ` ${s.dim(hint)}` : ""}`;
|
|
61
|
+
}
|
|
62
|
+
function notice(title, body, s) {
|
|
63
|
+
return [
|
|
64
|
+
` ${(s.warn ?? id)("!")} ${s.bold(title)}`,
|
|
65
|
+
...wrap(body, WIDTH - 4).map((line) => ` ${s.dim(line)}`),
|
|
66
|
+
""
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
function failure(error, fix, s) {
|
|
70
|
+
const [first = "", ...rest] = wrap(error, WIDTH - 4);
|
|
71
|
+
return [
|
|
72
|
+
` ${(s.err ?? id)("✗")} ${first}`,
|
|
73
|
+
...rest.map((line) => ` ${line}`),
|
|
74
|
+
...fix ? wrap(fix, WIDTH - 4).map((line) => ` ${s.dim(line)}`) : []
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function shortVersion(versionId) {
|
|
78
|
+
return versionId.slice(0, 8);
|
|
79
|
+
}
|
|
80
|
+
|
|
23
81
|
// src/cli/errors.ts
|
|
24
82
|
var USAGE_CODES = new Set([
|
|
25
83
|
"usage",
|
|
@@ -60,14 +118,12 @@ function errorEnvelope(err) {
|
|
|
60
118
|
...err.extra ?? {}
|
|
61
119
|
};
|
|
62
120
|
}
|
|
63
|
-
function emitError(err, args, io,
|
|
121
|
+
function emitError(err, args, io, _opts = {}) {
|
|
64
122
|
if (args.json) {
|
|
65
123
|
io.out(JSON.stringify(errorEnvelope(err)));
|
|
66
124
|
} else {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
if (err.fix)
|
|
70
|
-
io.err(` ${err.fix}`);
|
|
125
|
+
for (const line of failure(err.error, err.fix, io.style ?? PLAIN))
|
|
126
|
+
io.err(line);
|
|
71
127
|
}
|
|
72
128
|
return exitCodeFor(err.code);
|
|
73
129
|
}
|
|
@@ -171,6 +227,12 @@ function retryAfter(res) {
|
|
|
171
227
|
const seconds = raw ? Number(raw) : Number.NaN;
|
|
172
228
|
return Number.isFinite(seconds) ? { retry_after_s: seconds } : {};
|
|
173
229
|
}
|
|
230
|
+
function noBuildDir(message) {
|
|
231
|
+
const cut = message.indexOf(". ");
|
|
232
|
+
if (cut === -1)
|
|
233
|
+
return { code: "no_build_dir", error: message };
|
|
234
|
+
return { code: "no_build_dir", error: message.slice(0, cut + 1), fix: message.slice(cut + 2) };
|
|
235
|
+
}
|
|
174
236
|
function networkError(e, baseUrl) {
|
|
175
237
|
const reason = e instanceof Error ? e.message : String(e);
|
|
176
238
|
const host = baseUrl ? ` ${safeHost(baseUrl)}` : "";
|
|
@@ -280,8 +342,6 @@ async function forgetSite(site_id, env) {
|
|
|
280
342
|
// src/cli/receipt.ts
|
|
281
343
|
var DAY_MS = 86400000;
|
|
282
344
|
var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
283
|
-
var LABEL = 15;
|
|
284
|
-
var COMMAND = 18;
|
|
285
345
|
function daysUntil(expiresAt, now) {
|
|
286
346
|
return Math.max(0, Math.round((expiresAt - now) / DAY_MS));
|
|
287
347
|
}
|
|
@@ -296,75 +356,100 @@ function timestamp(ms) {
|
|
|
296
356
|
const mm = String(d.getUTCMinutes()).padStart(2, "0");
|
|
297
357
|
return `${expiryDate(ms)} ${hh}:${mm} UTC`;
|
|
298
358
|
}
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
{ label: "history", command: "flypod versions", effect: "every version, newest first" }
|
|
303
|
-
];
|
|
304
|
-
var PLAIN = {
|
|
305
|
-
dim: (s) => s,
|
|
306
|
-
bold: (s) => s,
|
|
307
|
-
muted: (s) => s,
|
|
308
|
-
accent: (s) => s,
|
|
309
|
-
ok: (s) => s
|
|
310
|
-
};
|
|
311
|
-
function gutter(label) {
|
|
312
|
-
return label.padEnd(LABEL, " ");
|
|
313
|
-
}
|
|
314
|
-
function row(label, command, effect, s) {
|
|
315
|
-
return ` ${s.muted(gutter(label))}${s.bold(command.padEnd(COMMAND, " "))}${s.dim(effect)}`;
|
|
359
|
+
var COMMAND = 15;
|
|
360
|
+
function step(label, command, hint, s) {
|
|
361
|
+
return field(label, s.bold(command.padEnd(COMMAND)), hint, s);
|
|
316
362
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
363
|
+
var NEXT = (s) => step("update", "flypod update", "publishes a new version · same URL", s);
|
|
364
|
+
var UNDO = (s) => step("undo", "flypod rollback", "puts the previous version back", s);
|
|
365
|
+
var HISTORY = (s) => step("history", "flypod versions", "lists every version you shipped", s);
|
|
366
|
+
function expiryRows(opts, style) {
|
|
367
|
+
const s = style ?? PLAIN;
|
|
368
|
+
if (opts.expiresAt === null) {
|
|
369
|
+
return [
|
|
370
|
+
field("expires", s.dim("never".padEnd(COMMAND)), opts.owned ? "it is on your account" : undefined, s)
|
|
371
|
+
];
|
|
372
|
+
}
|
|
327
373
|
const days = daysUntil(opts.expiresAt, opts.now ?? Date.now());
|
|
328
|
-
const when = `${expiryDate(opts.expiresAt)} · ${days} day${days === 1 ? "" : "s"}`;
|
|
329
374
|
return [
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
wrap("and every site on this machine", s)
|
|
375
|
+
field("expires", expiryDate(opts.expiresAt).padEnd(COMMAND), `in ${days} day${days === 1 ? "" : "s"}`, s),
|
|
376
|
+
step("keep it", "flypod login", "free · removes the expiry", s)
|
|
333
377
|
];
|
|
334
378
|
}
|
|
335
|
-
function
|
|
336
|
-
const
|
|
337
|
-
|
|
379
|
+
function warningLines(warnings, style) {
|
|
380
|
+
const s = style ?? PLAIN;
|
|
381
|
+
return (warnings ?? []).flatMap((w) => notice(w.code, w.fix_recipe, s));
|
|
382
|
+
}
|
|
383
|
+
function deployScreen(opts) {
|
|
384
|
+
const s = opts.style ?? PLAIN;
|
|
385
|
+
const lines = [
|
|
386
|
+
"",
|
|
387
|
+
hero(opts.url, s),
|
|
388
|
+
"",
|
|
389
|
+
...warningLines(opts.warnings, s),
|
|
390
|
+
...expiryRows(opts, s),
|
|
391
|
+
NEXT(s)
|
|
392
|
+
];
|
|
393
|
+
if (opts.verbose)
|
|
394
|
+
lines.push(UNDO(s), HISTORY(s));
|
|
338
395
|
lines.push("");
|
|
339
|
-
if (opts.
|
|
340
|
-
lines.push(
|
|
341
|
-
return lines;
|
|
396
|
+
if (opts.verbose && opts.details) {
|
|
397
|
+
lines.push(field("site", s.dim(opts.details.siteId), "", s), field("version", s.dim(opts.details.versionId), "", s), field("source", s.dim(opts.details.source), "", s), "");
|
|
342
398
|
}
|
|
343
|
-
lines.push(...expiryLines({ expiresAt: opts.expiresAt, now: opts.now, style }));
|
|
344
399
|
return lines;
|
|
345
400
|
}
|
|
346
|
-
function
|
|
401
|
+
function updateScreen(opts) {
|
|
347
402
|
const s = opts.style ?? PLAIN;
|
|
403
|
+
const version = opts.verbose ? opts.versionId : shortVersion(opts.versionId);
|
|
348
404
|
return [
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
...
|
|
405
|
+
headline("Updated", `version ${version} is live`, s),
|
|
406
|
+
"",
|
|
407
|
+
hero(opts.url, s),
|
|
408
|
+
"",
|
|
409
|
+
...warningLines(opts.warnings, s),
|
|
410
|
+
UNDO(s),
|
|
411
|
+
...opts.verbose ? [HISTORY(s)] : [],
|
|
412
|
+
...opts.expiresAt === null ? [] : expiryRows(opts, s),
|
|
413
|
+
""
|
|
354
414
|
];
|
|
355
415
|
}
|
|
356
416
|
function rollbackTail(opts) {
|
|
357
417
|
const s = opts.style ?? PLAIN;
|
|
358
|
-
return [
|
|
418
|
+
return [
|
|
419
|
+
headline("Rolled back", `version ${shortVersion(opts.versionId)} is live`, s),
|
|
420
|
+
"",
|
|
421
|
+
hero(opts.url, s),
|
|
422
|
+
""
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
function versionsTable(opts) {
|
|
426
|
+
const s = opts.style ?? PLAIN;
|
|
427
|
+
const rows = [...opts.versions].reverse().map((v) => {
|
|
428
|
+
const live = v.version_id === opts.liveVersionId;
|
|
429
|
+
const idCell = live ? s.bold(v.version_id) : v.version_id;
|
|
430
|
+
return ` ${idCell} ${s.dim(timestamp(v.created_at))}${live ? ` ${s.ok("● live")}` : ""}`;
|
|
431
|
+
});
|
|
432
|
+
return ["", ...rows, "", ...opts.expiresAt === null ? [] : [...expiryRows(opts, s), ""]];
|
|
359
433
|
}
|
|
360
434
|
function relinkNotice(prev, style) {
|
|
361
435
|
const s = style ?? PLAIN;
|
|
362
436
|
return [
|
|
363
|
-
` ${s.
|
|
364
|
-
`
|
|
365
|
-
|
|
437
|
+
` ${(s.warn ?? ((x) => x))("!")} ${s.bold("This folder already deploys to")}`,
|
|
438
|
+
` ${s.accent(prev.url)}`,
|
|
439
|
+
` ${s.bold("flypod update")}${s.dim(" ships there. This run makes a second site.")}`
|
|
366
440
|
];
|
|
367
441
|
}
|
|
442
|
+
function unsavedLinkNotice(opts, style) {
|
|
443
|
+
const s = style ?? PLAIN;
|
|
444
|
+
return [
|
|
445
|
+
...notice("Could not remember this site", `flypod could not write ${opts.configPath}, so nothing is holding this site's manage token. Save it now: without it this site cannot be updated or kept.`, s).slice(0, -1),
|
|
446
|
+
` ${s.accent(opts.manageToken)}`,
|
|
447
|
+
""
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
function agentNextCommands(opts) {
|
|
451
|
+
return { next: agentNext(opts).next };
|
|
452
|
+
}
|
|
368
453
|
function agentNext(opts) {
|
|
369
454
|
const now = opts.now ?? Date.now();
|
|
370
455
|
const expiring = opts.expiresAt !== null;
|
|
@@ -405,8 +490,10 @@ Ship a new version of the site linked to this folder.
|
|
|
405
490
|
Flags:
|
|
406
491
|
--site <id> Target a site by id instead of the linked folder.
|
|
407
492
|
--token <tok> Authorize with a manage_token.
|
|
493
|
+
--verbose The full receipt: also the rollback command, and with
|
|
494
|
+
--json the expiry restated as days and an ISO date.
|
|
408
495
|
--json Emit JSON on stdout (for agents/scripts).
|
|
409
|
-
-q, --quiet
|
|
496
|
+
-q, --quiet Only the URL.
|
|
410
497
|
-h, --help Show this help.`,
|
|
411
498
|
versions: `flypod versions [flags]
|
|
412
499
|
|
|
@@ -520,11 +607,11 @@ async function pollDeviceToken(client, deviceCode) {
|
|
|
520
607
|
}
|
|
521
608
|
async function finishLogin(accessToken, baseUrl, args, io, env) {
|
|
522
609
|
await saveSession({ session_token: accessToken, base_url: baseUrl, created_at: Date.now() }, env);
|
|
610
|
+
if (!args.json)
|
|
611
|
+
io.err(headline("Logged in", undefined, io.style ?? PLAIN));
|
|
523
612
|
const attached = await attachAnonymousSites(accessToken, baseUrl, args, io, env);
|
|
524
613
|
if (args.json)
|
|
525
614
|
io.out(JSON.stringify({ ok: true, logged_in: true, ...attached }));
|
|
526
|
-
else
|
|
527
|
-
io.err("Logged in.");
|
|
528
615
|
return 0;
|
|
529
616
|
}
|
|
530
617
|
async function login(args, io) {
|
|
@@ -641,9 +728,7 @@ async function attachAnonymousSites(apiKey, baseUrl, args, io, env) {
|
|
|
641
728
|
if (!args.json)
|
|
642
729
|
io.err(line);
|
|
643
730
|
};
|
|
644
|
-
const
|
|
645
|
-
say(`Found ${candidates.length} anonymous ${noun} on this machine.`);
|
|
646
|
-
say(` Attaching to your account…`);
|
|
731
|
+
const st = io.style ?? PLAIN;
|
|
647
732
|
const client = await createClient({
|
|
648
733
|
env,
|
|
649
734
|
fetch: io.fetch,
|
|
@@ -656,11 +741,15 @@ async function attachAnonymousSites(apiKey, baseUrl, args, io, env) {
|
|
|
656
741
|
manage_token: rec.manage_token
|
|
657
742
|
})));
|
|
658
743
|
} catch {
|
|
659
|
-
|
|
744
|
+
for (const line of notice("Could not attach your sites", "The server could not be reached. Run `flypod login` again later; they stay temporary until then.", st).slice(0, -1)) {
|
|
745
|
+
say(line);
|
|
746
|
+
}
|
|
660
747
|
return none;
|
|
661
748
|
}
|
|
662
749
|
if (!res.ok) {
|
|
663
|
-
|
|
750
|
+
for (const line of notice("Could not attach your sites", `The server answered ${res.status}. Run \`flypod login\` again later; they stay temporary until then.`, st).slice(0, -1)) {
|
|
751
|
+
say(line);
|
|
752
|
+
}
|
|
664
753
|
return none;
|
|
665
754
|
}
|
|
666
755
|
const body = await res.json().catch(() => ({}));
|
|
@@ -677,10 +766,10 @@ async function attachAnonymousSites(apiKey, baseUrl, args, io, env) {
|
|
|
677
766
|
}
|
|
678
767
|
if (attached.size > 0) {
|
|
679
768
|
const word = attached.size === 1 ? "site" : "sites";
|
|
680
|
-
say(`
|
|
769
|
+
say(headline(`Attached ${attached.size} ${word}`, "no expiry now, same URLs", st));
|
|
681
770
|
}
|
|
682
771
|
if (skipped.length > 0) {
|
|
683
|
-
say(`
|
|
772
|
+
say(` ${st.dim(`Skipped ${skipped.length} (already owned or expired).`)}`);
|
|
684
773
|
}
|
|
685
774
|
return { attached: [...attached], skipped };
|
|
686
775
|
}
|
|
@@ -692,9 +781,9 @@ async function logout(args, io) {
|
|
|
692
781
|
return 0;
|
|
693
782
|
}
|
|
694
783
|
if (ok)
|
|
695
|
-
io.err("Signed out
|
|
784
|
+
io.err(headline("Signed out", "this machine has forgotten the session", io.style ?? PLAIN));
|
|
696
785
|
else
|
|
697
|
-
io.err("Already signed out.");
|
|
786
|
+
io.err(" Already signed out.");
|
|
698
787
|
return 0;
|
|
699
788
|
}
|
|
700
789
|
async function list(args, io) {
|
|
@@ -717,7 +806,7 @@ async function list(args, io) {
|
|
|
717
806
|
const sites = body.sites ?? [];
|
|
718
807
|
io.out(JSON.stringify({ ok: true, sites }));
|
|
719
808
|
if (sites.length === 0 && !args.json) {
|
|
720
|
-
io.err("No sites yet. Run `flypod` in a folder to deploy one.");
|
|
809
|
+
io.err(" No sites yet. Run `flypod` in a folder to deploy one.");
|
|
721
810
|
}
|
|
722
811
|
return 0;
|
|
723
812
|
}
|
|
@@ -758,7 +847,7 @@ async function claim(args, io) {
|
|
|
758
847
|
owner_account_id: body.owner_account_id,
|
|
759
848
|
expires_at: null
|
|
760
849
|
}));
|
|
761
|
-
io.err(`Claimed ${body.site_id}
|
|
850
|
+
io.err(headline(`Claimed ${body.site_id}`, "no expiry now, same URL", io.style ?? PLAIN));
|
|
762
851
|
return 0;
|
|
763
852
|
}
|
|
764
853
|
async function resolveTarget(args, io) {
|
|
@@ -825,7 +914,7 @@ async function update(args, io) {
|
|
|
825
914
|
try {
|
|
826
915
|
dir = await resolveDeployDir({ cwd, explicit: args.path });
|
|
827
916
|
} catch (e) {
|
|
828
|
-
return
|
|
917
|
+
return emitError(noBuildDir(e.message), args, io);
|
|
829
918
|
}
|
|
830
919
|
let files;
|
|
831
920
|
try {
|
|
@@ -853,7 +942,8 @@ async function update(args, io) {
|
|
|
853
942
|
url: body.url,
|
|
854
943
|
healed: body.healed ?? [],
|
|
855
944
|
warnings: body.warnings ?? [],
|
|
856
|
-
|
|
945
|
+
expires_at: expiresAt,
|
|
946
|
+
...(args.verbose ? agentNext : agentNextCommands)({
|
|
857
947
|
siteId: target.site_id,
|
|
858
948
|
expiresAt,
|
|
859
949
|
owned: expiresAt === null
|
|
@@ -865,16 +955,18 @@ async function update(args, io) {
|
|
|
865
955
|
io.out(body.url);
|
|
866
956
|
return 0;
|
|
867
957
|
}
|
|
868
|
-
for (const line of
|
|
958
|
+
for (const line of updateScreen({
|
|
869
959
|
versionId: body.version_id,
|
|
870
960
|
url: body.url,
|
|
871
961
|
expiresAt,
|
|
872
962
|
warnings: body.warnings,
|
|
963
|
+
verbose: args.verbose,
|
|
873
964
|
style: io.style
|
|
874
965
|
})) {
|
|
875
966
|
io.err(line);
|
|
876
967
|
}
|
|
877
|
-
io.
|
|
968
|
+
if (!io.interactive)
|
|
969
|
+
io.out(body.url);
|
|
878
970
|
return 0;
|
|
879
971
|
}
|
|
880
972
|
async function versions(args, io) {
|
|
@@ -894,15 +986,27 @@ async function versions(args, io) {
|
|
|
894
986
|
live_version_id,
|
|
895
987
|
versions: vers,
|
|
896
988
|
expires_at: expiresAt,
|
|
897
|
-
...
|
|
989
|
+
...agentNextCommands({ siteId: target.site_id, expiresAt, owned: expiresAt === null })
|
|
898
990
|
}));
|
|
899
991
|
return 0;
|
|
900
992
|
}
|
|
993
|
+
if (io.interactive) {
|
|
994
|
+
for (const line of versionsTable({
|
|
995
|
+
versions: vers,
|
|
996
|
+
liveVersionId: live_version_id,
|
|
997
|
+
expiresAt,
|
|
998
|
+
style: io.style
|
|
999
|
+
})) {
|
|
1000
|
+
io.err(line);
|
|
1001
|
+
}
|
|
1002
|
+
return 0;
|
|
1003
|
+
}
|
|
901
1004
|
for (const v of [...vers].reverse()) {
|
|
902
1005
|
io.out(`${v.version_id} ${timestamp(v.created_at)} ${v.version_id === live_version_id ? "live" : ""}`);
|
|
903
1006
|
}
|
|
904
|
-
|
|
905
|
-
io.
|
|
1007
|
+
if (expiresAt !== null)
|
|
1008
|
+
for (const line of expiryRows({ expiresAt }, io.style))
|
|
1009
|
+
io.err(line);
|
|
906
1010
|
return 0;
|
|
907
1011
|
}
|
|
908
1012
|
async function rollback(args, io) {
|
|
@@ -953,7 +1057,7 @@ async function rollback(args, io) {
|
|
|
953
1057
|
return failSiteRequest("flypod rollback", res, target, args, io, env);
|
|
954
1058
|
const body = await res.json();
|
|
955
1059
|
await touchLink(target, body.live_version_id, env);
|
|
956
|
-
const url = target.rec?.url ?? siteUrlFrom(target.site_id, client.baseUrl);
|
|
1060
|
+
const url = body.url ?? target.rec?.url ?? siteUrlFrom(target.site_id, client.baseUrl);
|
|
957
1061
|
if (args.json) {
|
|
958
1062
|
io.out(JSON.stringify({
|
|
959
1063
|
ok: true,
|
|
@@ -970,7 +1074,8 @@ async function rollback(args, io) {
|
|
|
970
1074
|
})) {
|
|
971
1075
|
io.err(line);
|
|
972
1076
|
}
|
|
973
|
-
io.
|
|
1077
|
+
if (!io.interactive)
|
|
1078
|
+
io.out(url);
|
|
974
1079
|
return 0;
|
|
975
1080
|
}
|
|
976
1081
|
async function token(args, io) {
|
|
@@ -994,7 +1099,7 @@ async function token(args, io) {
|
|
|
994
1099
|
io.out(JSON.stringify({ ok: true, site_id: record.site_id, manage_token: record.manage_token }));
|
|
995
1100
|
return 0;
|
|
996
1101
|
}
|
|
997
|
-
io.err(`Manage token for ${record.site_id}
|
|
1102
|
+
io.err(` Manage token for ${record.site_id}. Treat it like a password.
|
|
998
1103
|
`);
|
|
999
1104
|
io.out(record.manage_token);
|
|
1000
1105
|
return 0;
|
|
@@ -1010,7 +1115,7 @@ async function forget(args, io) {
|
|
|
1010
1115
|
if (args.json)
|
|
1011
1116
|
io.out(JSON.stringify({ ok: true, site_id: args.site, forgotten: n }));
|
|
1012
1117
|
else {
|
|
1013
|
-
io.err(n ? `Forgot ${n} link${n === 1 ? "" : "s"} to ${args.site}
|
|
1118
|
+
io.err(n ? headline(`Forgot ${n} link${n === 1 ? "" : "s"} to ${args.site}`, undefined, io.style ?? PLAIN) : ` No links to ${args.site}.`);
|
|
1014
1119
|
}
|
|
1015
1120
|
return 0;
|
|
1016
1121
|
}
|
|
@@ -1025,7 +1130,7 @@ async function forget(args, io) {
|
|
|
1025
1130
|
}));
|
|
1026
1131
|
return 0;
|
|
1027
1132
|
}
|
|
1028
|
-
io.err(removed && rec ?
|
|
1133
|
+
io.err(removed && rec ? headline("Forgot this folder's link", `site ${rec.site_id} is still live`, io.style ?? PLAIN) : " Nothing is linked to this folder.");
|
|
1029
1134
|
return 0;
|
|
1030
1135
|
}
|
|
1031
1136
|
|
|
@@ -1514,8 +1619,8 @@ function paint(open, s) {
|
|
|
1514
1619
|
}
|
|
1515
1620
|
function makeStyle(enabled) {
|
|
1516
1621
|
if (!enabled) {
|
|
1517
|
-
const
|
|
1518
|
-
return { dim:
|
|
1622
|
+
const id2 = (s) => s;
|
|
1623
|
+
return { dim: id2, bold: id2, accent: id2, ok: id2, err: id2, warn: id2, muted: id2 };
|
|
1519
1624
|
}
|
|
1520
1625
|
return {
|
|
1521
1626
|
dim: (s) => paint("2", s),
|
|
@@ -1523,6 +1628,7 @@ function makeStyle(enabled) {
|
|
|
1523
1628
|
accent: (s) => paint("38;5;191", s),
|
|
1524
1629
|
ok: (s) => paint("38;5;120", s),
|
|
1525
1630
|
err: (s) => paint("38;5;203", s),
|
|
1631
|
+
warn: (s) => paint("38;5;221", s),
|
|
1526
1632
|
muted: (s) => paint("38;5;245", s)
|
|
1527
1633
|
};
|
|
1528
1634
|
}
|
|
@@ -1577,6 +1683,8 @@ function makeSpinner(stream = process.stderr, style = makeStyle(false)) {
|
|
|
1577
1683
|
this.stop();
|
|
1578
1684
|
},
|
|
1579
1685
|
stop() {
|
|
1686
|
+
if (started)
|
|
1687
|
+
clearLine();
|
|
1580
1688
|
if (timer)
|
|
1581
1689
|
clearInterval(timer);
|
|
1582
1690
|
timer = undefined;
|
|
@@ -1643,7 +1751,8 @@ var TOP_LEVEL_FLAG_SPEC = {
|
|
|
1643
1751
|
"-v": "bool",
|
|
1644
1752
|
"--version": "bool",
|
|
1645
1753
|
"--comments": "bool",
|
|
1646
|
-
"--mode": "value"
|
|
1754
|
+
"--mode": "value",
|
|
1755
|
+
"--verbose": "bool"
|
|
1647
1756
|
};
|
|
1648
1757
|
function rejectUnknownFlag(unknown, argv, helpCmd) {
|
|
1649
1758
|
const err = {
|
|
@@ -1655,8 +1764,9 @@ function rejectUnknownFlag(unknown, argv, helpCmd) {
|
|
|
1655
1764
|
process.stdout.write(`${JSON.stringify(errorEnvelope(err))}
|
|
1656
1765
|
`);
|
|
1657
1766
|
} else {
|
|
1658
|
-
process.stderr
|
|
1659
|
-
|
|
1767
|
+
const style = makeStyle(colorsEnabled(process.stderr));
|
|
1768
|
+
process.stderr.write(`${failure(err.error, err.fix, style).join(`
|
|
1769
|
+
`)}
|
|
1660
1770
|
`);
|
|
1661
1771
|
}
|
|
1662
1772
|
process.exit(exitCodeFor(err.code));
|
|
@@ -1672,7 +1782,8 @@ function parseArgs(argv) {
|
|
|
1672
1782
|
help: Boolean(flags["-h"] || flags["--help"]),
|
|
1673
1783
|
version: Boolean(flags["-v"] || flags["--version"]),
|
|
1674
1784
|
comments: Boolean(flags["--comments"]),
|
|
1675
|
-
commentsMode: flags["--mode"] ?? "anonymous"
|
|
1785
|
+
commentsMode: flags["--mode"] ?? "anonymous",
|
|
1786
|
+
verbose: Boolean(flags["--verbose"])
|
|
1676
1787
|
};
|
|
1677
1788
|
}
|
|
1678
1789
|
var SUB_FLAG_SPEC = {
|
|
@@ -1682,7 +1793,8 @@ var SUB_FLAG_SPEC = {
|
|
|
1682
1793
|
"-q": "bool",
|
|
1683
1794
|
"--quiet": "bool",
|
|
1684
1795
|
"-h": "bool",
|
|
1685
|
-
"--help": "bool"
|
|
1796
|
+
"--help": "bool",
|
|
1797
|
+
"--verbose": "bool"
|
|
1686
1798
|
};
|
|
1687
1799
|
var LOGIN_FLAG_SPEC = {
|
|
1688
1800
|
"--token": "value",
|
|
@@ -1706,7 +1818,8 @@ function parseSub(name, argv) {
|
|
|
1706
1818
|
token: flags["--token"],
|
|
1707
1819
|
json: Boolean(flags["--json"]),
|
|
1708
1820
|
quiet: Boolean(flags["-q"] || flags["--quiet"]),
|
|
1709
|
-
help: Boolean(flags["-h"] || flags["--help"])
|
|
1821
|
+
help: Boolean(flags["-h"] || flags["--help"]),
|
|
1822
|
+
verbose: Boolean(flags["--verbose"])
|
|
1710
1823
|
};
|
|
1711
1824
|
}
|
|
1712
1825
|
async function runSubcommand(name, argv) {
|
|
@@ -1715,12 +1828,13 @@ async function runSubcommand(name, argv) {
|
|
|
1715
1828
|
`),
|
|
1716
1829
|
err: (line) => process.stderr.write(`${line}
|
|
1717
1830
|
`),
|
|
1831
|
+
interactive: Boolean(process.stdout.isTTY),
|
|
1718
1832
|
style: makeStyle(colorsEnabled(process.stderr))
|
|
1719
1833
|
};
|
|
1720
1834
|
switch (name) {
|
|
1721
1835
|
case "update": {
|
|
1722
|
-
const { positionals, site, token: token2, json, quiet, help } = parseSub(name, argv);
|
|
1723
|
-
return update({ path: positionals[0], site, token: token2, json, quiet, help }, io);
|
|
1836
|
+
const { positionals, site, token: token2, json, quiet, help, verbose } = parseSub(name, argv);
|
|
1837
|
+
return update({ path: positionals[0], site, token: token2, json, quiet, help, verbose }, io);
|
|
1724
1838
|
}
|
|
1725
1839
|
case "versions": {
|
|
1726
1840
|
const { site, token: token2, json, help } = parseSub(name, argv);
|
|
@@ -1793,9 +1907,9 @@ async function runInstall(argv, io) {
|
|
|
1793
1907
|
if (unknown[0])
|
|
1794
1908
|
rejectUnknownFlag(unknown[0], argv, "flypod install skill --list");
|
|
1795
1909
|
const targets = [];
|
|
1796
|
-
for (const [flag,
|
|
1797
|
-
if (flags[flag] && !targets.includes(
|
|
1798
|
-
targets.push(
|
|
1910
|
+
for (const [flag, id2] of Object.entries(TARGET_FLAGS)) {
|
|
1911
|
+
if (flags[flag] && !targets.includes(id2))
|
|
1912
|
+
targets.push(id2);
|
|
1799
1913
|
}
|
|
1800
1914
|
const all = Boolean(flags["--all"]);
|
|
1801
1915
|
const global = Boolean(flags["--global"]);
|
|
@@ -1881,8 +1995,11 @@ Ownership — two states, one command:
|
|
|
1881
1995
|
|
|
1882
1996
|
Attribution:
|
|
1883
1997
|
flypod adds a small block of <meta> and JSON-LD to served HTML so crawlers
|
|
1884
|
-
can tell what hosts the page. It renders nothing and runs no script.
|
|
1885
|
-
|
|
1998
|
+
can tell what hosts the page. It renders nothing and runs no script. It also
|
|
1999
|
+
fills in link-preview tags a page lacks (og:title, og:description), taken
|
|
2000
|
+
from the page's own title and text, so a pasted URL unfurls properly; tags
|
|
2001
|
+
you wrote are never changed. To turn all of it off, put this anywhere in
|
|
2002
|
+
your page:
|
|
1886
2003
|
|
|
1887
2004
|
<meta name="flypod" content="none">
|
|
1888
2005
|
|
|
@@ -1930,6 +2047,12 @@ Comments (off by default — enabling is one command):
|
|
|
1930
2047
|
flypod comments reopen [<site>] <thread_id> Re-open a thread.
|
|
1931
2048
|
|
|
1932
2049
|
Output:
|
|
2050
|
+
The default is short: the URL, how to ship a change, and when the site
|
|
2051
|
+
ends. Warnings always show.
|
|
2052
|
+
--verbose More of the same receipt. In a terminal: the rollback and
|
|
2053
|
+
history commands, and the site id, version id and source
|
|
2054
|
+
folder. With --json: also the site's tokens, file and byte
|
|
2055
|
+
counts, timing, and the expiry as days and as an ISO date.
|
|
1933
2056
|
--json Emit a stable JSON result on stdout (for agents/scripts).
|
|
1934
2057
|
expires_at is epoch ms, or null once the site is yours.
|
|
1935
2058
|
'warnings' lists problems that survived the deploy, each with
|
|
@@ -1957,16 +2080,14 @@ function shortDir(dir) {
|
|
|
1957
2080
|
const rel = relative(process.cwd(), dir);
|
|
1958
2081
|
return rel === "" || rel.startsWith("..") ? dir : rel || ".";
|
|
1959
2082
|
}
|
|
1960
|
-
function fail2(err, args, style
|
|
2083
|
+
function fail2(err, args, style) {
|
|
1961
2084
|
if (args.json) {
|
|
1962
2085
|
process.stdout.write(`${JSON.stringify(errorEnvelope(err))}
|
|
1963
2086
|
`);
|
|
1964
2087
|
} else {
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
process.stderr.write(` ${head}
|
|
1969
|
-
${fix}
|
|
2088
|
+
process.stderr.write(`${failure(err.error, err.fix, style).join(`
|
|
2089
|
+
`)}
|
|
2090
|
+
|
|
1970
2091
|
`);
|
|
1971
2092
|
}
|
|
1972
2093
|
process.exit(exitCodeFor(err.code));
|
|
@@ -1994,17 +2115,6 @@ async function main() {
|
|
|
1994
2115
|
const { token: apiKey, baseUrl } = client;
|
|
1995
2116
|
const useUI = !args.json && !args.quiet;
|
|
1996
2117
|
const style = makeStyle(colorsEnabled(process.stderr) && useUI);
|
|
1997
|
-
if (useUI) {
|
|
1998
|
-
process.stderr.write(`
|
|
1999
|
-
${style.bold(style.accent("flypod"))} ${style.dim(`v${version}`)}
|
|
2000
|
-
`);
|
|
2001
|
-
if (!apiKey) {
|
|
2002
|
-
process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · deploy now, ")}${style.bold("flypod login")}${style.dim(" later")}
|
|
2003
|
-
`);
|
|
2004
|
-
}
|
|
2005
|
-
process.stderr.write(`
|
|
2006
|
-
`);
|
|
2007
|
-
}
|
|
2008
2118
|
const priorLink = await projectForDir(process.cwd()).catch(() => null);
|
|
2009
2119
|
if (priorLink && useUI) {
|
|
2010
2120
|
for (const line of relinkNotice(priorLink, style))
|
|
@@ -2017,7 +2127,7 @@ async function main() {
|
|
|
2017
2127
|
try {
|
|
2018
2128
|
dir = await resolveDeployDir({ explicit: args.path });
|
|
2019
2129
|
} catch (error) {
|
|
2020
|
-
fail2(
|
|
2130
|
+
fail2(noBuildDir(error.message), args, style);
|
|
2021
2131
|
}
|
|
2022
2132
|
let files;
|
|
2023
2133
|
try {
|
|
@@ -2038,10 +2148,6 @@ async function main() {
|
|
|
2038
2148
|
fix: "Build the site first, then deploy the output folder."
|
|
2039
2149
|
}, args, style);
|
|
2040
2150
|
}
|
|
2041
|
-
if (useUI) {
|
|
2042
|
-
process.stderr.write(` ${style.muted("source")} ${style.bold(shortDir(dir))} ${style.dim(`${fmtCount(fileNames.length, "file")} · ${fmtBytes(totalBytes)}`)}
|
|
2043
|
-
`);
|
|
2044
|
-
}
|
|
2045
2151
|
const spinner = useUI ? makeSpinner(process.stderr, style) : { start: () => {}, update: () => {}, success: () => {}, fail: () => {}, stop: () => {} };
|
|
2046
2152
|
spinner.start(`Uploading ${fmtBytes(totalBytes)}`);
|
|
2047
2153
|
const started = Date.now();
|
|
@@ -2049,12 +2155,12 @@ async function main() {
|
|
|
2049
2155
|
try {
|
|
2050
2156
|
result = await deploySite({ baseUrl, files, apiKey, source: client.source });
|
|
2051
2157
|
} catch (error) {
|
|
2052
|
-
spinner.
|
|
2158
|
+
spinner.stop();
|
|
2053
2159
|
const err = error instanceof DeployError ? await classifyResponse(error.toResponse(), { verb: "flypod" }) : networkError(error, baseUrl);
|
|
2054
|
-
fail2(err, args, style
|
|
2160
|
+
fail2(err, args, style);
|
|
2055
2161
|
}
|
|
2056
2162
|
const elapsed = Date.now() - started;
|
|
2057
|
-
spinner.success(`Deployed in ${fmtSeconds(elapsed)}`);
|
|
2163
|
+
spinner.success(`Deployed in ${fmtSeconds(elapsed)} ${style.dim(`· ${fmtCount(fileNames.length, "file")} · ${fmtBytes(totalBytes)}`)}`);
|
|
2058
2164
|
const owned = typeof result.owner_account_id === "string";
|
|
2059
2165
|
let linkSaved = true;
|
|
2060
2166
|
try {
|
|
@@ -2096,7 +2202,20 @@ async function main() {
|
|
|
2096
2202
|
}
|
|
2097
2203
|
}
|
|
2098
2204
|
if (args.json) {
|
|
2099
|
-
|
|
2205
|
+
const shared = {
|
|
2206
|
+
healed: result.healed ?? [],
|
|
2207
|
+
warnings: result.warnings ?? [],
|
|
2208
|
+
link_saved: linkSaved,
|
|
2209
|
+
...priorLink && priorLink.site_id !== result.site_id ? { replaced_link: { site_id: priorLink.site_id, url: priorLink.url } } : {},
|
|
2210
|
+
...args.comments ? { comments_enabled: commentsEnabled, comments_mode: args.commentsMode } : {}
|
|
2211
|
+
};
|
|
2212
|
+
const nextOpts = {
|
|
2213
|
+
siteId: result.site_id,
|
|
2214
|
+
expiresAt: result.expires_at,
|
|
2215
|
+
owned,
|
|
2216
|
+
linkSaved
|
|
2217
|
+
};
|
|
2218
|
+
const receipt = args.verbose ? {
|
|
2100
2219
|
ok: true,
|
|
2101
2220
|
url: result.url,
|
|
2102
2221
|
site_id: result.site_id,
|
|
@@ -2109,18 +2228,19 @@ async function main() {
|
|
|
2109
2228
|
files: fileNames.length,
|
|
2110
2229
|
bytes: totalBytes,
|
|
2111
2230
|
elapsed_ms: elapsed,
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
}
|
|
2121
|
-
...
|
|
2122
|
-
...
|
|
2123
|
-
}
|
|
2231
|
+
...shared,
|
|
2232
|
+
...agentNext(nextOpts)
|
|
2233
|
+
} : {
|
|
2234
|
+
ok: true,
|
|
2235
|
+
url: result.url,
|
|
2236
|
+
site_id: result.site_id,
|
|
2237
|
+
version_id: result.version_id,
|
|
2238
|
+
expires_at: result.expires_at,
|
|
2239
|
+
...!linkSaved && !owned ? { manage_token: result.manage_token } : {},
|
|
2240
|
+
...shared,
|
|
2241
|
+
...agentNextCommands(nextOpts)
|
|
2242
|
+
};
|
|
2243
|
+
process.stdout.write(`${JSON.stringify(receipt, null, 2)}
|
|
2124
2244
|
`);
|
|
2125
2245
|
return;
|
|
2126
2246
|
}
|
|
@@ -2132,34 +2252,30 @@ async function main() {
|
|
|
2132
2252
|
`);
|
|
2133
2253
|
return;
|
|
2134
2254
|
}
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
`);
|
|
2145
|
-
for (const line of deployTail({ expiresAt: result.expires_at, owned, style })) {
|
|
2255
|
+
for (const line of deployScreen({
|
|
2256
|
+
url: result.url,
|
|
2257
|
+
warnings: result.warnings,
|
|
2258
|
+
expiresAt: result.expires_at,
|
|
2259
|
+
owned,
|
|
2260
|
+
verbose: args.verbose,
|
|
2261
|
+
details: { siteId: result.site_id, versionId: result.version_id, source: shortDir(dir) },
|
|
2262
|
+
style
|
|
2263
|
+
})) {
|
|
2146
2264
|
process.stderr.write(`${line}
|
|
2147
2265
|
`);
|
|
2148
2266
|
}
|
|
2149
|
-
process.stderr.write(`
|
|
2150
|
-
`);
|
|
2151
2267
|
if (!linkSaved && !owned) {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
` + ` ${style.accent(result.manage_token)}
|
|
2155
|
-
|
|
2268
|
+
for (const line of unsavedLinkNotice({ configPath: projectsFilePath(), manageToken: result.manage_token }, style)) {
|
|
2269
|
+
process.stderr.write(`${line}
|
|
2156
2270
|
`);
|
|
2271
|
+
}
|
|
2157
2272
|
} else if (process.env.FLYPOD_SHOW_TOKEN) {
|
|
2158
2273
|
process.stderr.write(` ${style.dim(`manage token ${result.manage_token} — remembered for this folder; needed only with --site elsewhere`)}
|
|
2159
2274
|
|
|
2160
2275
|
`);
|
|
2161
2276
|
}
|
|
2162
|
-
process.stdout.
|
|
2277
|
+
if (!process.stdout.isTTY)
|
|
2278
|
+
process.stdout.write(`${result.url}
|
|
2163
2279
|
`);
|
|
2164
2280
|
}
|
|
2165
2281
|
main().catch((error) => {
|
|
@@ -2168,9 +2284,8 @@ main().catch((error) => {
|
|
|
2168
2284
|
process.stdout.write(`${JSON.stringify(errorEnvelope(err))}
|
|
2169
2285
|
`);
|
|
2170
2286
|
} else {
|
|
2171
|
-
process.stderr.write(`
|
|
2172
|
-
|
|
2173
|
-
|
|
2287
|
+
process.stderr.write(`${failure(err.error, err.fix, PLAIN).join(`
|
|
2288
|
+
`)}
|
|
2174
2289
|
`);
|
|
2175
2290
|
}
|
|
2176
2291
|
process.exit(exitCodeFor(err.code));
|