flypod 0.12.0 → 0.14.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 CHANGED
@@ -452,7 +452,7 @@ publish something.
452
452
  | `deploy_site`, `update_site`, `rollback_site` | Publish a site, publish a new version, go back to an earlier one |
453
453
  | `get_site`, `compare_versions` | A site's URL, expiry and versions; the files that differ between two versions |
454
454
  | `duplicate_site` | Copy a temporary site to a new URL |
455
- | `configure_timeline` | Show or hide the version slider on a site's pages |
455
+ | `configure_timeline` | Show or hide the History chip on a site's pages |
456
456
  | `list_sites`, `rename_site`, `delete_site` | The sites on your account |
457
457
  | `keep_site` | Attach a temporary site to your account so it no longer expires |
458
458
  | `configure_comments`, `list_comments`, `get_comment_thread` | Turn comments on or off; read threads and the moderation queue |
@@ -495,29 +495,21 @@ The way a static export expects, with nothing to configure:
495
495
  - **Caching.** Files whose name carries a build hash (`app.3f9a2c1b.js`,
496
496
  `assets/index-BjK3x9aZ.css`, anything under `_next/static/` or `_astro/`)
497
497
  are served `immutable` for a year. Everything else revalidates after a
498
- minute, so a `flypod update` shows up promptly. For a day after a deploy
499
- (and on a site with the timeline on) it revalidates on every request
500
- instead, which costs a `304` and keeps a reloaded page from pairing new
501
- HTML with an old stylesheet.
502
- - **Live update.** A page that is open when you deploy reloads itself, so a
503
- tab on a second screen or a phone follows your work. It applies for a day
504
- after each deploy: the page asks which version is live, every two seconds
505
- at first and less often as the site settles, and not at all while the tab
506
- is hidden. A site that has not been deployed for a day carries no script.
507
- A page someone has typed into is never reloaded.
498
+ minute, so a `flypod update` shows up promptly.
508
499
  - **Media.** Non-HTML files answer byte-range requests, which is what lets
509
500
  video and audio play on Safari and iOS.
510
501
  - **Link previews.** A page with no `og:title` or `og:description` gets them
511
- from its own `<title>` and first paragraph, and a page with no `og:image`
512
- gets a card: its title and description set in type, with the site's
513
- address underneath. A pasted URL then unfurls with a picture and the
514
- page's own words instead of a bare address. The card is drawn the first
515
- time something asks for it, not at deploy time, and is not a screenshot.
516
- Tags you wrote are never changed. `<meta name="flypod" content="none">`
517
- turns this, live update and the attribution block off.
518
- - **Version timeline** (opt-in). `--timeline` puts a small slider on the
519
- site's pages that steps through its versions, so a reviewer can compare
520
- the third attempt with the fifth without anyone rolling back. It is off
502
+ from its own `<title>` and first paragraph, so a pasted URL unfurls with the
503
+ page's title instead of a bare address. Tags you wrote are never changed.
504
+ `<meta name="flypod" content="none">` turns this and the attribution block
505
+ off.
506
+ - **Version timeline** (opt-in). `--timeline` puts a small History chip on
507
+ the site's pages that lists its versions and opens any of them, each at
508
+ its own address (`<site>--<version>.flypod.page`), and a page at
509
+ `/_flypod/history` that shows two versions side by side, stacked, or
510
+ with a divider to drag across them. A reviewer can compare the third
511
+ attempt with the fifth without anyone rolling back. `flypod versions`
512
+ prints the compare link, and the account page has the same switch. It is off
521
513
  by default because it makes replaced versions public. Versions that are
522
514
  not live are kept for seven days.
523
515
  - **Dead links.** An address with no site shows a browser a short page saying
@@ -583,8 +575,7 @@ Deploy flags:
583
575
  | `--json` | Emit the result as JSON on stdout (replaces the pretty output) |
584
576
  | `--verbose` | More of the same receipt. In a terminal: the rollback and history commands, plus the site id, version id and source folder. With `--json`: also tokens, counts, timing. Also on `flypod update` |
585
577
  | `-q`, `--quiet` | Print only the URL on stdout, and nothing else |
586
- | `--watch` | Keep running and deploy again each time the folder changes. With `--json`, one line per deploy. Ctrl+C to stop. Also on `flypod update` |
587
- | `--timeline`, `--no-timeline` | Show or hide the version slider on the site's pages. Also on `flypod update` |
578
+ | `--timeline`, `--no-timeline` | Turn History on or off: the chip on the site's pages, an address per version, and the compare page. Also on `flypod update`, and on `flypod versions` to switch it without deploying. `--history` is the same flag |
588
579
  | `--comments` | Enable comments on the new site (requires being signed in) |
589
580
  | `--mode <mode>` | With `--comments`: `anonymous` (default), `passcode`, or `approved` |
590
581
  | `-h`, `--help` | Show usage |
@@ -12,7 +12,7 @@ import {
12
12
  resolveCredentials,
13
13
  resolveDeployDir,
14
14
  saveSession
15
- } from "../cli-6255rw94.js";
15
+ } from "../cli-xrnr1hed.js";
16
16
 
17
17
  // bin/deploy.ts
18
18
  import { readFile as readFile2 } from "node:fs/promises";
@@ -471,82 +471,6 @@ function agentNext(opts) {
471
471
  };
472
472
  }
473
473
 
474
- // src/cli/watch.ts
475
- import { createHash } from "node:crypto";
476
- import { readdir, stat } from "node:fs/promises";
477
- import { join } from "node:path";
478
- var POLL_MS = 400;
479
- var RETRY_MS = 5000;
480
- async function snapshot(path) {
481
- const parts = [];
482
- async function walk(current) {
483
- for (const entry of await readdir(current, { withFileTypes: true })) {
484
- const full = join(current, entry.name);
485
- if (entry.isDirectory())
486
- await walk(full);
487
- else {
488
- const info = await stat(full);
489
- parts.push(`${full}\x00${info.size}\x00${info.mtimeMs}`);
490
- }
491
- }
492
- }
493
- try {
494
- const info = await stat(path);
495
- if (info.isFile())
496
- return `${path}\x00${info.size}\x00${info.mtimeMs}`;
497
- await walk(path);
498
- } catch {
499
- return null;
500
- }
501
- return parts.length === 0 ? null : parts.sort().join(`
502
- `);
503
- }
504
- function contentKey(files) {
505
- const hash = createHash("sha1");
506
- for (const name of Object.keys(files).sort()) {
507
- hash.update(name);
508
- hash.update("\x00");
509
- hash.update(files[name]);
510
- hash.update("\x00");
511
- }
512
- return hash.digest("hex");
513
- }
514
- function sleepUntil(ms, signal) {
515
- return new Promise((resolve) => {
516
- if (signal.aborted)
517
- return resolve();
518
- const timer = setTimeout(done, ms);
519
- function done() {
520
- clearTimeout(timer);
521
- signal.removeEventListener("abort", done);
522
- resolve();
523
- }
524
- signal.addEventListener("abort", done);
525
- });
526
- }
527
- async function watchLoop(opts) {
528
- const sleep = opts.sleep ?? ((ms) => sleepUntil(ms, opts.signal));
529
- let shipped = opts.baseline;
530
- let seen = opts.baseline;
531
- while (!opts.signal.aborted) {
532
- await sleep(opts.pollMs ?? POLL_MS);
533
- if (opts.signal.aborted)
534
- return;
535
- const now = await opts.snapshot();
536
- if (now !== seen) {
537
- seen = now;
538
- continue;
539
- }
540
- if (now === null || now === shipped)
541
- continue;
542
- if (await opts.ship() === "retry") {
543
- await sleep(opts.retryMs ?? RETRY_MS);
544
- continue;
545
- }
546
- shipped = now;
547
- }
548
- }
549
-
550
474
  // src/cli/commands.ts
551
475
  function siteUrlFrom(site_id, baseUrl) {
552
476
  const host = new URL(baseUrl).host;
@@ -566,10 +490,8 @@ Ship a new version of the site linked to this folder.
566
490
  Flags:
567
491
  --site <id> Target a site by id instead of the linked folder.
568
492
  --token <tok> Authorize with a manage_token.
569
- --watch Keep running and deploy again each time the folder changes.
570
- With --json, one line per deploy. Ctrl+C to stop.
571
- --timeline Show a version slider on the site's pages, so a visitor can
572
- step back through earlier versions. --no-timeline hides it.
493
+ --timeline Show a History chip on the site's pages, so a visitor can
494
+ open earlier versions and compare two. --no-timeline hides it.
573
495
  --verbose The full receipt: also the rollback command, and with
574
496
  --json the expiry restated as days and an ISO date.
575
497
  --json Emit JSON on stdout (for agents/scripts).
@@ -581,11 +503,17 @@ List every version of the site linked to this folder.
581
503
 
582
504
  flypod versions Show version history for the linked site.
583
505
  flypod versions --site <id> Show versions for a specific site.
506
+ flypod versions --timeline Turn on History for the site, without a deploy.
584
507
 
585
508
  Flags:
586
509
  --site <id> Target a site by id.
587
510
  --token <tok> Authorize with a manage_token.
588
- --json Emit JSON on stdout.
511
+ --timeline Turn on History: a chip on the site's pages that opens
512
+ earlier versions, and a page that compares two. Each version
513
+ then has an address of its own, listed here.
514
+ --no-timeline Turn it off. Earlier versions stop being reachable.
515
+ --json Emit JSON on stdout: also "timeline", and with it on,
516
+ "history_url" and a "url" for each version.
589
517
  -h, --help Show this help.`,
590
518
  rollback: `flypod rollback [version] [flags]
591
519
 
@@ -984,7 +912,7 @@ async function touchLink(target, version_id, env) {
984
912
  await linkProject(target.dir, { ...target.rec, version_id, last_used: Date.now() }, env);
985
913
  }
986
914
  }
987
- async function updateContext(args, io) {
915
+ async function update(args, io) {
988
916
  const pre = await withTarget("update", args, io);
989
917
  if (typeof pre === "number")
990
918
  return pre;
@@ -996,15 +924,13 @@ async function updateContext(args, io) {
996
924
  } catch (e) {
997
925
  return emitError(noBuildDir(e.message), args, io);
998
926
  }
999
- return { env, target, dir, client: await clientForTarget(target, args, io) };
1000
- }
1001
- function clock(ms) {
1002
- const d = new Date(ms);
1003
- const two = (n) => String(n).padStart(2, "0");
1004
- return `${two(d.getHours())}:${two(d.getMinutes())}:${two(d.getSeconds())}`;
1005
- }
1006
- async function publishUpdate(ctx, files, args, io, opts) {
1007
- const { env, target, client } = ctx;
927
+ let files;
928
+ try {
929
+ files = await collectDist(dir);
930
+ } catch (e) {
931
+ return fail("no_files", `Could not read ${dir}: ${e.message}`, args, io);
932
+ }
933
+ const client = await clientForTarget(target, args, io);
1008
934
  let res;
1009
935
  try {
1010
936
  res = await client.redeploy(target.site_id, packDeploy(files));
@@ -1015,11 +941,8 @@ async function publishUpdate(ctx, files, args, io, opts) {
1015
941
  return failSiteRequest("flypod update", res, target, args, io, env);
1016
942
  const body = await res.json();
1017
943
  await touchLink(target, body.version_id, env);
1018
- let timeline;
1019
- if (args.timeline !== undefined && !opts.again) {
1020
- const ok = await client.setTimeline(target.site_id, args.timeline).then((r) => r.ok).catch(() => false);
1021
- timeline = ok ? args.timeline : !args.timeline;
1022
- }
944
+ const switched = args.timeline === undefined ? undefined : await switchTimeline(client, target.site_id, args.timeline);
945
+ const timeline = switched?.timeline;
1023
946
  const expiresAt = body.expires_at !== undefined ? body.expires_at : target.rec?.expires_at ?? null;
1024
947
  if (args.json) {
1025
948
  io.out(JSON.stringify({
@@ -1030,7 +953,7 @@ async function publishUpdate(ctx, files, args, io, opts) {
1030
953
  healed: body.healed ?? [],
1031
954
  warnings: body.warnings ?? [],
1032
955
  expires_at: expiresAt,
1033
- ...timeline !== undefined ? { timeline } : {},
956
+ ...switched ?? {},
1034
957
  ...(args.verbose ? agentNext : agentNextCommands)({
1035
958
  siteId: target.site_id,
1036
959
  expiresAt,
@@ -1040,15 +963,7 @@ async function publishUpdate(ctx, files, args, io, opts) {
1040
963
  return 0;
1041
964
  }
1042
965
  if (args.quiet) {
1043
- if (!opts.again)
1044
- io.out(body.url);
1045
- return 0;
1046
- }
1047
- const s = io.style ?? PLAIN;
1048
- if (opts.again) {
1049
- io.err(headline("Updated", `${clock(Date.now())} · version ${shortVersion(body.version_id)}`, s));
1050
- for (const line of warningLines(body.warnings, s))
1051
- io.err(line);
966
+ io.out(body.url);
1052
967
  return 0;
1053
968
  }
1054
969
  for (const line of updateScreen({
@@ -1062,94 +977,66 @@ async function publishUpdate(ctx, files, args, io, opts) {
1062
977
  io.err(line);
1063
978
  }
1064
979
  if (timeline !== undefined) {
1065
- for (const line of timelineRows(args.timeline, timeline, s))
980
+ for (const line of timelineRows(args.timeline, timeline, io.style ?? PLAIN, switched?.history_url)) {
1066
981
  io.err(line);
982
+ }
1067
983
  }
1068
984
  if (!io.interactive)
1069
985
  io.out(body.url);
1070
986
  return 0;
1071
987
  }
1072
- function timelineRows(asked, now, s) {
988
+ async function switchTimeline(client, siteId, enabled) {
989
+ try {
990
+ const res = await client.setTimeline(siteId, enabled);
991
+ if (!res.ok)
992
+ return { timeline: !enabled };
993
+ const body = await res.json().catch(() => ({}));
994
+ return {
995
+ timeline: enabled,
996
+ ...enabled && typeof body.history_url === "string" ? { history_url: body.history_url } : {}
997
+ };
998
+ } catch {
999
+ return { timeline: !enabled };
1000
+ }
1001
+ }
1002
+ function timelineRows(asked, now, s, historyUrl) {
1073
1003
  if (asked !== now) {
1074
- return [field("timeline", "not changed", "the server refused; run it again", s), ""];
1004
+ return [field("history", "not changed", "the server refused; run it again", s), ""];
1075
1005
  }
1076
1006
  return [
1077
- field("timeline", now ? "on" : "off", now ? "visitors can step back through versions" : "only the live version is public", s),
1007
+ field("history", now ? "on" : "off", now ? "visitors can open earlier versions" : "only the live version is public", s),
1008
+ ...now && historyUrl ? [field("compare", historyUrl, undefined, s)] : [],
1078
1009
  ""
1079
1010
  ];
1080
1011
  }
1081
- async function watchUpdates(ctx, args, io, state) {
1082
- const controller = new AbortController;
1083
- const stop = () => controller.abort();
1084
- if (io.signal) {
1085
- if (io.signal.aborted)
1086
- stop();
1087
- else
1088
- io.signal.addEventListener("abort", stop, { once: true });
1089
- } else {
1090
- process.once("SIGINT", stop);
1091
- process.once("SIGTERM", stop);
1092
- }
1093
- if (!args.json && !args.quiet) {
1094
- io.err(field("watching", ctx.dir, "saves deploy · Ctrl+C to stop", io.style ?? PLAIN));
1095
- io.err("");
1096
- }
1097
- let shipped = state.shipped;
1098
- await watchLoop({
1099
- baseline: state.baseline,
1100
- snapshot: () => snapshot(ctx.dir),
1101
- signal: controller.signal,
1102
- pollMs: io.watchPollMs,
1103
- ship: async () => {
1104
- let files;
1105
- try {
1106
- files = await collectDist(ctx.dir);
1107
- } catch {
1108
- return "retry";
1109
- }
1110
- const key = contentKey(files);
1111
- if (Object.keys(files).length === 0 || key === shipped)
1112
- return "done";
1113
- const code = await publishUpdate(ctx, files, args, io, { again: true });
1114
- if (code === 0)
1115
- shipped = key;
1116
- return code === 4 ? "retry" : "done";
1117
- }
1118
- });
1119
- return 0;
1120
- }
1121
- async function update(args, io) {
1122
- const ctx = await updateContext(args, io);
1123
- if (typeof ctx === "number")
1124
- return ctx;
1125
- const baseline = args.watch ? await snapshot(ctx.dir) : null;
1126
- let files;
1127
- try {
1128
- files = await collectDist(ctx.dir);
1129
- } catch (e) {
1130
- return fail("no_files", `Could not read ${ctx.dir}: ${e.message}`, args, io);
1131
- }
1132
- const code = await publishUpdate(ctx, files, args, io, { again: false });
1133
- if (code !== 0 || !args.watch)
1134
- return code;
1135
- return watchUpdates(ctx, args, io, { baseline, shipped: contentKey(files) });
1136
- }
1137
- async function watchSite(args, io, state) {
1138
- const ctx = await updateContext(args, io);
1139
- if (typeof ctx === "number")
1140
- return ctx;
1141
- return watchUpdates(ctx, args, io, state);
1142
- }
1143
1012
  async function versions(args, io) {
1144
1013
  const pre = await withTarget("versions", args, io);
1145
1014
  if (typeof pre === "number")
1146
1015
  return pre;
1147
1016
  const { env, target } = pre;
1017
+ if (args.timeline !== undefined) {
1018
+ const client = await clientForTarget(target, args, io);
1019
+ let res;
1020
+ try {
1021
+ res = await client.setTimeline(target.site_id, args.timeline);
1022
+ } catch (e) {
1023
+ return emitError(networkError(e, client.baseUrl), args, io, { prefix: "flypod versions" });
1024
+ }
1025
+ if (!res.ok)
1026
+ return failSiteRequest("flypod versions", res, target, args, io, env);
1027
+ }
1148
1028
  const site = await fetchSite("flypod versions", target, args, io, env);
1149
1029
  if ("error" in site)
1150
1030
  return site.error;
1151
1031
  const { live_version_id, versions: vers } = site.data;
1152
1032
  const expiresAt = site.data.expires_at ?? null;
1033
+ const timeline = Boolean(site.data.timeline);
1034
+ const historyRows = () => {
1035
+ const s = io.style ?? PLAIN;
1036
+ if (timeline)
1037
+ return timelineRows(true, true, s, site.data.history_url);
1038
+ return [field("history", "off", "flypod versions --timeline turns it on", s), ""];
1039
+ };
1153
1040
  if (args.json) {
1154
1041
  io.out(JSON.stringify({
1155
1042
  ok: true,
@@ -1157,6 +1044,8 @@ async function versions(args, io) {
1157
1044
  live_version_id,
1158
1045
  versions: vers,
1159
1046
  expires_at: expiresAt,
1047
+ timeline,
1048
+ ...site.data.history_url ? { history_url: site.data.history_url } : {},
1160
1049
  ...agentNextCommands({ siteId: target.site_id, expiresAt, owned: expiresAt === null })
1161
1050
  }));
1162
1051
  return 0;
@@ -1170,6 +1059,8 @@ async function versions(args, io) {
1170
1059
  })) {
1171
1060
  io.err(line);
1172
1061
  }
1062
+ for (const line of historyRows())
1063
+ io.err(line);
1173
1064
  return 0;
1174
1065
  }
1175
1066
  for (const v of [...vers].reverse()) {
@@ -1178,6 +1069,9 @@ async function versions(args, io) {
1178
1069
  if (expiresAt !== null)
1179
1070
  for (const line of expiryRows({ expiresAt }, io.style))
1180
1071
  io.err(line);
1072
+ if (timeline || args.timeline !== undefined)
1073
+ for (const line of historyRows())
1074
+ io.err(line);
1181
1075
  return 0;
1182
1076
  }
1183
1077
  async function rollback(args, io) {
@@ -1914,9 +1808,9 @@ var INSTALL_FLAG_SPEC = {
1914
1808
  ...Object.fromEntries(Object.keys(TARGET_FLAGS).map((f) => [f, "bool"]))
1915
1809
  };
1916
1810
  function timelineFlag(flags) {
1917
- if (flags["--no-timeline"])
1811
+ if (flags["--no-timeline"] || flags["--no-history"])
1918
1812
  return false;
1919
- return flags["--timeline"] ? true : undefined;
1813
+ return flags["--timeline"] || flags["--history"] ? true : undefined;
1920
1814
  }
1921
1815
  var TOP_LEVEL_FLAG_SPEC = {
1922
1816
  "--json": "bool",
@@ -1929,9 +1823,10 @@ var TOP_LEVEL_FLAG_SPEC = {
1929
1823
  "--comments": "bool",
1930
1824
  "--mode": "value",
1931
1825
  "--verbose": "bool",
1932
- "--watch": "bool",
1933
1826
  "--timeline": "bool",
1934
- "--no-timeline": "bool"
1827
+ "--no-timeline": "bool",
1828
+ "--history": "bool",
1829
+ "--no-history": "bool"
1935
1830
  };
1936
1831
  function rejectUnknownFlag(unknown, argv, helpCmd) {
1937
1832
  const err = {
@@ -1963,7 +1858,6 @@ function parseArgs(argv) {
1963
1858
  comments: Boolean(flags["--comments"]),
1964
1859
  commentsMode: flags["--mode"] ?? "anonymous",
1965
1860
  verbose: Boolean(flags["--verbose"]),
1966
- watch: Boolean(flags["--watch"]),
1967
1861
  timeline: timelineFlag(flags)
1968
1862
  };
1969
1863
  }
@@ -1976,9 +1870,10 @@ var SUB_FLAG_SPEC = {
1976
1870
  "-h": "bool",
1977
1871
  "--help": "bool",
1978
1872
  "--verbose": "bool",
1979
- "--watch": "bool",
1980
1873
  "--timeline": "bool",
1981
- "--no-timeline": "bool"
1874
+ "--no-timeline": "bool",
1875
+ "--history": "bool",
1876
+ "--no-history": "bool"
1982
1877
  };
1983
1878
  var LOGIN_FLAG_SPEC = {
1984
1879
  "--token": "value",
@@ -2004,12 +1899,11 @@ function parseSub(name, argv) {
2004
1899
  quiet: Boolean(flags["-q"] || flags["--quiet"]),
2005
1900
  help: Boolean(flags["-h"] || flags["--help"]),
2006
1901
  verbose: Boolean(flags["--verbose"]),
2007
- watch: Boolean(flags["--watch"]),
2008
1902
  timeline: timelineFlag(flags)
2009
1903
  };
2010
1904
  }
2011
- function terminalIO() {
2012
- return {
1905
+ async function runSubcommand(name, argv) {
1906
+ const io = {
2013
1907
  out: (line) => process.stdout.write(`${line}
2014
1908
  `),
2015
1909
  err: (line) => process.stderr.write(`${line}
@@ -2017,17 +1911,14 @@ function terminalIO() {
2017
1911
  interactive: Boolean(process.stdout.isTTY),
2018
1912
  style: makeStyle(colorsEnabled(process.stderr))
2019
1913
  };
2020
- }
2021
- async function runSubcommand(name, argv) {
2022
- const io = terminalIO();
2023
1914
  switch (name) {
2024
1915
  case "update": {
2025
- const { positionals, site, token: token2, json, quiet, help, verbose, watch, timeline } = parseSub(name, argv);
2026
- return update({ path: positionals[0], site, token: token2, json, quiet, help, verbose, watch, timeline }, io);
1916
+ const { positionals, site, token: token2, json, quiet, help, verbose, timeline } = parseSub(name, argv);
1917
+ return update({ path: positionals[0], site, token: token2, json, quiet, help, verbose, timeline }, io);
2027
1918
  }
2028
1919
  case "versions": {
2029
- const { site, token: token2, json, help } = parseSub(name, argv);
2030
- return versions({ site, token: token2, json, help }, io);
1920
+ const { site, token: token2, json, help, timeline } = parseSub(name, argv);
1921
+ return versions({ site, token: token2, json, help, timeline }, io);
2031
1922
  }
2032
1923
  case "rollback": {
2033
1924
  const { positionals, site, token: token2, json, help } = parseSub(name, argv);
@@ -2184,16 +2075,11 @@ Ownership — two states, one command:
2184
2075
 
2185
2076
  Attribution:
2186
2077
  flypod adds a small block of <meta> and JSON-LD to served HTML so crawlers
2187
- can tell what hosts the page. It renders nothing. It also fills in the
2188
- link-preview tags a page lacks (og:title, og:description, and an og:image
2189
- card drawn from the two), taken from the page's own title and text, so a
2190
- pasted URL unfurls properly; tags you wrote are never changed.
2191
-
2192
- For a day after each deploy, pages also carry a few lines of script that
2193
- reload the page when the next version lands, so an open tab follows your
2194
- work. A page someone has typed into is left alone.
2195
-
2196
- To turn all of it off, put this anywhere in your page:
2078
+ can tell what hosts the page. It renders nothing and runs no script. It also
2079
+ fills in link-preview tags a page lacks (og:title, og:description), taken
2080
+ from the page's own title and text, so a pasted URL unfurls properly; tags
2081
+ you wrote are never changed. To turn all of it off, put this anywhere in
2082
+ your page:
2197
2083
 
2198
2084
  <meta name="flypod" content="none">
2199
2085
 
@@ -2219,15 +2105,14 @@ Agents:
2219
2105
  CLI, Copilot). Add --global for your home dir,
2220
2106
  --list to see the paths, --dry-run to preview.
2221
2107
 
2222
- Deploy flags (the first three also work on 'flypod update'):
2223
- --watch Keep running: deploy again each time the folder
2224
- changes. An open page of the site reloads by
2225
- itself, so a save shows up in the browser.
2226
- Ctrl+C to stop. With --json, one line per deploy.
2227
- --timeline Show a version slider on the site's pages, so a
2228
- visitor can step back through earlier versions.
2229
- Off by default: it makes replaced versions public.
2230
- --no-timeline Turn the slider off again.
2108
+ Deploy flags:
2109
+ --timeline Turn on History: a chip on the site's pages
2110
+ that opens earlier versions, and a page that
2111
+ compares two side by side. Off by default: it
2112
+ makes replaced versions public. Also on
2113
+ 'flypod update', and on 'flypod versions' to
2114
+ switch it without deploying.
2115
+ --no-timeline Turn History off again.
2231
2116
  --comments Enable comments on the new site (mode: anonymous).
2232
2117
  --comments --mode <mode> Same, but choose the mode: anonymous|passcode|
2233
2118
  approved.
@@ -2331,7 +2216,6 @@ async function main() {
2331
2216
  } catch (error) {
2332
2217
  fail2(noBuildDir(error.message), args, style);
2333
2218
  }
2334
- const baseline = args.watch ? await snapshot(dir) : null;
2335
2219
  let files;
2336
2220
  try {
2337
2221
  files = await collectDist(dir);
@@ -2404,23 +2288,12 @@ async function main() {
2404
2288
  } catch {}
2405
2289
  }
2406
2290
  }
2407
- let timeline;
2291
+ let switched;
2408
2292
  if (args.timeline !== undefined) {
2409
2293
  const siteClient = owned ? client : await createClient({ overrides: { manageToken: result.manage_token, baseUrl } });
2410
- const ok = await siteClient.setTimeline(result.site_id, args.timeline).then((r) => r.ok).catch(() => false);
2411
- timeline = ok ? args.timeline : !args.timeline;
2412
- }
2413
- const keepWatching = async () => {
2414
- if (!args.watch)
2415
- return;
2416
- const code = await watchSite({
2417
- path: dir,
2418
- json: args.json,
2419
- quiet: args.quiet,
2420
- ...linkSaved ? {} : { site: result.site_id, ...owned ? {} : { token: result.manage_token } }
2421
- }, terminalIO(), { baseline, shipped: contentKey(files) });
2422
- process.exit(code);
2423
- };
2294
+ switched = await switchTimeline(siteClient, result.site_id, args.timeline);
2295
+ }
2296
+ const timeline = switched?.timeline;
2424
2297
  if (args.json) {
2425
2298
  const shared = {
2426
2299
  healed: result.healed ?? [],
@@ -2428,7 +2301,7 @@ async function main() {
2428
2301
  link_saved: linkSaved,
2429
2302
  ...priorLink && priorLink.site_id !== result.site_id ? { replaced_link: { site_id: priorLink.site_id, url: priorLink.url } } : {},
2430
2303
  ...args.comments ? { comments_enabled: commentsEnabled, comments_mode: args.commentsMode } : {},
2431
- ...timeline !== undefined ? { timeline } : {}
2304
+ ...switched ?? {}
2432
2305
  };
2433
2306
  const nextOpts = {
2434
2307
  siteId: result.site_id,
@@ -2461,9 +2334,8 @@ async function main() {
2461
2334
  ...shared,
2462
2335
  ...agentNextCommands(nextOpts)
2463
2336
  };
2464
- process.stdout.write(`${JSON.stringify(receipt, null, args.watch ? undefined : 2)}
2337
+ process.stdout.write(`${JSON.stringify(receipt, null, 2)}
2465
2338
  `);
2466
- await keepWatching();
2467
2339
  return;
2468
2340
  }
2469
2341
  if (args.quiet) {
@@ -2472,7 +2344,6 @@ async function main() {
2472
2344
  if (!linkSaved && !owned)
2473
2345
  process.stderr.write(`${result.manage_token}
2474
2346
  `);
2475
- await keepWatching();
2476
2347
  return;
2477
2348
  }
2478
2349
  for (const line of deployScreen({
@@ -2488,7 +2359,7 @@ async function main() {
2488
2359
  `);
2489
2360
  }
2490
2361
  if (timeline !== undefined) {
2491
- for (const line of timelineRows(args.timeline, timeline, style)) {
2362
+ for (const line of timelineRows(args.timeline, timeline, style, switched?.history_url)) {
2492
2363
  process.stderr.write(`${line}
2493
2364
  `);
2494
2365
  }
@@ -2506,7 +2377,6 @@ async function main() {
2506
2377
  if (!process.stdout.isTTY)
2507
2378
  process.stdout.write(`${result.url}
2508
2379
  `);
2509
- await keepWatching();
2510
2380
  }
2511
2381
  main().catch((error) => {
2512
2382
  const err = unexpectedError(error);
@@ -518,34 +518,22 @@ the site you already made, and the URL holds.
518
518
  flypod update ./dist
519
519
  \`\`\`
520
520
 
521
- A page of the site that is open in a browser reloads itself when the new
522
- version lands, for a day after each deploy. Tell the user they can leave the
523
- tab open; they do not need to refresh.
524
-
525
- ### Deploy on every save
526
-
527
- \`\`\`sh
528
- flypod update ./dist --watch # the linked site
529
- flypod ./dist --watch # a new site, then keep watching
530
- \`\`\`
531
-
532
- \`--watch\` keeps running and ships a new version each time the folder stops
533
- changing. **It never exits**, so run it in the background and stop it when the
534
- work is done; do not wait on it. With \`--json\` it prints one line per deploy.
535
- Use it when the user is iterating with you and watching the page; for a single
536
- change, a plain \`flypod update\` is simpler.
537
-
538
521
  ### Let a reviewer compare versions
539
522
 
540
523
  \`\`\`sh
541
- flypod update --timeline # --no-timeline turns it off
524
+ flypod update --timeline # with the next deploy
525
+ flypod versions --timeline --json # now, without deploying
526
+ flypod versions --no-timeline # off again
542
527
  \`\`\`
543
528
 
544
- \`--timeline\` (also on \`flypod\`) puts a slider on the site's pages that steps
545
- through its versions without changing what is live. Offer it when the user is
529
+ \`--timeline\` (also on \`flypod\`) puts a History chip on the site's pages that lists
530
+ its versions and opens any of them, plus a page that compares two side by
531
+ side (\`<site url>/_flypod/history\`), without changing what is live. Offer it when the user is
546
532
  choosing between iterations. It is off by default because it makes replaced
547
533
  versions public: do not turn it on for a site where an earlier version held
548
- something that was removed on purpose. Versions that are not live are kept
534
+ something that was removed on purpose. With it on, \`--json\` carries a
535
+ \`history_url\` to give the user (two versions side by side), and
536
+ \`flypod versions --json\` a \`url\` for each version. Versions that are not live are kept
549
537
  for seven days.
550
538
 
551
539
  ## Where sites live
@@ -577,11 +565,6 @@ Every site also answers \`/llms.txt\` with a list of its pages, generated from
577
565
  the deploy unless the folder ships its own. Another agent handed the URL can
578
566
  start there; you do not need to write the file.
579
567
 
580
- A pasted link unfurls with the page's title, description and a preview card
581
- drawn from them, unless the page sets its own \`og:\` tags. Give each page a
582
- real \`<title>\` and a first paragraph that says what it is, and the link looks
583
- finished wherever the user shares it; you do not need to make an image.
584
-
585
568
  ## Deeper reference
586
569
 
587
570
  Open these when the task calls for them.
@@ -1,3 +1,4 @@
1
+ import { type FlypodClient } from "./client";
1
2
  import { type TailStyle } from "./receipt";
2
3
  type FetchLike = typeof fetch;
3
4
  export interface CommandIO {
@@ -19,10 +20,6 @@ export interface CommandIO {
19
20
  * what it has always been.
20
21
  */
21
22
  interactive?: boolean;
22
- /** Ends a `--watch` loop when aborted. Tests inject one; the binary uses Ctrl+C. */
23
- signal?: AbortSignal;
24
- /** How often `--watch` looks at the folder. Tests shorten it; see ./watch.ts for the default. */
25
- watchPollMs?: number;
26
23
  /** Open a URL in the default browser. Tests inject a no-op. */
27
24
  openUrl?: (url: string) => Promise<void>;
28
25
  /**
@@ -50,7 +47,7 @@ export declare function claim(args: {
50
47
  token?: string;
51
48
  json?: boolean;
52
49
  }, io: CommandIO): Promise<number>;
53
- interface UpdateArgs {
50
+ export declare function update(args: {
54
51
  path?: string;
55
52
  site?: string;
56
53
  token?: string;
@@ -59,28 +56,27 @@ interface UpdateArgs {
59
56
  help?: boolean;
60
57
  /** The full receipt instead of the short default. See receipt.ts. */
61
58
  verbose?: boolean;
62
- /** Keep running and redeploy whenever the folder changes. See ./watch.ts. */
63
- watch?: boolean;
64
59
  /** Turn the version timeline on (`true`) or off (`false`); unset leaves it alone. */
65
60
  timeline?: boolean;
66
- }
67
- /** What the screen says after `--timeline` / `--no-timeline`. */
68
- export declare function timelineRows(asked: boolean, now: boolean, s: TailStyle): string[];
69
- export declare function update(args: UpdateArgs, io: CommandIO): Promise<number>;
61
+ }, io: CommandIO): Promise<number>;
70
62
  /**
71
- * Carry on from a first deploy made with `flypod --watch`: the site exists
72
- * and has just been published, so this only watches. `state` is what that
73
- * deploy read from disk.
63
+ * Turn the version timeline on or off, and report the state the site is
64
+ * actually in: a refusal leaves it as it was. `history_url` is where two
65
+ * versions can be compared, present only while the timeline is on.
74
66
  */
75
- export declare function watchSite(args: UpdateArgs, io: CommandIO, state: {
76
- baseline: string | null;
77
- shipped: string | null;
78
- }): Promise<number>;
67
+ export declare function switchTimeline(client: FlypodClient, siteId: string, enabled: boolean): Promise<{
68
+ timeline: boolean;
69
+ history_url?: string;
70
+ }>;
71
+ /** What the screen says after `--timeline` / `--no-timeline`. */
72
+ export declare function timelineRows(asked: boolean, now: boolean, s: TailStyle, historyUrl?: string): string[];
79
73
  export declare function versions(args: {
80
74
  site?: string;
81
75
  token?: string;
82
76
  json?: boolean;
83
77
  help?: boolean;
78
+ /** Turn the version timeline on or off before listing; unset leaves it alone. */
79
+ timeline?: boolean;
84
80
  }, io: CommandIO): Promise<number>;
85
81
  export declare function rollback(args: {
86
82
  version?: string;
package/dist/src/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  collectDist,
5
5
  deploySite,
6
6
  resolveDeployDir
7
- } from "../cli-6255rw94.js";
7
+ } from "../cli-xrnr1hed.js";
8
8
  export {
9
9
  BUILD_DIR_CANDIDATES,
10
10
  DeployError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flypod",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Zero-auth deploy primitive. Turns any folder into a live URL in one command. For AI agents and humans.",
5
5
  "module": "./dist/src/cli.js",
6
6
  "types": "./dist/src/cli.d.ts",
@@ -1,39 +0,0 @@
1
- /**
2
- * A fingerprint of what is on disk at `path` (a folder or a single file):
3
- * every file's name, size and modification time. Null when there is nothing
4
- * to deploy there right now — the path is missing or the folder is empty,
5
- * which is what the middle of a build looks like.
6
- */
7
- export declare function snapshot(path: string): Promise<string | null>;
8
- /**
9
- * A fingerprint of the content about to be deployed. A save that changes
10
- * nothing (an editor rewriting the same bytes, a build that produced identical
11
- * output) changes the snapshot above but not this, and is not worth a deploy.
12
- */
13
- export declare function contentKey(files: Record<string, Uint8Array>): string;
14
- export interface WatchLoopOptions {
15
- /** The snapshot of what was last deployed, taken before that deploy read the folder. */
16
- baseline: string | null;
17
- snapshot(): Promise<string | null>;
18
- /**
19
- * Publish what is on disk now. `"retry"` means it failed for a reason that
20
- * may pass (the network, a rate limit) and the same content should be tried
21
- * again; anything else is final until the folder changes.
22
- */
23
- ship(): Promise<"done" | "retry">;
24
- /** Stops the loop. */
25
- signal: AbortSignal;
26
- /** Injected by tests. */
27
- sleep?: (ms: number) => Promise<void>;
28
- pollMs?: number;
29
- retryMs?: number;
30
- }
31
- /**
32
- * Poll until stopped, shipping each time the folder has changed and then held
33
- * still for one tick.
34
- *
35
- * "Held still" is the debounce: a build writes its files over a second or
36
- * two, and deploying the first half of one publishes a broken site. A folder
37
- * that reads the same on two consecutive ticks has finished changing.
38
- */
39
- export declare function watchLoop(opts: WatchLoopOptions): Promise<void>;