flypod 0.17.0 → 0.18.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 +39 -13
- package/dist/bin/deploy.js +542 -98
- package/dist/{cli-z3p9tds1.js → cli-4d5fkx95.js} +291 -37
- package/dist/src/api-error.d.ts +4 -0
- package/dist/src/cli/agent-env.d.ts +5 -0
- package/dist/src/cli/build-hint.d.ts +13 -0
- package/dist/src/cli/commands.d.ts +4 -0
- package/dist/src/cli/errors.d.ts +81 -2
- package/dist/src/cli/install-id.d.ts +7 -3
- package/dist/src/cli/limits.d.ts +30 -8
- package/dist/src/cli/projects.d.ts +51 -3
- package/dist/src/cli/receipt.d.ts +18 -0
- package/dist/src/cli/skill.d.ts +18 -4
- package/dist/src/cli/source.d.ts +3 -1
- package/dist/src/cli-error-codes.d.ts +20 -0
- package/dist/src/cli.d.ts +15 -3
- package/dist/src/cli.js +1 -1
- package/dist/src/client-meta.d.ts +50 -0
- package/dist/src/ingest-error.d.ts +18 -1
- package/dist/src/upload-shape.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/cli.ts
|
|
2
2
|
import { readdir, readFile as readFile4, realpath, stat as stat2 } from "node:fs/promises";
|
|
3
|
-
import {
|
|
3
|
+
import { homedir as homedir3 } from "node:os";
|
|
4
|
+
import { join as join4, parse, relative, resolve, sep } from "node:path";
|
|
4
5
|
|
|
5
6
|
// src/deploy-source.ts
|
|
6
7
|
var SOURCE_HEADER = "x-flypod-source";
|
|
@@ -23,6 +24,43 @@ import { randomBytes } from "node:crypto";
|
|
|
23
24
|
import { readFile } from "node:fs/promises";
|
|
24
25
|
import { join as join2 } from "node:path";
|
|
25
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")
|
|
60
|
+
return true;
|
|
61
|
+
return env.GITHUB_ACTIONS === "true";
|
|
62
|
+
}
|
|
63
|
+
|
|
26
64
|
// src/cli/paths.ts
|
|
27
65
|
import { mkdir, rename, writeFile } from "node:fs/promises";
|
|
28
66
|
import { homedir, platform } from "node:os";
|
|
@@ -61,6 +99,8 @@ var INSTALL_HEADER = "x-flypod-install";
|
|
|
61
99
|
var INSTALL_NEW_HEADER = "x-flypod-install-new";
|
|
62
100
|
var VERSION_HEADER = "x-flypod-version";
|
|
63
101
|
var RELINK_HEADER = "x-flypod-relink";
|
|
102
|
+
var AGENT_HEADER = "x-flypod-agent";
|
|
103
|
+
var CI_HEADER = "x-flypod-ci";
|
|
64
104
|
function telemetryOptedOut(env) {
|
|
65
105
|
const dnt = env.DO_NOT_TRACK;
|
|
66
106
|
if (dnt !== undefined && !["", "0", "false"].includes(dnt.trim().toLowerCase()))
|
|
@@ -118,6 +158,10 @@ async function identityHeaders(env) {
|
|
|
118
158
|
if (install.isNew)
|
|
119
159
|
headers[INSTALL_NEW_HEADER] = "1";
|
|
120
160
|
}
|
|
161
|
+
if (!telemetryOptedOut(env)) {
|
|
162
|
+
headers[AGENT_HEADER] = detectCodingAgent(env);
|
|
163
|
+
headers[CI_HEADER] = detectCi(env) ? "1" : "0";
|
|
164
|
+
}
|
|
121
165
|
return headers;
|
|
122
166
|
}
|
|
123
167
|
var FIRST_RUN_NOTICE = "flypod counts deploys with a random id. DO_NOT_TRACK=1 stops it.";
|
|
@@ -241,6 +285,7 @@ function storedZipBytes(files) {
|
|
|
241
285
|
// src/cli/telemetry.ts
|
|
242
286
|
var REPORT_TIMEOUT_MS = 1500;
|
|
243
287
|
var TELEMETRY_PATH = "/telemetry/cli";
|
|
288
|
+
var NOT_FAILURES = new Set(["authorization_pending"]);
|
|
244
289
|
var run = null;
|
|
245
290
|
var pending = new Set;
|
|
246
291
|
function startFailureReports(opts) {
|
|
@@ -260,6 +305,8 @@ function reportFailure(err, args) {
|
|
|
260
305
|
const current = run;
|
|
261
306
|
if (!current || telemetryOptedOut(current.env))
|
|
262
307
|
return;
|
|
308
|
+
if (NOT_FAILURES.has(err.code))
|
|
309
|
+
return;
|
|
263
310
|
const agent = current.stdoutPiped || Boolean(args.json);
|
|
264
311
|
const sent = send(current, reportBody(err, current.verb, agent)).catch(() => {});
|
|
265
312
|
pending.add(sent);
|
|
@@ -287,7 +334,7 @@ async function send(r, body) {
|
|
|
287
334
|
return;
|
|
288
335
|
const headers = {
|
|
289
336
|
...await identityHeaders(r.env),
|
|
290
|
-
[SOURCE_HEADER]: await resolveCliSource(r.env, r.cwd),
|
|
337
|
+
[SOURCE_HEADER]: await resolveCliSource(r.env, r.cwd, { stdoutIsTTY: !r.stdoutPiped }),
|
|
291
338
|
"content-type": "application/json"
|
|
292
339
|
};
|
|
293
340
|
const res = await r.fetch(new URL(TELEMETRY_PATH, baseUrl).toString(), {
|
|
@@ -390,12 +437,25 @@ async function readServerMessage(res) {
|
|
|
390
437
|
code: typeof body.code === "string" ? body.code : undefined,
|
|
391
438
|
json: true,
|
|
392
439
|
...typeof body.fix === "string" && body.fix ? { fix: body.fix } : {},
|
|
393
|
-
...typeof body.limit === "string" ? { limit: body.limit } : {}
|
|
440
|
+
...typeof body.limit === "string" ? { limit: body.limit } : {},
|
|
441
|
+
...typeof body.request_id === "string" && body.request_id ? { requestId: body.request_id } : {}
|
|
394
442
|
};
|
|
395
443
|
} catch {
|
|
396
|
-
|
|
444
|
+
const cfError = cloudflareErrorNumber(text);
|
|
445
|
+
return {
|
|
446
|
+
message: text.length > 200 ? `${text.slice(0, 200)}…` : text,
|
|
447
|
+
...cfError !== undefined ? { cfError } : {}
|
|
448
|
+
};
|
|
397
449
|
}
|
|
398
450
|
}
|
|
451
|
+
function cloudflareErrorNumber(text) {
|
|
452
|
+
const m = text.match(/\berror(?: code)?:?\s*(1\d{3})\b/i);
|
|
453
|
+
return m ? Number(m[1]) : undefined;
|
|
454
|
+
}
|
|
455
|
+
var CF_ERRORS = {
|
|
456
|
+
1101: "the server crashed on this request",
|
|
457
|
+
1102: "the server ran out of CPU time or memory on this request"
|
|
458
|
+
};
|
|
399
459
|
async function classifyResponse(res, ctx) {
|
|
400
460
|
const said = await readServerMessage(res);
|
|
401
461
|
const err = classifyParsed(res, said, ctx);
|
|
@@ -406,6 +466,7 @@ async function classifyResponse(res, ctx) {
|
|
|
406
466
|
}
|
|
407
467
|
return err;
|
|
408
468
|
}
|
|
469
|
+
var UNAUTHORIZED_FIX = "Run `flypod login`, or pass --token <manage_token> for a site this machine does not remember.";
|
|
409
470
|
var SIZE_LIMITS = ["files", "total_bytes", "zip_bytes"];
|
|
410
471
|
function classifyParsed(res, said, ctx) {
|
|
411
472
|
const { message, code: serverCode, json } = said;
|
|
@@ -451,7 +512,7 @@ function classifyParsed(res, said, ctx) {
|
|
|
451
512
|
...base,
|
|
452
513
|
code: "unauthorized",
|
|
453
514
|
error: `Not authorized for site${site}.`,
|
|
454
|
-
fix:
|
|
515
|
+
fix: UNAUTHORIZED_FIX
|
|
455
516
|
};
|
|
456
517
|
case 404:
|
|
457
518
|
return ctx.siteScoped ? {
|
|
@@ -484,17 +545,36 @@ function classifyParsed(res, said, ctx) {
|
|
|
484
545
|
extra: retryAfter(res)
|
|
485
546
|
};
|
|
486
547
|
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
|
-
}
|
|
548
|
+
if (status >= 500)
|
|
549
|
+
return serverError(status, said, ctx.verb);
|
|
495
550
|
return { ...base, code: "bad_request", error: `${ctx.verb}: ${message}` };
|
|
496
551
|
}
|
|
497
552
|
}
|
|
553
|
+
function serverError(status, said, verb) {
|
|
554
|
+
const origin = said.json ? "app" : "edge";
|
|
555
|
+
const telemetry = { origin };
|
|
556
|
+
if (said.cfError !== undefined)
|
|
557
|
+
telemetry.cf_error = said.cfError;
|
|
558
|
+
if (origin === "app") {
|
|
559
|
+
return {
|
|
560
|
+
status,
|
|
561
|
+
code: "server_error",
|
|
562
|
+
error: `${verb}: the server hit an error (HTTP ${status}).`,
|
|
563
|
+
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.",
|
|
564
|
+
...said.requestId ? { extra: { request_id: said.requestId } } : {},
|
|
565
|
+
telemetry
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
const cf = said.cfError;
|
|
569
|
+
const known = cf !== undefined ? CF_ERRORS[cf] : undefined;
|
|
570
|
+
return {
|
|
571
|
+
status,
|
|
572
|
+
code: "server_error",
|
|
573
|
+
error: known ? `${verb}: ${known} (HTTP ${status}, Cloudflare error ${cf}).` : `${verb}: the server's hosting platform returned ${status}${cf !== undefined ? ` (Cloudflare error ${cf})` : ""}.`,
|
|
574
|
+
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.",
|
|
575
|
+
telemetry
|
|
576
|
+
};
|
|
577
|
+
}
|
|
498
578
|
function retryAfter(res) {
|
|
499
579
|
const raw = res.headers.get("retry-after");
|
|
500
580
|
const seconds = raw ? Number(raw) : Number.NaN;
|
|
@@ -527,6 +607,64 @@ var NO_SITE = {
|
|
|
527
607
|
error: "No flypod site is linked to this folder.",
|
|
528
608
|
fix: "Run `flypod` here to create one, or pass --site <id>."
|
|
529
609
|
};
|
|
610
|
+
function noSite(ctx) {
|
|
611
|
+
const make = (reason, error, fix, siteId) => ({
|
|
612
|
+
code: "no_site",
|
|
613
|
+
error,
|
|
614
|
+
fix,
|
|
615
|
+
extra: { reason, ...siteId ? { site_id: siteId } : {} },
|
|
616
|
+
telemetry: { reason }
|
|
617
|
+
});
|
|
618
|
+
if (ctx.gone?.reason === "expired") {
|
|
619
|
+
const day = new Date(ctx.gone.at).toISOString().slice(0, 10);
|
|
620
|
+
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);
|
|
621
|
+
}
|
|
622
|
+
if (ctx.gone) {
|
|
623
|
+
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);
|
|
624
|
+
}
|
|
625
|
+
if (ctx.nearby) {
|
|
626
|
+
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);
|
|
627
|
+
}
|
|
628
|
+
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>.");
|
|
629
|
+
}
|
|
630
|
+
function unauthorizedFor(ctx) {
|
|
631
|
+
const base = {
|
|
632
|
+
code: "unauthorized",
|
|
633
|
+
status: ctx.status,
|
|
634
|
+
telemetry: { credential: ctx.sent }
|
|
635
|
+
};
|
|
636
|
+
const id2 = ctx.siteId;
|
|
637
|
+
switch (ctx.sent) {
|
|
638
|
+
case "flag":
|
|
639
|
+
return {
|
|
640
|
+
...base,
|
|
641
|
+
error: `The --token you passed does not manage site ${id2}.`,
|
|
642
|
+
fix: "Pass that site's own token, or run `flypod login` with the account that owns the site and leave --token out."
|
|
643
|
+
};
|
|
644
|
+
case "manage_token":
|
|
645
|
+
return {
|
|
646
|
+
...base,
|
|
647
|
+
error: `Site ${id2} refused the token this machine holds for it: it was kept by an account, or it no longer exists.`,
|
|
648
|
+
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."
|
|
649
|
+
};
|
|
650
|
+
case "account":
|
|
651
|
+
return {
|
|
652
|
+
...base,
|
|
653
|
+
error: `Site ${id2} is not on the account you are signed in to, or it no longer exists.`,
|
|
654
|
+
fix: "Run `flypod list` to see the sites on your account, or `flypod login` with the account that owns this one."
|
|
655
|
+
};
|
|
656
|
+
default:
|
|
657
|
+
return ctx.known ? {
|
|
658
|
+
...base,
|
|
659
|
+
error: `Site ${id2} belongs to an account, and this machine is not signed in.`,
|
|
660
|
+
fix: "Run `flypod login` with the account that owns it, then run this again."
|
|
661
|
+
} : {
|
|
662
|
+
...base,
|
|
663
|
+
error: `This machine holds nothing that can change site ${id2}: it was made on another machine or install.`,
|
|
664
|
+
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`."
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
}
|
|
530
668
|
var NOT_SIGNED_IN = {
|
|
531
669
|
code: "not_signed_in",
|
|
532
670
|
error: "Not signed in.",
|
|
@@ -798,13 +936,27 @@ step when there is one; \`status\` is the HTTP status when a server answered. Co
|
|
|
798
936
|
\`invalid_upload\`, \`too_large\`, \`blocked\`, \`challenge_required\`,
|
|
799
937
|
\`rate_limited\`, \`server_error\`, \`network\`, \`unknown_flag\`, \`usage\`.
|
|
800
938
|
|
|
939
|
+
\`flypod update\` has already retried a \`server_error\` or \`network\` failure once
|
|
940
|
+
before reporting it, so do not loop on it: wait a minute before one more try.
|
|
941
|
+
When flypod itself answered, the JSON carries a \`request_id\` to quote.
|
|
942
|
+
|
|
801
943
|
\`usage\` includes a value flag given no value (\`--site needs a value\`) and a
|
|
802
944
|
\`--mode\` that is not \`anonymous\`, \`passcode\` or \`approved\`. \`unknown_flag\`
|
|
803
945
|
names the closest real flag when there is one. \`no_build_dir\` also covers a
|
|
804
|
-
path that does not exist
|
|
946
|
+
path that does not exist; its \`fix\` is the command to run, such as
|
|
947
|
+
"Run \`npm run build\`, then \`flypod ./dist\`" for a project that is not built.
|
|
948
|
+
\`too_large\` is checked before uploading to flypod.dev
|
|
805
949
|
(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
|
|
950
|
+
Read its \`fix\`: when the folder is a project root, or most of it is source maps,
|
|
951
|
+
video or images, it says so and names the folder or the \`.flypodignore\` lines to use.
|
|
952
|
+
|
|
953
|
+
\`no_site\` carries a \`reason\`: \`never_linked\` (run \`flypod\` to make the site),
|
|
954
|
+
\`expired\` (the temporary site ran out: run \`flypod\` for a new one, then
|
|
955
|
+
\`flypod login\` to keep it), \`gone\` (the site no longer exists: run \`flypod\`), or
|
|
956
|
+
\`other_folder\` (a folder above or below this one is linked: the \`fix\` gives the
|
|
957
|
+
\`--site <id>\` command). \`unauthorized\` on a version verb says what to do with the
|
|
958
|
+
credential this machine holds; when the site was kept by the account you are
|
|
959
|
+
signed in to, flypod retries as that account by itself.
|
|
808
960
|
|
|
809
961
|
Rarer ones: \`unknown_command\` (a verb that does not exist — \`flypod verisons\`
|
|
810
962
|
fails this way with \`"fix": "flypod versions"\` instead of deploying a folder
|
|
@@ -838,6 +990,10 @@ Each warning has a \`code\` and a \`fix_recipe\` naming the change to make.
|
|
|
838
990
|
- \`missing-index\` — nothing is served at \`/\`. Name the entry file \`index.html\`.
|
|
839
991
|
- \`not-spa\` — the page ships scripts but also has visible body content, so
|
|
840
992
|
client-side routing fallback stays off and deep links will 404 on refresh.
|
|
993
|
+
- \`new-site-in-linked-folder\` — \`flypod\` ran in a folder that already had a
|
|
994
|
+
site, so it made a second one. The deploy is live; do not redo it. Next time,
|
|
995
|
+
ship with \`flypod update\`. To put this build on the earlier URL instead, run
|
|
996
|
+
the \`flypod update --site <id>\` the warning names.
|
|
841
997
|
|
|
842
998
|
\`healed\` lists what flypod fixed on your behalf. \`spa-fallback\` there means it
|
|
843
999
|
recognised a single-page app, so unknown paths serve \`index.html\` and
|
|
@@ -865,7 +1021,7 @@ it would otherwise outlive.
|
|
|
865
1021
|
| \`FLYPOD_TOKEN\` | Deploy as your account without logging in (agents / CI) |
|
|
866
1022
|
| \`DEPLOY_URL\` | Point at a different flypod server (default \`https://flypod.dev\`) |
|
|
867
1023
|
| \`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) |
|
|
1024
|
+
| \`DO_NOT_TRACK\` | \`1\` turns off the CLI's random install id, the one word naming which agent ran it, and its failure reports (codes and counts, never file names) |
|
|
869
1025
|
|
|
870
1026
|
\`FLYPOD_TOKEN\` wins over a saved \`flypod login\` session; \`--token\` and a site's own
|
|
871
1027
|
stored manage token win over both. \`FLYPOD_API_KEY\` is read only as a last-resort
|
|
@@ -897,12 +1053,17 @@ files; flypod serves them.
|
|
|
897
1053
|
|
|
898
1054
|
1. Build first, if the project has a build — flypod serves files, it does not
|
|
899
1055
|
make them. You want a folder whose contents *are* the finished site.
|
|
900
|
-
2. Deploy it:
|
|
1056
|
+
2. Deploy it. **The first time**, \`flypod\` makes the site:
|
|
901
1057
|
|
|
902
1058
|
\`\`\`sh
|
|
903
1059
|
npx flypod ./dist --json
|
|
904
1060
|
\`\`\`
|
|
905
1061
|
|
|
1062
|
+
**Every later deploy** of the same project is \`flypod update\`, which ships
|
|
1063
|
+
to the URL the user already has (see "Shipping a change"). Running \`flypod\`
|
|
1064
|
+
again makes a second site on a new URL, and the receipt then carries a
|
|
1065
|
+
\`new-site-in-linked-folder\` warning.
|
|
1066
|
+
|
|
906
1067
|
3. Read \`url\` from the JSON and give it to the user.
|
|
907
1068
|
|
|
908
1069
|
**Done when** the user has the URL, and \`warnings\` is empty or you have told
|
|
@@ -910,7 +1071,10 @@ them what is in it.
|
|
|
910
1071
|
|
|
911
1072
|
Omit the path and flypod auto-detects a build folder, trying \`dist\`, \`build\`,
|
|
912
1073
|
\`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\` — each of
|
|
913
|
-
which must hold an \`index.html
|
|
1074
|
+
which must hold an \`index.html\` (or one app folder that does, as Angular's
|
|
1075
|
+
\`dist/<app>/browser\`). A folder with an \`index.html\` and no \`package.json\` deploys
|
|
1076
|
+
as it is. Pass the path whenever you know it. \`flypod update\` with no path
|
|
1077
|
+
deploys the folder the site was last deployed from.
|
|
914
1078
|
|
|
915
1079
|
A single file deploys too: \`flypod report.html\`. For several, deploy the folder.
|
|
916
1080
|
|
|
@@ -987,8 +1151,9 @@ flypod login --json
|
|
|
987
1151
|
# {"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
1152
|
\`\`\`
|
|
989
1153
|
|
|
990
|
-
It exits at once (code 2). Give the user the URL and the
|
|
991
|
-
they have confirmed, finish with the \`device_code\`
|
|
1154
|
+
It exits at once (code 2). Give the user the URL and the \`user_code\`; when they
|
|
1155
|
+
say they have confirmed, finish with the \`device_code\` (not the \`user_code\`)
|
|
1156
|
+
from that output:
|
|
992
1157
|
|
|
993
1158
|
\`\`\`sh
|
|
994
1159
|
flypod login --device-code <device_code> --json
|
|
@@ -996,6 +1161,11 @@ flypod login --device-code <device_code> --json
|
|
|
996
1161
|
# {"ok":false,"code":"authorization_pending",…} — exit 4, ask again later
|
|
997
1162
|
\`\`\`
|
|
998
1163
|
|
|
1164
|
+
\`authorization_pending\` means the user has not confirmed yet: wait \`interval\`
|
|
1165
|
+
seconds and run the same command again. \`login_expired\` means the code is
|
|
1166
|
+
spent (expired, or already used): if an earlier run printed
|
|
1167
|
+
\`"ok":true\` you are signed in, otherwise start again with \`flypod login --json\`.
|
|
1168
|
+
|
|
999
1169
|
A successful login also attaches every temporary site this machine deployed;
|
|
1000
1170
|
\`attached\` lists them.
|
|
1001
1171
|
|
|
@@ -1148,6 +1318,24 @@ async function skillInstalledIn(root) {
|
|
|
1148
1318
|
}
|
|
1149
1319
|
return (await legacyArtifacts(root)).length > 0;
|
|
1150
1320
|
}
|
|
1321
|
+
function globalSkillDirs(env) {
|
|
1322
|
+
const h = home(env);
|
|
1323
|
+
return [
|
|
1324
|
+
...TARGETS.map((t) => t.globalDir(env)),
|
|
1325
|
+
join3(h, ".codex", "skills", SKILL_NAME),
|
|
1326
|
+
join3(h, ".cursor", "skills", SKILL_NAME),
|
|
1327
|
+
join3(h, ".gemini", "skills", SKILL_NAME),
|
|
1328
|
+
join3(h, ".copilot", "skills", SKILL_NAME),
|
|
1329
|
+
join3(h, ".config", "opencode", "skills", SKILL_NAME)
|
|
1330
|
+
];
|
|
1331
|
+
}
|
|
1332
|
+
async function skillInstalledGlobally(env) {
|
|
1333
|
+
for (const dir of globalSkillDirs(env)) {
|
|
1334
|
+
if (await exists(join3(dir, "SKILL.md")))
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
return false;
|
|
1338
|
+
}
|
|
1151
1339
|
async function writeTarget(target, dir) {
|
|
1152
1340
|
const results = [];
|
|
1153
1341
|
for (const [rel, content] of Object.entries(skillFiles())) {
|
|
@@ -1281,12 +1469,16 @@ async function installSkill(args, callerIo) {
|
|
|
1281
1469
|
}
|
|
1282
1470
|
|
|
1283
1471
|
// src/cli/source.ts
|
|
1284
|
-
async function resolveCliSource(env, cwd) {
|
|
1472
|
+
async function resolveCliSource(env, cwd, opts = {}) {
|
|
1285
1473
|
const explicit = env.FLYPOD_SOURCE;
|
|
1286
1474
|
if (explicit)
|
|
1287
1475
|
return coerceSource(explicit);
|
|
1288
1476
|
try {
|
|
1289
|
-
|
|
1477
|
+
if (await skillInstalledIn(cwd))
|
|
1478
|
+
return "skill";
|
|
1479
|
+
const tty = opts.stdoutIsTTY ?? Boolean(process.stdout.isTTY);
|
|
1480
|
+
const agentRun = detectCodingAgent(env) !== "none" || !tty;
|
|
1481
|
+
return agentRun && await skillInstalledGlobally(env) ? "skill" : "cli";
|
|
1290
1482
|
} catch {
|
|
1291
1483
|
return "cli";
|
|
1292
1484
|
}
|
|
@@ -2019,19 +2211,81 @@ var BUILD_DIR_CANDIDATES = [
|
|
|
2019
2211
|
"public",
|
|
2020
2212
|
"_site"
|
|
2021
2213
|
];
|
|
2214
|
+
var SOURCE_MARKERS = [
|
|
2215
|
+
"package.json",
|
|
2216
|
+
"_config.yml",
|
|
2217
|
+
"Gemfile",
|
|
2218
|
+
"mkdocs.yml",
|
|
2219
|
+
"hugo.toml",
|
|
2220
|
+
"config.toml",
|
|
2221
|
+
"pyproject.toml",
|
|
2222
|
+
"requirements.txt",
|
|
2223
|
+
"Cargo.toml",
|
|
2224
|
+
"go.mod",
|
|
2225
|
+
"composer.json"
|
|
2226
|
+
];
|
|
2227
|
+
async function isFile(path) {
|
|
2228
|
+
try {
|
|
2229
|
+
return (await stat2(path)).isFile();
|
|
2230
|
+
} catch {
|
|
2231
|
+
return false;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
async function isDir(path) {
|
|
2235
|
+
try {
|
|
2236
|
+
return (await stat2(path)).isDirectory();
|
|
2237
|
+
} catch {
|
|
2238
|
+
return false;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
async function nestedSite(dir) {
|
|
2242
|
+
let names;
|
|
2243
|
+
try {
|
|
2244
|
+
names = (await readdir(dir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
2245
|
+
} catch {
|
|
2246
|
+
return null;
|
|
2247
|
+
}
|
|
2248
|
+
const found = [];
|
|
2249
|
+
for (const name of names) {
|
|
2250
|
+
const sub = join4(dir, name);
|
|
2251
|
+
if (await isFile(join4(sub, "index.html")))
|
|
2252
|
+
found.push(sub);
|
|
2253
|
+
else if (await isFile(join4(sub, "browser", "index.html")))
|
|
2254
|
+
found.push(join4(sub, "browser"));
|
|
2255
|
+
if (found.length > 1)
|
|
2256
|
+
return null;
|
|
2257
|
+
}
|
|
2258
|
+
return found[0] ?? null;
|
|
2259
|
+
}
|
|
2260
|
+
async function deployableAsIs(dir) {
|
|
2261
|
+
const at = resolve(dir);
|
|
2262
|
+
if (at === resolve(homedir3()) || at === parse(at).root)
|
|
2263
|
+
return false;
|
|
2264
|
+
if (!await isFile(join4(at, "index.html")))
|
|
2265
|
+
return false;
|
|
2266
|
+
for (const marker of SOURCE_MARKERS) {
|
|
2267
|
+
if (await isFile(join4(at, marker)))
|
|
2268
|
+
return false;
|
|
2269
|
+
}
|
|
2270
|
+
return true;
|
|
2271
|
+
}
|
|
2022
2272
|
async function resolveDeployDir(opts = {}) {
|
|
2023
2273
|
if (opts.explicit)
|
|
2024
2274
|
return opts.explicit;
|
|
2025
2275
|
const cwd = opts.cwd ?? process.cwd();
|
|
2026
2276
|
for (const candidate of BUILD_DIR_CANDIDATES) {
|
|
2027
2277
|
const dir = join4(cwd, candidate);
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2278
|
+
if (await isDir(dir) && await isFile(join4(dir, "index.html")))
|
|
2279
|
+
return dir;
|
|
2280
|
+
}
|
|
2281
|
+
for (const candidate of BUILD_DIR_CANDIDATES) {
|
|
2282
|
+
const dir = join4(cwd, candidate);
|
|
2283
|
+
const nested = await isDir(dir) ? await nestedSite(dir) : null;
|
|
2284
|
+
if (nested)
|
|
2285
|
+
return nested;
|
|
2034
2286
|
}
|
|
2287
|
+
if (await deployableAsIs(cwd))
|
|
2288
|
+
return cwd;
|
|
2035
2289
|
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
2290
|
}
|
|
2037
2291
|
var DEFAULT_IGNORES = [
|
|
@@ -2081,10 +2335,10 @@ function compileRule(line, source) {
|
|
|
2081
2335
|
const re = new RegExp(anchored ? `^${body}$` : `(?:^|/)${body}$`);
|
|
2082
2336
|
return { re, negate, dirOnly, source };
|
|
2083
2337
|
}
|
|
2084
|
-
function ignoredBy(rules, rel,
|
|
2338
|
+
function ignoredBy(rules, rel, isDir2) {
|
|
2085
2339
|
let verdict = null;
|
|
2086
2340
|
for (const rule of rules) {
|
|
2087
|
-
if (rule.dirOnly && !
|
|
2341
|
+
if (rule.dirOnly && !isDir2)
|
|
2088
2342
|
continue;
|
|
2089
2343
|
if (rule.re.test(rel))
|
|
2090
2344
|
verdict = rule.negate ? null : rule.source;
|
|
@@ -2116,23 +2370,23 @@ async function collectFiles(path) {
|
|
|
2116
2370
|
const rel = relative(path, full).split("\\").join("/");
|
|
2117
2371
|
if (rel === IGNORE_FILE)
|
|
2118
2372
|
continue;
|
|
2119
|
-
let
|
|
2373
|
+
let isDir2 = entry.isDirectory();
|
|
2120
2374
|
let real;
|
|
2121
2375
|
if (entry.isSymbolicLink()) {
|
|
2122
2376
|
try {
|
|
2123
2377
|
real = await realpath(full);
|
|
2124
|
-
|
|
2378
|
+
isDir2 = (await stat2(real)).isDirectory();
|
|
2125
2379
|
} catch {
|
|
2126
2380
|
skipped.push({ path: rel, reason: "broken_symlink" });
|
|
2127
2381
|
continue;
|
|
2128
2382
|
}
|
|
2129
2383
|
}
|
|
2130
|
-
const reason = ignoredBy(rules, rel,
|
|
2384
|
+
const reason = ignoredBy(rules, rel, isDir2);
|
|
2131
2385
|
if (reason) {
|
|
2132
|
-
skipped.push({ path:
|
|
2386
|
+
skipped.push({ path: isDir2 ? `${rel}/` : rel, reason });
|
|
2133
2387
|
continue;
|
|
2134
2388
|
}
|
|
2135
|
-
if (
|
|
2389
|
+
if (isDir2) {
|
|
2136
2390
|
const childReal = real ?? join4(currentReal, entry.name);
|
|
2137
2391
|
if (real !== undefined) {
|
|
2138
2392
|
const inside = real === root || real.startsWith(`${root}${sep}`);
|
|
@@ -2204,4 +2458,4 @@ class DeployError extends Error {
|
|
|
2204
2458
|
}
|
|
2205
2459
|
}
|
|
2206
2460
|
|
|
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 };
|
|
2461
|
+
export { projectsFilePath, atomicWriteFile, installId, setCliVersion, FIRST_RUN_NOTICE, loadSession, saveSession, clearSession, PLAIN, headline, hero, field, notice, failure, shortVersion, HOSTED_UPLOAD_LIMITS, uploadLimitsFor, storedZipBytes, startFailureReports, reportFailure, flushFailureReports, exitCodeFor, errorEnvelope, emitError, fail, readServerMessage, classifyResponse, UNAUTHORIZED_FIX, serverError, noBuildDir, networkError, NO_SITE, noSite, unauthorizedFor, NOT_SIGNED_IN, unexpectedError, installSkill, resolveCredentials, createClient, packDeploy, BUILD_DIR_CANDIDATES, resolveDeployDir, DEFAULT_IGNORES, IGNORE_FILE, collectFiles, collectDist, deploySite, DeployError };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type ApiErrorCode = "bad_request" | "invalid_upload" | "too_large" | "unauthorized" | "login_required" | "token_rejected" | "invalid_origin" | "forbidden" | "challenge_required" | "blocked" | "not_found" | "unknown_version" | "already_claimed" | "invalid_claim" | "expired" | "taken_down" | "rate_limited" | "server_error";
|
|
2
|
+
export declare function apiError(status: number, code: ApiErrorCode, message: string, extra?: Record<string, unknown>): Response;
|
|
3
|
+
/** The code a bare HTTP status implies, for errors raised with a status only. */
|
|
4
|
+
export declare function codeForStatus(status: number): ApiErrorCode;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CodingAgent } from "../client-meta";
|
|
2
|
+
/** The coding agent that launched this process, or `none`. First match wins. */
|
|
3
|
+
export declare function detectCodingAgent(env: NodeJS.ProcessEnv): CodingAgent;
|
|
4
|
+
/** True under a CI system. `CI` is the shared convention; GitHub Actions also sets its own. */
|
|
5
|
+
export declare function detectCi(env: NodeJS.ProcessEnv): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BuildHintOptions {
|
|
2
|
+
/** The verb the fix runs: `flypod` for a first deploy, `flypod update` after. */
|
|
3
|
+
verb: string;
|
|
4
|
+
/** A folder that must not be named: the one that just turned out empty. */
|
|
5
|
+
exclude?: string;
|
|
6
|
+
/** The folder this one deployed last time, named first when it is the answer. */
|
|
7
|
+
remembered?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The fix for "no folder to deploy here", or null when the folder says
|
|
11
|
+
* nothing more specific than the generic advice. Never throws.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildHint(cwd: string, opts: BuildHintOptions): Promise<string | null>;
|
|
@@ -29,6 +29,8 @@ export interface CommandIO {
|
|
|
29
29
|
* asserting on strings rather than on escape sequences).
|
|
30
30
|
*/
|
|
31
31
|
style?: TailStyle;
|
|
32
|
+
/** Wait before a retry. Defaults to a real timer; tests inject one that does not wait. */
|
|
33
|
+
sleep?: (ms: number) => Promise<void>;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Print help text: always on stdout and always exit 0, for every verb, so
|
|
@@ -61,6 +63,8 @@ export declare function claim(args: {
|
|
|
61
63
|
json?: boolean;
|
|
62
64
|
help?: boolean;
|
|
63
65
|
}, io: CommandIO): Promise<number>;
|
|
66
|
+
/** The pause before `update`'s one retry. */
|
|
67
|
+
export declare const UPDATE_RETRY_MS = 2000;
|
|
64
68
|
export declare function update(args: {
|
|
65
69
|
path?: string;
|
|
66
70
|
site?: string;
|