flypod 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  // src/cli.ts
2
- import { readdir, readFile as readFile4, realpath, stat as stat2 } from "node:fs/promises";
3
- import { join as join4, relative, sep } from "node:path";
2
+ import { readdir as readdir2, readFile as readFile4, realpath, stat as stat3 } from "node:fs/promises";
3
+ import { homedir as homedir4 } from "node:os";
4
+ import { join as join5, parse, relative, resolve as resolve2, sep } from "node:path";
4
5
 
5
6
  // src/deploy-source.ts
6
7
  var SOURCE_HEADER = "x-flypod-source";
@@ -20,142 +21,55 @@ function coerceSource(value) {
20
21
 
21
22
  // src/cli/install-id.ts
22
23
  import { randomBytes } from "node:crypto";
23
- import { readFile } from "node:fs/promises";
24
- import { join as join2 } from "node:path";
25
-
26
- // src/cli/paths.ts
27
- import { mkdir, rename, writeFile } from "node:fs/promises";
28
- import { homedir, platform } from "node:os";
29
- import { dirname, join } from "node:path";
30
- function configDir(env = process.env) {
31
- if (env.FLYPOD_CONFIG_DIR)
32
- return env.FLYPOD_CONFIG_DIR;
33
- const os = platform();
34
- if (os === "darwin") {
35
- return join(homedir(), "Library", "Application Support", "flypod");
36
- }
37
- if (os === "win32") {
38
- const appData = env.APPDATA ?? join(homedir(), "AppData", "Roaming");
39
- return join(appData, "flypod");
40
- }
41
- const xdg = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
42
- return join(xdg, "flypod");
43
- }
44
- function sessionFilePath(env = process.env) {
45
- return join(configDir(env), "session.json");
46
- }
47
- function projectsFilePath(env = process.env) {
48
- return join(configDir(env), "projects.json");
49
- }
50
- async function atomicWriteFile(path, content) {
51
- await mkdir(dirname(path), { recursive: true });
52
- const tmp = `${path}.tmp`;
53
- await writeFile(tmp, content, { mode: 384 });
54
- await rename(tmp, path);
55
- }
56
-
57
- // src/cli/install-id.ts
58
- var ID_RE = /^[A-Za-z0-9_-]{16,64}$/;
59
- var VERSION_RE = /^\d{1,3}\.\d{1,3}\.\d{1,3}(?:-[0-9A-Za-z.-]{1,20})?$/;
60
- var INSTALL_HEADER = "x-flypod-install";
61
- var INSTALL_NEW_HEADER = "x-flypod-install-new";
62
- var VERSION_HEADER = "x-flypod-version";
63
- var RELINK_HEADER = "x-flypod-relink";
64
- function telemetryOptedOut(env) {
65
- const dnt = env.DO_NOT_TRACK;
66
- if (dnt !== undefined && !["", "0", "false"].includes(dnt.trim().toLowerCase()))
24
+ import { readFile as readFile3 } from "node:fs/promises";
25
+ import { join as join4 } from "node:path";
26
+
27
+ // src/cli/agent-env.ts
28
+ var set = (v) => v !== undefined && v.trim() !== "" && v.trim() !== "0";
29
+ function fromAiAgent(value) {
30
+ const name = value.trim().toLowerCase();
31
+ if (name.startsWith("claude"))
32
+ return "claude_code";
33
+ if (name.startsWith("codex"))
34
+ return "codex";
35
+ if (name.startsWith("cursor"))
36
+ return "cursor";
37
+ if (name.startsWith("gemini"))
38
+ return "gemini";
39
+ if (name.startsWith("opencode"))
40
+ return "opencode";
41
+ return "other";
42
+ }
43
+ function detectCodingAgent(env) {
44
+ if (set(env.AI_AGENT))
45
+ return fromAiAgent(env.AI_AGENT);
46
+ if (set(env.CLAUDECODE) || set(env.CLAUDE_CODE_ENTRYPOINT))
47
+ return "claude_code";
48
+ if (set(env.CURSOR_AGENT))
49
+ return "cursor";
50
+ if (set(env.GEMINI_CLI))
51
+ return "gemini";
52
+ if (set(env.CODEX_SANDBOX) || set(env.CODEX_SANDBOX_NETWORK_DISABLED) || set(env.CODEX_THREAD_ID) || set(env.CODEX_MANAGED_BY_NPM)) {
53
+ return "codex";
54
+ }
55
+ return "none";
56
+ }
57
+ function detectCi(env) {
58
+ const ci = (env.CI ?? "").trim().toLowerCase();
59
+ if (ci !== "" && ci !== "0" && ci !== "false")
67
60
  return true;
68
- const own = env.FLYPOD_TELEMETRY;
69
- return own !== undefined && ["0", "false", "off", "no"].includes(own.trim().toLowerCase());
70
- }
71
- function installFilePath(env = process.env) {
72
- return join2(configDir(env), "install.json");
61
+ return env.GITHUB_ACTIONS === "true";
73
62
  }
74
- var cache = new Map;
75
- function installId(env = process.env) {
76
- if (telemetryOptedOut(env))
77
- return Promise.resolve(null);
78
- let path;
79
- try {
80
- path = installFilePath(env);
81
- } catch {
82
- return Promise.resolve(null);
83
- }
84
- let pending = cache.get(path);
85
- if (!pending) {
86
- pending = loadOrCreate(path);
87
- cache.set(path, pending);
88
- }
89
- return pending;
90
- }
91
- async function loadOrCreate(path) {
92
- try {
93
- const saved = JSON.parse(await readFile(path, "utf8"));
94
- if (typeof saved.install_id === "string" && ID_RE.test(saved.install_id)) {
95
- return { id: saved.install_id, isNew: false };
96
- }
97
- } catch {}
98
- const id = randomBytes(16).toString("base64url");
99
- try {
100
- await atomicWriteFile(path, `${JSON.stringify({ install_id: id, created_at: new Date().toISOString() }, null, 2)}
101
- `);
102
- } catch {
103
- return null;
104
- }
105
- return { id, isNew: true };
106
- }
107
- var version;
108
- function setCliVersion(v) {
109
- version = VERSION_RE.test(v) ? v : undefined;
110
- }
111
- async function identityHeaders(env) {
112
- const headers = {};
113
- if (version)
114
- headers[VERSION_HEADER] = version;
115
- const install = await installId(env);
116
- if (install) {
117
- headers[INSTALL_HEADER] = install.id;
118
- if (install.isNew)
119
- headers[INSTALL_NEW_HEADER] = "1";
120
- }
121
- return headers;
122
- }
123
- var FIRST_RUN_NOTICE = "flypod counts deploys with a random id. DO_NOT_TRACK=1 stops it.";
124
63
 
125
- // src/cli/session.ts
126
- import { readFile as readFile2, unlink } from "node:fs/promises";
127
- async function loadSession(env) {
128
- try {
129
- const path = sessionFilePath(env);
130
- const text = await readFile2(path, "utf8");
131
- const parsed = JSON.parse(text);
132
- if (typeof parsed?.session_token === "string" && typeof parsed?.base_url === "string" && typeof parsed?.created_at === "number") {
133
- return parsed;
134
- }
135
- return null;
136
- } catch {
137
- return null;
138
- }
139
- }
140
- async function saveSession(session, env) {
141
- const path = sessionFilePath(env);
142
- await atomicWriteFile(path, `${JSON.stringify(session, null, 2)}
143
- `);
144
- return path;
145
- }
146
- async function clearSession(env) {
147
- try {
148
- await unlink(sessionFilePath(env));
149
- return true;
150
- } catch {
151
- return false;
152
- }
153
- }
64
+ // src/cli/agent-guide.ts
65
+ import { open, readdir, stat as stat2 } from "node:fs/promises";
66
+ import { homedir as homedir3 } from "node:os";
67
+ import { dirname as dirname3, join as join3, resolve } from "node:path";
154
68
 
155
69
  // src/cli/skill.ts
156
- import { mkdir as mkdir2, readFile as readFile3, stat, writeFile as writeFile2 } from "node:fs/promises";
70
+ import { mkdir as mkdir2, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
157
71
  import { homedir as homedir2 } from "node:os";
158
- import { dirname as dirname2, join as join3 } from "node:path";
72
+ import { dirname as dirname2, join as join2 } from "node:path";
159
73
 
160
74
  // src/cli/screen.ts
161
75
  var WIDTH = 66;
@@ -238,9 +152,89 @@ function storedZipBytes(files) {
238
152
  return total;
239
153
  }
240
154
 
155
+ // src/cli/session.ts
156
+ import { readFile, unlink } from "node:fs/promises";
157
+
158
+ // src/cli/paths.ts
159
+ import { mkdir, rename, writeFile } from "node:fs/promises";
160
+ import { homedir, platform } from "node:os";
161
+ import { dirname, join } from "node:path";
162
+ function configDir(env = process.env) {
163
+ if (env.FLYPOD_CONFIG_DIR)
164
+ return env.FLYPOD_CONFIG_DIR;
165
+ const os = platform();
166
+ if (os === "darwin") {
167
+ return join(homedir(), "Library", "Application Support", "flypod");
168
+ }
169
+ if (os === "win32") {
170
+ const appData = env.APPDATA ?? join(homedir(), "AppData", "Roaming");
171
+ return join(appData, "flypod");
172
+ }
173
+ const xdg = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
174
+ return join(xdg, "flypod");
175
+ }
176
+ function sessionFilePath(env = process.env) {
177
+ return join(configDir(env), "session.json");
178
+ }
179
+ function projectsFilePath(env = process.env) {
180
+ return join(configDir(env), "projects.json");
181
+ }
182
+ async function atomicWriteFile(path, content) {
183
+ await mkdir(dirname(path), { recursive: true });
184
+ const tmp = `${path}.tmp`;
185
+ await writeFile(tmp, content, { mode: 384 });
186
+ await rename(tmp, path);
187
+ }
188
+
189
+ // src/cli/session.ts
190
+ async function loadSession(env) {
191
+ try {
192
+ const path = sessionFilePath(env);
193
+ const text = await readFile(path, "utf8");
194
+ const parsed = JSON.parse(text);
195
+ if (typeof parsed?.session_token === "string" && typeof parsed?.base_url === "string" && typeof parsed?.created_at === "number") {
196
+ return parsed;
197
+ }
198
+ return null;
199
+ } catch {
200
+ return null;
201
+ }
202
+ }
203
+ async function saveSession(session, env) {
204
+ const path = sessionFilePath(env);
205
+ await atomicWriteFile(path, `${JSON.stringify(session, null, 2)}
206
+ `);
207
+ return path;
208
+ }
209
+ async function clearSession(env) {
210
+ try {
211
+ await unlink(sessionFilePath(env));
212
+ return true;
213
+ } catch {
214
+ return false;
215
+ }
216
+ }
217
+
218
+ // src/cli/source.ts
219
+ async function resolveCliSource(env, cwd, opts = {}) {
220
+ const explicit = env.FLYPOD_SOURCE;
221
+ if (explicit)
222
+ return coerceSource(explicit);
223
+ try {
224
+ if (await skillInstalledIn(cwd))
225
+ return "skill";
226
+ const tty = opts.stdoutIsTTY ?? Boolean(process.stdout.isTTY);
227
+ const agentRun = detectCodingAgent(env) !== "none" || !tty;
228
+ return agentRun && await skillInstalledGlobally(env) ? "skill" : "cli";
229
+ } catch {
230
+ return "cli";
231
+ }
232
+ }
233
+
241
234
  // src/cli/telemetry.ts
242
235
  var REPORT_TIMEOUT_MS = 1500;
243
236
  var TELEMETRY_PATH = "/telemetry/cli";
237
+ var NOT_FAILURES = new Set(["authorization_pending"]);
244
238
  var run = null;
245
239
  var pending = new Set;
246
240
  function startFailureReports(opts) {
@@ -260,6 +254,8 @@ function reportFailure(err, args) {
260
254
  const current = run;
261
255
  if (!current || telemetryOptedOut(current.env))
262
256
  return;
257
+ if (NOT_FAILURES.has(err.code))
258
+ return;
263
259
  const agent = current.stdoutPiped || Boolean(args.json);
264
260
  const sent = send(current, reportBody(err, current.verb, agent)).catch(() => {});
265
261
  pending.add(sent);
@@ -286,8 +282,8 @@ async function send(r, body) {
286
282
  if (!uploadLimitsFor(baseUrl))
287
283
  return;
288
284
  const headers = {
289
- ...await identityHeaders(r.env),
290
- [SOURCE_HEADER]: await resolveCliSource(r.env, r.cwd),
285
+ ...await identityHeaders(r.env, { cwd: r.cwd }),
286
+ [SOURCE_HEADER]: await resolveCliSource(r.env, r.cwd, { stdoutIsTTY: !r.stdoutPiped }),
291
287
  "content-type": "application/json"
292
288
  };
293
289
  const res = await r.fetch(new URL(TELEMETRY_PATH, baseUrl).toString(), {
@@ -390,12 +386,25 @@ async function readServerMessage(res) {
390
386
  code: typeof body.code === "string" ? body.code : undefined,
391
387
  json: true,
392
388
  ...typeof body.fix === "string" && body.fix ? { fix: body.fix } : {},
393
- ...typeof body.limit === "string" ? { limit: body.limit } : {}
389
+ ...typeof body.limit === "string" ? { limit: body.limit } : {},
390
+ ...typeof body.request_id === "string" && body.request_id ? { requestId: body.request_id } : {}
394
391
  };
395
392
  } catch {
396
- return { message: text.length > 200 ? `${text.slice(0, 200)}…` : text };
393
+ const cfError = cloudflareErrorNumber(text);
394
+ return {
395
+ message: text.length > 200 ? `${text.slice(0, 200)}…` : text,
396
+ ...cfError !== undefined ? { cfError } : {}
397
+ };
397
398
  }
398
399
  }
400
+ function cloudflareErrorNumber(text) {
401
+ const m = text.match(/\berror(?: code)?:?\s*(1\d{3})\b/i);
402
+ return m ? Number(m[1]) : undefined;
403
+ }
404
+ var CF_ERRORS = {
405
+ 1101: "the server crashed on this request",
406
+ 1102: "the server ran out of CPU time or memory on this request"
407
+ };
399
408
  async function classifyResponse(res, ctx) {
400
409
  const said = await readServerMessage(res);
401
410
  const err = classifyParsed(res, said, ctx);
@@ -406,6 +415,7 @@ async function classifyResponse(res, ctx) {
406
415
  }
407
416
  return err;
408
417
  }
418
+ var UNAUTHORIZED_FIX = "Run `flypod login`, or pass --token <manage_token> for a site this machine does not remember.";
409
419
  var SIZE_LIMITS = ["files", "total_bytes", "zip_bytes"];
410
420
  function classifyParsed(res, said, ctx) {
411
421
  const { message, code: serverCode, json } = said;
@@ -451,7 +461,7 @@ function classifyParsed(res, said, ctx) {
451
461
  ...base,
452
462
  code: "unauthorized",
453
463
  error: `Not authorized for site${site}.`,
454
- fix: "Run `flypod login`, or pass --token <manage_token> for a site this machine does not remember."
464
+ fix: UNAUTHORIZED_FIX
455
465
  };
456
466
  case 404:
457
467
  return ctx.siteScoped ? {
@@ -484,17 +494,36 @@ function classifyParsed(res, said, ctx) {
484
494
  extra: retryAfter(res)
485
495
  };
486
496
  default:
487
- if (status >= 500) {
488
- return {
489
- ...base,
490
- code: "server_error",
491
- error: `${ctx.verb}: the server returned ${status}.`,
492
- fix: "Retry in a moment; if it keeps failing, check https://flypod.dev/status."
493
- };
494
- }
497
+ if (status >= 500)
498
+ return serverError(status, said, ctx.verb);
495
499
  return { ...base, code: "bad_request", error: `${ctx.verb}: ${message}` };
496
500
  }
497
501
  }
502
+ function serverError(status, said, verb) {
503
+ const origin = said.json ? "app" : "edge";
504
+ const telemetry = { origin };
505
+ if (said.cfError !== undefined)
506
+ telemetry.cf_error = said.cfError;
507
+ if (origin === "app") {
508
+ return {
509
+ status,
510
+ code: "server_error",
511
+ error: `${verb}: the server hit an error (HTTP ${status}).`,
512
+ fix: said.requestId ? `Retry in a moment; if it keeps failing, check https://flypod.dev/status and quote request_id ${said.requestId}.` : "Retry in a moment; if it keeps failing, check https://flypod.dev/status.",
513
+ ...said.requestId ? { extra: { request_id: said.requestId } } : {},
514
+ telemetry
515
+ };
516
+ }
517
+ const cf = said.cfError;
518
+ const known = cf !== undefined ? CF_ERRORS[cf] : undefined;
519
+ return {
520
+ status,
521
+ code: "server_error",
522
+ error: known ? `${verb}: ${known} (HTTP ${status}, Cloudflare error ${cf}).` : `${verb}: the server's hosting platform returned ${status}${cf !== undefined ? ` (Cloudflare error ${cf})` : ""}.`,
523
+ fix: cf === 1102 ? "Retry in a moment. If it fails again, a smaller upload (fewer or lighter files) will get through." : "Retry in a moment; if it keeps failing, check https://flypod.dev/status.",
524
+ telemetry
525
+ };
526
+ }
498
527
  function retryAfter(res) {
499
528
  const raw = res.headers.get("retry-after");
500
529
  const seconds = raw ? Number(raw) : Number.NaN;
@@ -527,6 +556,64 @@ var NO_SITE = {
527
556
  error: "No flypod site is linked to this folder.",
528
557
  fix: "Run `flypod` here to create one, or pass --site <id>."
529
558
  };
559
+ function noSite(ctx) {
560
+ const make = (reason, error, fix, siteId) => ({
561
+ code: "no_site",
562
+ error,
563
+ fix,
564
+ extra: { reason, ...siteId ? { site_id: siteId } : {} },
565
+ telemetry: { reason }
566
+ });
567
+ if (ctx.gone?.reason === "expired") {
568
+ const day = new Date(ctx.gone.at).toISOString().slice(0, 10);
569
+ return make("expired", `This folder's site ${ctx.gone.url} expired on ${day}, as temporary sites do.`, "Run `flypod` to make a new site, then `flypod login` to keep it: a site on an account does not expire.", ctx.gone.site_id);
570
+ }
571
+ if (ctx.gone) {
572
+ return make("gone", `This folder's site ${ctx.gone.url} no longer exists: it expired or was deleted.`, "Run `flypod` to make a new site.", ctx.gone.site_id);
573
+ }
574
+ if (ctx.nearby) {
575
+ return make("other_folder", `No flypod site is linked to this folder, but ${ctx.nearby.dir} is linked to ${ctx.nearby.site_id}.`, `Run it from ${ctx.nearby.dir}, or name the site: \`flypod ${ctx.verb} --site ${ctx.nearby.site_id}\`.`, ctx.nearby.site_id);
576
+ }
577
+ return make("never_linked", "No flypod site is linked to this folder.", ctx.signedIn ? "Run `flypod` here to make the site, or pass --site <id> (`flypod list` shows yours)." : "Run `flypod` here to make the site. For one made elsewhere, pass --site <id>.");
578
+ }
579
+ function unauthorizedFor(ctx) {
580
+ const base = {
581
+ code: "unauthorized",
582
+ status: ctx.status,
583
+ telemetry: { credential: ctx.sent, known: ctx.known, target: ctx.target }
584
+ };
585
+ const id2 = ctx.siteId;
586
+ switch (ctx.sent) {
587
+ case "flag":
588
+ return {
589
+ ...base,
590
+ error: `The --token you passed does not manage site ${id2}.`,
591
+ fix: "Pass that site's own token, or run `flypod login` with the account that owns the site and leave --token out."
592
+ };
593
+ case "manage_token":
594
+ return {
595
+ ...base,
596
+ error: `Site ${id2} refused the token this machine holds for it: it was kept by an account, or it no longer exists.`,
597
+ fix: "If you kept it with an account, run `flypod login` with that account and run this again. Otherwise run `flypod` to make a new site."
598
+ };
599
+ case "account":
600
+ return {
601
+ ...base,
602
+ error: `Site ${id2} is not on the account you are signed in to, or it no longer exists.`,
603
+ fix: "Run `flypod list` to see the sites on your account, or `flypod login` with the account that owns this one."
604
+ };
605
+ default:
606
+ return ctx.known ? {
607
+ ...base,
608
+ error: `Site ${id2} belongs to an account, and this machine is not signed in.`,
609
+ fix: "Run `flypod login` with the account that owns it, then run this again."
610
+ } : {
611
+ ...base,
612
+ error: `This machine holds nothing that can change site ${id2}: it was made on another machine or install.`,
613
+ fix: "Run `flypod login` with the account that owns it. A temporary site can only be changed where it was made; to start again here, run `flypod`."
614
+ };
615
+ }
616
+ }
530
617
  var NOT_SIGNED_IN = {
531
618
  code: "not_signed_in",
532
619
  error: "Not signed in.",
@@ -798,13 +885,27 @@ step when there is one; \`status\` is the HTTP status when a server answered. Co
798
885
  \`invalid_upload\`, \`too_large\`, \`blocked\`, \`challenge_required\`,
799
886
  \`rate_limited\`, \`server_error\`, \`network\`, \`unknown_flag\`, \`usage\`.
800
887
 
888
+ \`flypod update\` has already retried a \`server_error\` or \`network\` failure once
889
+ before reporting it, so do not loop on it: wait a minute before one more try.
890
+ When flypod itself answered, the JSON carries a \`request_id\` to quote.
891
+
801
892
  \`usage\` includes a value flag given no value (\`--site needs a value\`) and a
802
893
  \`--mode\` that is not \`anonymous\`, \`passcode\` or \`approved\`. \`unknown_flag\`
803
894
  names the closest real flag when there is one. \`no_build_dir\` also covers a
804
- path that does not exist. \`too_large\` is checked before uploading to flypod.dev
895
+ path that does not exist; its \`fix\` is the command to run, such as
896
+ "Run \`npm run build\`, then \`flypod ./dist\`" for a project that is not built.
897
+ \`too_large\` is checked before uploading to flypod.dev
805
898
  (at most 200 files, 10 MB of files, 12 MB as an upload) and names the largest files.
806
- Read its \`fix\`: when the folder is a project root, or most of it is source maps
807
- or video, it says so and names the folder or the \`.flypodignore\` line to use.
899
+ Read its \`fix\`: when the folder is a project root, or most of it is source maps,
900
+ video or images, it says so and names the folder or the \`.flypodignore\` lines to use.
901
+
902
+ \`no_site\` carries a \`reason\`: \`never_linked\` (run \`flypod\` to make the site),
903
+ \`expired\` (the temporary site ran out: run \`flypod\` for a new one, then
904
+ \`flypod login\` to keep it), \`gone\` (the site no longer exists: run \`flypod\`), or
905
+ \`other_folder\` (a folder above or below this one is linked: the \`fix\` gives the
906
+ \`--site <id>\` command). \`unauthorized\` on a version verb says what to do with the
907
+ credential this machine holds; when the site was kept by the account you are
908
+ signed in to, flypod retries as that account by itself.
808
909
 
809
910
  Rarer ones: \`unknown_command\` (a verb that does not exist — \`flypod verisons\`
810
911
  fails this way with \`"fix": "flypod versions"\` instead of deploying a folder
@@ -838,6 +939,10 @@ Each warning has a \`code\` and a \`fix_recipe\` naming the change to make.
838
939
  - \`missing-index\` — nothing is served at \`/\`. Name the entry file \`index.html\`.
839
940
  - \`not-spa\` — the page ships scripts but also has visible body content, so
840
941
  client-side routing fallback stays off and deep links will 404 on refresh.
942
+ - \`new-site-in-linked-folder\` — \`flypod\` ran in a folder that already had a
943
+ site, so it made a second one. The deploy is live; do not redo it. Next time,
944
+ ship with \`flypod update\`. To put this build on the earlier URL instead, run
945
+ the \`flypod update --site <id>\` the warning names.
841
946
 
842
947
  \`healed\` lists what flypod fixed on your behalf. \`spa-fallback\` there means it
843
948
  recognised a single-page app, so unknown paths serve \`index.html\` and
@@ -865,7 +970,7 @@ it would otherwise outlive.
865
970
  | \`FLYPOD_TOKEN\` | Deploy as your account without logging in (agents / CI) |
866
971
  | \`DEPLOY_URL\` | Point at a different flypod server (default \`https://flypod.dev\`) |
867
972
  | \`FLYPOD_CONFIG_DIR\` | Relocate the session + folder→site memory |
868
- | \`DO_NOT_TRACK\` | \`1\` turns off the CLI's random install id and its failure reports (codes and counts, never file names) |
973
+ | \`DO_NOT_TRACK\` | \`1\` turns off the CLI's random install id, the fixed words naming which agent ran it, how it was launched and whether this project's agent instructions mention flypod, and its failure reports (codes and counts, never file names or contents) |
869
974
 
870
975
  \`FLYPOD_TOKEN\` wins over a saved \`flypod login\` session; \`--token\` and a site's own
871
976
  stored manage token win over both. \`FLYPOD_API_KEY\` is read only as a last-resort
@@ -897,12 +1002,17 @@ files; flypod serves them.
897
1002
 
898
1003
  1. Build first, if the project has a build — flypod serves files, it does not
899
1004
  make them. You want a folder whose contents *are* the finished site.
900
- 2. Deploy it:
1005
+ 2. Deploy it. **The first time**, \`flypod\` makes the site:
901
1006
 
902
1007
  \`\`\`sh
903
1008
  npx flypod ./dist --json
904
1009
  \`\`\`
905
1010
 
1011
+ **Every later deploy** of the same project is \`flypod update\`, which ships
1012
+ to the URL the user already has (see "Shipping a change"). Running \`flypod\`
1013
+ again makes a second site on a new URL, and the receipt then carries a
1014
+ \`new-site-in-linked-folder\` warning.
1015
+
906
1016
  3. Read \`url\` from the JSON and give it to the user.
907
1017
 
908
1018
  **Done when** the user has the URL, and \`warnings\` is empty or you have told
@@ -910,7 +1020,10 @@ them what is in it.
910
1020
 
911
1021
  Omit the path and flypod auto-detects a build folder, trying \`dist\`, \`build\`,
912
1022
  \`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\` — each of
913
- which must hold an \`index.html\`. Pass the path whenever you know it.
1023
+ which must hold an \`index.html\` (or one app folder that does, as Angular's
1024
+ \`dist/<app>/browser\`). A folder with an \`index.html\` and no \`package.json\` deploys
1025
+ as it is. Pass the path whenever you know it. \`flypod update\` with no path
1026
+ deploys the folder the site was last deployed from.
914
1027
 
915
1028
  A single file deploys too: \`flypod report.html\`. For several, deploy the folder.
916
1029
 
@@ -987,8 +1100,9 @@ flypod login --json
987
1100
  # {"ok":false,"code":"interactive_login_required","error":"…","fix":"…","verification_uri":"https://…","verification_uri_complete":"https://…","user_code":"ABCD-1234","device_code":"…","expires_in":600,"interval":5}
988
1101
  \`\`\`
989
1102
 
990
- It exits at once (code 2). Give the user the URL and the code; when they say
991
- they have confirmed, finish with the \`device_code\` from that output:
1103
+ It exits at once (code 2). Give the user the URL and the \`user_code\`; when they
1104
+ say they have confirmed, finish with the \`device_code\` (not the \`user_code\`)
1105
+ from that output:
992
1106
 
993
1107
  \`\`\`sh
994
1108
  flypod login --device-code <device_code> --json
@@ -996,6 +1110,11 @@ flypod login --device-code <device_code> --json
996
1110
  # {"ok":false,"code":"authorization_pending",…} — exit 4, ask again later
997
1111
  \`\`\`
998
1112
 
1113
+ \`authorization_pending\` means the user has not confirmed yet: wait \`interval\`
1114
+ seconds and run the same command again. \`login_expired\` means the code is
1115
+ spent (expired, or already used): if an earlier run printed
1116
+ \`"ok":true\` you are signed in, otherwise start again with \`flypod login --json\`.
1117
+
999
1118
  A successful login also attaches every temporary site this machine deployed;
1000
1119
  \`attached\` lists them.
1001
1120
 
@@ -1090,30 +1209,30 @@ var TARGETS = [
1090
1209
  id: "claude",
1091
1210
  label: "Claude Code",
1092
1211
  detail: ".claude/skills/flypod/ — loaded on demand",
1093
- projectDir: (root) => join3(root, ".claude", "skills", SKILL_NAME),
1094
- globalDir: (env) => join3(home(env), ".claude", "skills", SKILL_NAME)
1212
+ projectDir: (root) => join2(root, ".claude", "skills", SKILL_NAME),
1213
+ globalDir: (env) => join2(home(env), ".claude", "skills", SKILL_NAME)
1095
1214
  },
1096
1215
  {
1097
1216
  id: "agents",
1098
1217
  label: "Agent Skills (shared)",
1099
1218
  detail: ".agents/skills/flypod/ — Codex, Cursor, Gemini CLI, Copilot",
1100
- projectDir: (root) => join3(root, ".agents", "skills", SKILL_NAME),
1101
- globalDir: (env) => join3(home(env), ".agents", "skills", SKILL_NAME)
1219
+ projectDir: (root) => join2(root, ".agents", "skills", SKILL_NAME),
1220
+ globalDir: (env) => join2(home(env), ".agents", "skills", SKILL_NAME)
1102
1221
  }
1103
1222
  ];
1104
1223
  var LEGACY_PATHS = [
1105
1224
  "AGENTS.md",
1106
1225
  "GEMINI.md",
1107
- join3(".github", "copilot-instructions.md"),
1108
- join3(".cursor", "rules", `${SKILL_NAME}.mdc`),
1109
- join3(".windsurf", "rules", `${SKILL_NAME}.md`),
1110
- join3(".clinerules", `${SKILL_NAME}.md`),
1111
- join3(".roo", "rules", `${SKILL_NAME}.md`)
1226
+ join2(".github", "copilot-instructions.md"),
1227
+ join2(".cursor", "rules", `${SKILL_NAME}.mdc`),
1228
+ join2(".windsurf", "rules", `${SKILL_NAME}.md`),
1229
+ join2(".clinerules", `${SKILL_NAME}.md`),
1230
+ join2(".roo", "rules", `${SKILL_NAME}.md`)
1112
1231
  ];
1113
1232
  var LEGACY_SHARED = new Set([
1114
1233
  "AGENTS.md",
1115
1234
  "GEMINI.md",
1116
- join3(".github", "copilot-instructions.md")
1235
+ join2(".github", "copilot-instructions.md")
1117
1236
  ]);
1118
1237
  var LEGACY_MARK = `<!-- ${SKILL_NAME}:begin -->`;
1119
1238
  async function exists(path) {
@@ -1127,7 +1246,7 @@ async function exists(path) {
1127
1246
  async function legacyArtifacts(root) {
1128
1247
  const found = [];
1129
1248
  for (const rel of LEGACY_PATHS) {
1130
- const path = join3(root, rel);
1249
+ const path = join2(root, rel);
1131
1250
  if (!await exists(path))
1132
1251
  continue;
1133
1252
  if (!LEGACY_SHARED.has(rel)) {
@@ -1135,7 +1254,7 @@ async function legacyArtifacts(root) {
1135
1254
  continue;
1136
1255
  }
1137
1256
  try {
1138
- if ((await readFile3(path, "utf8")).includes(LEGACY_MARK))
1257
+ if ((await readFile2(path, "utf8")).includes(LEGACY_MARK))
1139
1258
  found.push(rel);
1140
1259
  } catch {}
1141
1260
  }
@@ -1143,17 +1262,35 @@ async function legacyArtifacts(root) {
1143
1262
  }
1144
1263
  async function skillInstalledIn(root) {
1145
1264
  for (const target of TARGETS) {
1146
- if (await exists(join3(target.projectDir(root), "SKILL.md")))
1265
+ if (await exists(join2(target.projectDir(root), "SKILL.md")))
1147
1266
  return true;
1148
1267
  }
1149
1268
  return (await legacyArtifacts(root)).length > 0;
1150
1269
  }
1270
+ function globalSkillDirs(env) {
1271
+ const h = home(env);
1272
+ return [
1273
+ ...TARGETS.map((t) => t.globalDir(env)),
1274
+ join2(h, ".codex", "skills", SKILL_NAME),
1275
+ join2(h, ".cursor", "skills", SKILL_NAME),
1276
+ join2(h, ".gemini", "skills", SKILL_NAME),
1277
+ join2(h, ".copilot", "skills", SKILL_NAME),
1278
+ join2(h, ".config", "opencode", "skills", SKILL_NAME)
1279
+ ];
1280
+ }
1281
+ async function skillInstalledGlobally(env) {
1282
+ for (const dir of globalSkillDirs(env)) {
1283
+ if (await exists(join2(dir, "SKILL.md")))
1284
+ return true;
1285
+ }
1286
+ return false;
1287
+ }
1151
1288
  async function writeTarget(target, dir) {
1152
1289
  const results = [];
1153
1290
  for (const [rel, content] of Object.entries(skillFiles())) {
1154
- const path = join3(dir, rel);
1291
+ const path = join2(dir, rel);
1155
1292
  const had = await exists(path);
1156
- if (had && await readFile3(path, "utf8") === content) {
1293
+ if (had && await readFile2(path, "utf8") === content) {
1157
1294
  results.push({ target, path, status: "unchanged" });
1158
1295
  continue;
1159
1296
  }
@@ -1226,14 +1363,14 @@ async function installSkill(args, callerIo) {
1226
1363
  emit({
1227
1364
  ok: true,
1228
1365
  dry_run: true,
1229
- files: selected.flatMap((e) => Object.keys(skillFiles()).map((rel) => join3(e.dir, rel)))
1366
+ files: selected.flatMap((e) => Object.keys(skillFiles()).map((rel) => join2(e.dir, rel)))
1230
1367
  });
1231
1368
  return 0;
1232
1369
  }
1233
1370
  io.err("Would write:");
1234
1371
  for (const e of selected) {
1235
1372
  for (const rel of Object.keys(skillFiles()))
1236
- io.out(join3(e.dir, rel));
1373
+ io.out(join2(e.dir, rel));
1237
1374
  }
1238
1375
  return 0;
1239
1376
  }
@@ -1280,18 +1417,255 @@ async function installSkill(args, callerIo) {
1280
1417
  return 0;
1281
1418
  }
1282
1419
 
1283
- // src/cli/source.ts
1284
- async function resolveCliSource(env, cwd) {
1285
- const explicit = env.FLYPOD_SOURCE;
1286
- if (explicit)
1287
- return coerceSource(explicit);
1420
+ // src/cli/agent-guide.ts
1421
+ var MAX_LEVELS = 4;
1422
+ var MAX_BYTES = 32 * 1024;
1423
+ var MAX_RULES = 20;
1424
+ var NEEDLE = "flypod";
1425
+ var FILES = [
1426
+ ["agents_md", "AGENTS.md"],
1427
+ ["claude_md", "CLAUDE.md"],
1428
+ ["claude_md", join3(".claude", "CLAUDE.md")],
1429
+ ["cursor_rules", ".cursorrules"],
1430
+ ["copilot", join3(".github", "copilot-instructions.md")],
1431
+ ["gemini_md", "GEMINI.md"]
1432
+ ];
1433
+ async function mentions(path) {
1434
+ let fh;
1288
1435
  try {
1289
- return await skillInstalledIn(cwd) ? "skill" : "cli";
1436
+ fh = await open(path, "r");
1437
+ const buf = new Uint8Array(MAX_BYTES);
1438
+ const { bytesRead } = await fh.read(buf, 0, MAX_BYTES, 0);
1439
+ return new TextDecoder().decode(buf.subarray(0, bytesRead)).toLowerCase().includes(NEEDLE);
1290
1440
  } catch {
1291
- return "cli";
1441
+ return false;
1442
+ } finally {
1443
+ await fh?.close().catch(() => {});
1444
+ }
1445
+ }
1446
+ async function cursorRulesMention(dir) {
1447
+ let names;
1448
+ try {
1449
+ names = await readdir(join3(dir, ".cursor", "rules"));
1450
+ } catch {
1451
+ return false;
1452
+ }
1453
+ const rules = names.filter((n) => /\.mdc?$/i.test(n)).slice(0, MAX_RULES);
1454
+ for (const name of rules) {
1455
+ if (await mentions(join3(dir, ".cursor", "rules", name)))
1456
+ return true;
1457
+ }
1458
+ return false;
1459
+ }
1460
+ async function guideIn(dir) {
1461
+ if (await skillInstalledIn(dir).catch(() => false))
1462
+ return "skill";
1463
+ for (const [kind, rel] of FILES) {
1464
+ if (await mentions(join3(dir, rel)))
1465
+ return kind;
1466
+ if (rel === ".cursorrules" && await cursorRulesMention(dir))
1467
+ return "cursor_rules";
1468
+ }
1469
+ return null;
1470
+ }
1471
+ async function isRepoRoot(dir) {
1472
+ try {
1473
+ await stat2(join3(dir, ".git"));
1474
+ return true;
1475
+ } catch {
1476
+ return false;
1477
+ }
1478
+ }
1479
+ async function detectAgentGuide(cwd, opts = {}) {
1480
+ try {
1481
+ const home2 = resolve(opts.home ?? homedir3());
1482
+ let dir = resolve(cwd);
1483
+ for (let level = 0;level < MAX_LEVELS + 1; level++) {
1484
+ if (dir === home2)
1485
+ break;
1486
+ const found = await guideIn(dir);
1487
+ if (found)
1488
+ return found;
1489
+ if (await isRepoRoot(dir))
1490
+ break;
1491
+ const parent = dirname3(dir);
1492
+ if (parent === dir)
1493
+ break;
1494
+ dir = parent;
1495
+ }
1496
+ return "none";
1497
+ } catch {
1498
+ return "none";
1499
+ }
1500
+ }
1501
+ var cache = new Map;
1502
+ function agentGuideFor(cwd, opts = {}) {
1503
+ const key = `${resolve(cwd)}\x00${opts.home ?? ""}`;
1504
+ let pending2 = cache.get(key);
1505
+ if (!pending2) {
1506
+ pending2 = detectAgentGuide(cwd, opts);
1507
+ cache.set(key, pending2);
1508
+ }
1509
+ return pending2;
1510
+ }
1511
+
1512
+ // src/cli/invoked-via.ts
1513
+ import { realpathSync } from "node:fs";
1514
+ function norm(p) {
1515
+ return p.replace(/\\/g, "/").toLowerCase();
1516
+ }
1517
+ function real(p) {
1518
+ try {
1519
+ return realpathSync(p);
1520
+ } catch {
1521
+ return p;
1522
+ }
1523
+ }
1524
+ function manager(env) {
1525
+ const ua = (env.npm_config_user_agent ?? "").trim().toLowerCase();
1526
+ const name = ua.split("/")[0] ?? "";
1527
+ if (name)
1528
+ return name;
1529
+ const exec = norm(env.npm_execpath ?? "");
1530
+ if (exec.includes("pnpm"))
1531
+ return "pnpm";
1532
+ if (exec.includes("yarn"))
1533
+ return "yarn";
1534
+ if (exec.includes("bun"))
1535
+ return "bun";
1536
+ return exec ? "npm" : "";
1537
+ }
1538
+ function fetched(path, env) {
1539
+ if (path.includes("/_npx/"))
1540
+ return "npx";
1541
+ if (/\/bunx-[^/]*\//.test(path))
1542
+ return "bunx";
1543
+ if (/\/pnpm(-cache)?\/dlx\//.test(path))
1544
+ return "pnpm_dlx";
1545
+ if (/\/dlx-[^/]*\//.test(path)) {
1546
+ const by = manager(env);
1547
+ if (by === "yarn" || /\/xfs-[^/]*\//.test(path))
1548
+ return "yarn_dlx";
1549
+ if (by === "pnpm")
1550
+ return "pnpm_dlx";
1551
+ }
1552
+ return null;
1553
+ }
1554
+ var GLOBAL_PATTERNS = [
1555
+ /\/lib\/node_modules\//,
1556
+ /\/npm\/node_modules\//,
1557
+ /\/\.bun\/install\/global\//,
1558
+ /\/pnpm\/global\//,
1559
+ /\/yarn\/global\//,
1560
+ /\/\.volta\/tools\//
1561
+ ];
1562
+ function detectInvokedVia(env, script, cwd) {
1563
+ try {
1564
+ const path = script ? norm(real(script)) : "";
1565
+ const viaPath = path ? fetched(path, env) : null;
1566
+ if (viaPath)
1567
+ return viaPath;
1568
+ const lifecycle = (env.npm_lifecycle_event ?? "").trim();
1569
+ if (lifecycle && lifecycle !== "npx" && lifecycle !== "bunx")
1570
+ return "script";
1571
+ const at = path.indexOf("/node_modules/");
1572
+ if (at > 0) {
1573
+ const root = path.slice(0, at);
1574
+ const here = norm(real(cwd)).replace(/\/+$/, "");
1575
+ if (here === root || here.startsWith(`${root}/`))
1576
+ return "local";
1577
+ if (GLOBAL_PATTERNS.some((re) => re.test(path)))
1578
+ return "global";
1579
+ }
1580
+ if (env.npm_command === "exec" || lifecycle === "npx")
1581
+ return "npx";
1582
+ if (lifecycle === "bunx")
1583
+ return "bunx";
1584
+ return "other";
1585
+ } catch {
1586
+ return "other";
1292
1587
  }
1293
1588
  }
1294
1589
 
1590
+ // src/cli/install-id.ts
1591
+ var ID_RE = /^[A-Za-z0-9_-]{16,64}$/;
1592
+ var VERSION_RE = /^\d{1,3}\.\d{1,3}\.\d{1,3}(?:-[0-9A-Za-z.-]{1,20})?$/;
1593
+ var INSTALL_HEADER = "x-flypod-install";
1594
+ var INSTALL_NEW_HEADER = "x-flypod-install-new";
1595
+ var VERSION_HEADER = "x-flypod-version";
1596
+ var RELINK_HEADER = "x-flypod-relink";
1597
+ var AGENT_HEADER = "x-flypod-agent";
1598
+ var CI_HEADER = "x-flypod-ci";
1599
+ var INVOKED_VIA_HEADER = "x-flypod-invoked-via";
1600
+ var AGENT_GUIDE_HEADER = "x-flypod-agent-guide";
1601
+ function telemetryOptedOut(env) {
1602
+ const dnt = env.DO_NOT_TRACK;
1603
+ if (dnt !== undefined && !["", "0", "false"].includes(dnt.trim().toLowerCase()))
1604
+ return true;
1605
+ const own = env.FLYPOD_TELEMETRY;
1606
+ return own !== undefined && ["0", "false", "off", "no"].includes(own.trim().toLowerCase());
1607
+ }
1608
+ function installFilePath(env = process.env) {
1609
+ return join4(configDir(env), "install.json");
1610
+ }
1611
+ var cache2 = new Map;
1612
+ function installId(env = process.env) {
1613
+ if (telemetryOptedOut(env))
1614
+ return Promise.resolve(null);
1615
+ let path;
1616
+ try {
1617
+ path = installFilePath(env);
1618
+ } catch {
1619
+ return Promise.resolve(null);
1620
+ }
1621
+ let pending2 = cache2.get(path);
1622
+ if (!pending2) {
1623
+ pending2 = loadOrCreate(path);
1624
+ cache2.set(path, pending2);
1625
+ }
1626
+ return pending2;
1627
+ }
1628
+ async function loadOrCreate(path) {
1629
+ try {
1630
+ const saved = JSON.parse(await readFile3(path, "utf8"));
1631
+ if (typeof saved.install_id === "string" && ID_RE.test(saved.install_id)) {
1632
+ return { id: saved.install_id, isNew: false };
1633
+ }
1634
+ } catch {}
1635
+ const id2 = randomBytes(16).toString("base64url");
1636
+ try {
1637
+ await atomicWriteFile(path, `${JSON.stringify({ install_id: id2, created_at: new Date().toISOString() }, null, 2)}
1638
+ `);
1639
+ } catch {
1640
+ return null;
1641
+ }
1642
+ return { id: id2, isNew: true };
1643
+ }
1644
+ var version;
1645
+ function setCliVersion(v) {
1646
+ version = VERSION_RE.test(v) ? v : undefined;
1647
+ }
1648
+ async function identityHeaders(env, opts = {}) {
1649
+ const headers = {};
1650
+ if (version)
1651
+ headers[VERSION_HEADER] = version;
1652
+ const install = await installId(env);
1653
+ if (install) {
1654
+ headers[INSTALL_HEADER] = install.id;
1655
+ if (install.isNew)
1656
+ headers[INSTALL_NEW_HEADER] = "1";
1657
+ }
1658
+ if (!telemetryOptedOut(env)) {
1659
+ headers[AGENT_HEADER] = detectCodingAgent(env);
1660
+ headers[CI_HEADER] = detectCi(env) ? "1" : "0";
1661
+ const cwd = opts.cwd ?? process.cwd();
1662
+ headers[INVOKED_VIA_HEADER] = detectInvokedVia(env, opts.script ?? process.argv[1], cwd);
1663
+ headers[AGENT_GUIDE_HEADER] = await agentGuideFor(cwd, { home: env.HOME });
1664
+ }
1665
+ return headers;
1666
+ }
1667
+ var FIRST_RUN_NOTICE = "flypod counts deploys with a random id. DO_NOT_TRACK=1 stops it.";
1668
+
1295
1669
  // src/cli/client.ts
1296
1670
  var DEVICE_CLIENT_ID = "flypod-cli";
1297
1671
  var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
@@ -1356,8 +1730,9 @@ async function createClient(opts) {
1356
1730
  const fetchImpl = opts.fetch ?? fetch;
1357
1731
  const session = await loadSession(env);
1358
1732
  const { token, baseUrl } = resolveCredentials(env, session, opts.overrides);
1359
- const source = await resolveCliSource(env, opts.cwd ?? process.cwd());
1360
- const identity = await identityHeaders(env).catch(() => ({}));
1733
+ const cwd = opts.cwd ?? process.cwd();
1734
+ const source = await resolveCliSource(env, cwd);
1735
+ const identity = await identityHeaders(env, { cwd }).catch(() => ({}));
1361
1736
  return buildClient(token, baseUrl, fetchImpl, source, identity);
1362
1737
  }
1363
1738
 
@@ -2019,19 +2394,81 @@ var BUILD_DIR_CANDIDATES = [
2019
2394
  "public",
2020
2395
  "_site"
2021
2396
  ];
2397
+ var SOURCE_MARKERS = [
2398
+ "package.json",
2399
+ "_config.yml",
2400
+ "Gemfile",
2401
+ "mkdocs.yml",
2402
+ "hugo.toml",
2403
+ "config.toml",
2404
+ "pyproject.toml",
2405
+ "requirements.txt",
2406
+ "Cargo.toml",
2407
+ "go.mod",
2408
+ "composer.json"
2409
+ ];
2410
+ async function isFile(path) {
2411
+ try {
2412
+ return (await stat3(path)).isFile();
2413
+ } catch {
2414
+ return false;
2415
+ }
2416
+ }
2417
+ async function isDir(path) {
2418
+ try {
2419
+ return (await stat3(path)).isDirectory();
2420
+ } catch {
2421
+ return false;
2422
+ }
2423
+ }
2424
+ async function nestedSite(dir) {
2425
+ let names;
2426
+ try {
2427
+ names = (await readdir2(dir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
2428
+ } catch {
2429
+ return null;
2430
+ }
2431
+ const found = [];
2432
+ for (const name of names) {
2433
+ const sub = join5(dir, name);
2434
+ if (await isFile(join5(sub, "index.html")))
2435
+ found.push(sub);
2436
+ else if (await isFile(join5(sub, "browser", "index.html")))
2437
+ found.push(join5(sub, "browser"));
2438
+ if (found.length > 1)
2439
+ return null;
2440
+ }
2441
+ return found[0] ?? null;
2442
+ }
2443
+ async function deployableAsIs(dir) {
2444
+ const at = resolve2(dir);
2445
+ if (at === resolve2(homedir4()) || at === parse(at).root)
2446
+ return false;
2447
+ if (!await isFile(join5(at, "index.html")))
2448
+ return false;
2449
+ for (const marker of SOURCE_MARKERS) {
2450
+ if (await isFile(join5(at, marker)))
2451
+ return false;
2452
+ }
2453
+ return true;
2454
+ }
2022
2455
  async function resolveDeployDir(opts = {}) {
2023
2456
  if (opts.explicit)
2024
2457
  return opts.explicit;
2025
2458
  const cwd = opts.cwd ?? process.cwd();
2026
2459
  for (const candidate of BUILD_DIR_CANDIDATES) {
2027
- const dir = join4(cwd, candidate);
2028
- try {
2029
- if (!(await stat2(dir)).isDirectory())
2030
- continue;
2031
- if ((await stat2(join4(dir, "index.html"))).isFile())
2032
- return dir;
2033
- } catch {}
2460
+ const dir = join5(cwd, candidate);
2461
+ if (await isDir(dir) && await isFile(join5(dir, "index.html")))
2462
+ return dir;
2463
+ }
2464
+ for (const candidate of BUILD_DIR_CANDIDATES) {
2465
+ const dir = join5(cwd, candidate);
2466
+ const nested = await isDir(dir) ? await nestedSite(dir) : null;
2467
+ if (nested)
2468
+ return nested;
2034
2469
  }
2470
+ if (await deployableAsIs(cwd))
2471
+ return cwd;
2035
2472
  throw new Error(`No build output folder found. Looked for ${BUILD_DIR_CANDIDATES.join(", ")} ` + `(each must contain an index.html). Pass the folder explicitly, e.g. \`npx flypod ./dist\`.`);
2036
2473
  }
2037
2474
  var DEFAULT_IGNORES = [
@@ -2081,10 +2518,10 @@ function compileRule(line, source) {
2081
2518
  const re = new RegExp(anchored ? `^${body}$` : `(?:^|/)${body}$`);
2082
2519
  return { re, negate, dirOnly, source };
2083
2520
  }
2084
- function ignoredBy(rules, rel, isDir) {
2521
+ function ignoredBy(rules, rel, isDir2) {
2085
2522
  let verdict = null;
2086
2523
  for (const rule of rules) {
2087
- if (rule.dirOnly && !isDir)
2524
+ if (rule.dirOnly && !isDir2)
2088
2525
  continue;
2089
2526
  if (rule.re.test(rel))
2090
2527
  verdict = rule.negate ? null : rule.source;
@@ -2092,14 +2529,14 @@ function ignoredBy(rules, rel, isDir) {
2092
2529
  return verdict;
2093
2530
  }
2094
2531
  async function collectFiles(path) {
2095
- const info = await stat2(path);
2532
+ const info = await stat3(path);
2096
2533
  if (info.isFile()) {
2097
2534
  const name = path.split("/").pop() ?? "index.html";
2098
2535
  return { files: { [name]: await readFile4(path) }, skipped: [] };
2099
2536
  }
2100
2537
  const rules = DEFAULT_IGNORES.map((p) => compileRule(p, "default"));
2101
2538
  try {
2102
- const text = await readFile4(join4(path, IGNORE_FILE), "utf8");
2539
+ const text = await readFile4(join5(path, IGNORE_FILE), "utf8");
2103
2540
  for (const line of text.split(/\r?\n/)) {
2104
2541
  const rule = compileRule(line, "flypodignore");
2105
2542
  if (rule)
@@ -2111,36 +2548,36 @@ async function collectFiles(path) {
2111
2548
  const skipped = [];
2112
2549
  const active = new Set([root]);
2113
2550
  async function walk(current, currentReal) {
2114
- for (const entry of await readdir(current, { withFileTypes: true })) {
2115
- const full = join4(current, entry.name);
2551
+ for (const entry of await readdir2(current, { withFileTypes: true })) {
2552
+ const full = join5(current, entry.name);
2116
2553
  const rel = relative(path, full).split("\\").join("/");
2117
2554
  if (rel === IGNORE_FILE)
2118
2555
  continue;
2119
- let isDir = entry.isDirectory();
2120
- let real;
2556
+ let isDir2 = entry.isDirectory();
2557
+ let real2;
2121
2558
  if (entry.isSymbolicLink()) {
2122
2559
  try {
2123
- real = await realpath(full);
2124
- isDir = (await stat2(real)).isDirectory();
2560
+ real2 = await realpath(full);
2561
+ isDir2 = (await stat3(real2)).isDirectory();
2125
2562
  } catch {
2126
2563
  skipped.push({ path: rel, reason: "broken_symlink" });
2127
2564
  continue;
2128
2565
  }
2129
2566
  }
2130
- const reason = ignoredBy(rules, rel, isDir);
2567
+ const reason = ignoredBy(rules, rel, isDir2);
2131
2568
  if (reason) {
2132
- skipped.push({ path: isDir ? `${rel}/` : rel, reason });
2569
+ skipped.push({ path: isDir2 ? `${rel}/` : rel, reason });
2133
2570
  continue;
2134
2571
  }
2135
- if (isDir) {
2136
- const childReal = real ?? join4(currentReal, entry.name);
2137
- if (real !== undefined) {
2138
- const inside = real === root || real.startsWith(`${root}${sep}`);
2572
+ if (isDir2) {
2573
+ const childReal = real2 ?? join5(currentReal, entry.name);
2574
+ if (real2 !== undefined) {
2575
+ const inside = real2 === root || real2.startsWith(`${root}${sep}`);
2139
2576
  if (!inside) {
2140
2577
  skipped.push({ path: `${rel}/`, reason: "symlink_outside" });
2141
2578
  continue;
2142
2579
  }
2143
- if (active.has(real)) {
2580
+ if (active.has(real2)) {
2144
2581
  skipped.push({ path: `${rel}/`, reason: "symlink_loop" });
2145
2582
  continue;
2146
2583
  }
@@ -2204,4 +2641,4 @@ class DeployError extends Error {
2204
2641
  }
2205
2642
  }
2206
2643
 
2207
- export { projectsFilePath, atomicWriteFile, installId, setCliVersion, FIRST_RUN_NOTICE, saveSession, clearSession, PLAIN, headline, hero, field, notice, failure, shortVersion, HOSTED_UPLOAD_LIMITS, uploadLimitsFor, storedZipBytes, startFailureReports, reportFailure, flushFailureReports, exitCodeFor, errorEnvelope, emitError, fail, classifyResponse, noBuildDir, networkError, NO_SITE, NOT_SIGNED_IN, unexpectedError, installSkill, resolveCredentials, createClient, packDeploy, BUILD_DIR_CANDIDATES, resolveDeployDir, DEFAULT_IGNORES, IGNORE_FILE, collectFiles, collectDist, deploySite, DeployError };
2644
+ export { PLAIN, headline, hero, field, notice, failure, shortVersion, HOSTED_UPLOAD_LIMITS, uploadLimitsFor, storedZipBytes, projectsFilePath, atomicWriteFile, loadSession, saveSession, clearSession, startFailureReports, reportFailure, flushFailureReports, exitCodeFor, errorEnvelope, emitError, fail, readServerMessage, classifyResponse, UNAUTHORIZED_FIX, serverError, noBuildDir, networkError, NO_SITE, noSite, unauthorizedFor, NOT_SIGNED_IN, unexpectedError, installSkill, installId, setCliVersion, FIRST_RUN_NOTICE, resolveCredentials, createClient, packDeploy, BUILD_DIR_CANDIDATES, resolveDeployDir, DEFAULT_IGNORES, IGNORE_FILE, collectFiles, collectDist, deploySite, DeployError };