flypod 0.7.0 → 0.8.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 +425 -187
- package/dist/bin/deploy.js +142 -399
- package/dist/{cli-j9rxpfdv.js → cli-g2wb2hxm.js} +621 -14
- package/dist/src/cli/client.d.ts +13 -1
- package/dist/src/cli/commands.d.ts +68 -0
- package/dist/src/cli/projects.d.ts +35 -0
- package/dist/src/cli/skill.d.ts +135 -0
- package/dist/src/cli/source.d.ts +7 -0
- package/dist/src/cli.d.ts +18 -0
- package/dist/src/cli.js +1 -1
- package/dist/src/deploy-source.d.ts +20 -0
- package/package.json +4 -8
package/dist/bin/deploy.js
CHANGED
|
@@ -5,16 +5,17 @@ import {
|
|
|
5
5
|
collectDist,
|
|
6
6
|
createClient,
|
|
7
7
|
deploySite,
|
|
8
|
+
installSkill,
|
|
8
9
|
projectsFilePath,
|
|
9
10
|
resolveCredentials,
|
|
10
11
|
resolveDeployDir,
|
|
11
12
|
saveSession,
|
|
12
13
|
zipSync
|
|
13
|
-
} from "../cli-
|
|
14
|
+
} from "../cli-g2wb2hxm.js";
|
|
14
15
|
|
|
15
16
|
// bin/deploy.ts
|
|
16
|
-
import { readFile as
|
|
17
|
-
import { homedir
|
|
17
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
18
|
+
import { homedir } from "node:os";
|
|
18
19
|
import { relative } from "node:path";
|
|
19
20
|
import { fileURLToPath } from "node:url";
|
|
20
21
|
|
|
@@ -34,8 +35,14 @@ function cap(projects) {
|
|
|
34
35
|
const entries = Object.entries(projects);
|
|
35
36
|
if (entries.length <= MAX_PROJECTS)
|
|
36
37
|
return projects;
|
|
38
|
+
const irreplaceable = ([, r]) => r.expires_at !== null && typeof r.manage_token === "string";
|
|
37
39
|
entries.sort(([, a], [, b]) => b.last_used - a.last_used);
|
|
38
|
-
|
|
40
|
+
const keep = [
|
|
41
|
+
...entries.filter((e) => irreplaceable(e)),
|
|
42
|
+
...entries.filter((e) => !irreplaceable(e))
|
|
43
|
+
].slice(0, MAX_PROJECTS);
|
|
44
|
+
keep.sort(([, a], [, b]) => b.last_used - a.last_used);
|
|
45
|
+
return Object.fromEntries(keep);
|
|
39
46
|
}
|
|
40
47
|
async function loadProjects(env) {
|
|
41
48
|
try {
|
|
@@ -144,6 +151,26 @@ Drop this folder's remembered site link.
|
|
|
144
151
|
Flags:
|
|
145
152
|
--site <id> Forget all links to this site.
|
|
146
153
|
-h, --help Show this help.`,
|
|
154
|
+
token: `flypod token [flags]
|
|
155
|
+
|
|
156
|
+
Reveal the manage token for a site you deployed.
|
|
157
|
+
|
|
158
|
+
The token is a secret: anyone holding it can update, roll back, or claim that
|
|
159
|
+
site. Deploy output hides it by default for exactly that reason — it is already
|
|
160
|
+
saved for this folder, so update/rollback/versions work without it. You only
|
|
161
|
+
need to reveal it to act on the site from a different machine or folder.
|
|
162
|
+
|
|
163
|
+
flypod token Reveal this folder's site token.
|
|
164
|
+
flypod token --site <id> Reveal a remembered site's token by id.
|
|
165
|
+
|
|
166
|
+
The token goes to stdout, so it pipes:
|
|
167
|
+
|
|
168
|
+
flypod token | pbcopy
|
|
169
|
+
TOKEN=$(flypod token)
|
|
170
|
+
|
|
171
|
+
Flags:
|
|
172
|
+
--site <id> Reveal the token for this site id instead of this folder.
|
|
173
|
+
-h, --help Show this help.`,
|
|
147
174
|
login: `flypod login [flags]
|
|
148
175
|
|
|
149
176
|
Authenticate with flypod via the browser (device authorization).
|
|
@@ -269,7 +296,8 @@ async function attachAnonymousSites(apiKey, baseUrl, io, env) {
|
|
|
269
296
|
if (attached.size > 0) {
|
|
270
297
|
for (const [dir, rec] of candidates) {
|
|
271
298
|
if (attached.has(rec.site_id)) {
|
|
272
|
-
|
|
299
|
+
const { manage_token: _dead, ...owned } = rec;
|
|
300
|
+
projects[dir] = { ...owned, expires_at: null };
|
|
273
301
|
}
|
|
274
302
|
}
|
|
275
303
|
await saveProjects(projects, env);
|
|
@@ -325,10 +353,23 @@ async function claim(args, io) {
|
|
|
325
353
|
}
|
|
326
354
|
const res = await client.claimSite(args.site_id, args.token);
|
|
327
355
|
if (!res.ok) {
|
|
328
|
-
io.err(`flypod claim: server returned ${res.status}.`);
|
|
356
|
+
io.err(res.status === 409 ? `flypod claim: ${args.site_id} already belongs to another account.` : `flypod claim: server returned ${res.status}.`);
|
|
329
357
|
return 1;
|
|
330
358
|
}
|
|
331
359
|
const body = await res.json();
|
|
360
|
+
try {
|
|
361
|
+
const projects = await loadProjects(env);
|
|
362
|
+
let changed = false;
|
|
363
|
+
for (const [dir, r] of Object.entries(projects)) {
|
|
364
|
+
if (r.site_id === body.site_id && (r.expires_at !== null || r.manage_token)) {
|
|
365
|
+
const { manage_token: _dead, ...owned } = r;
|
|
366
|
+
projects[dir] = { ...owned, expires_at: null };
|
|
367
|
+
changed = true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (changed)
|
|
371
|
+
await saveProjects(projects, env);
|
|
372
|
+
} catch {}
|
|
332
373
|
io.out(JSON.stringify({ ok: true, site_id: body.site_id, owner_account_id: body.owner_account_id }));
|
|
333
374
|
io.err(`Claimed. Owned by ${body.owner_account_id}.`);
|
|
334
375
|
return 0;
|
|
@@ -357,6 +398,7 @@ function clientForTarget(target, args, io) {
|
|
|
357
398
|
return createClient({
|
|
358
399
|
env: io.env ?? process.env,
|
|
359
400
|
fetch: io.fetch,
|
|
401
|
+
cwd: io.cwd,
|
|
360
402
|
overrides: {
|
|
361
403
|
token: args.token,
|
|
362
404
|
manageToken: target.rec?.manage_token,
|
|
@@ -520,6 +562,26 @@ async function rollback(args, io) {
|
|
|
520
562
|
io.out(url);
|
|
521
563
|
return 0;
|
|
522
564
|
}
|
|
565
|
+
async function token(args, io) {
|
|
566
|
+
if (args.help) {
|
|
567
|
+
showSubHelp("token", io);
|
|
568
|
+
return 0;
|
|
569
|
+
}
|
|
570
|
+
const env = io.env ?? process.env;
|
|
571
|
+
const record = args.site ? Object.values(await loadProjects(env)).find((p) => p.site_id === args.site) : await projectForDir(io.cwd ?? process.cwd(), env);
|
|
572
|
+
if (!record) {
|
|
573
|
+
io.err(args.site ? `No remembered site ${args.site}. Tokens are only stored for sites deployed from this machine.` : "Nothing linked to this folder. Deploy first, or pass --site <id>.");
|
|
574
|
+
return 1;
|
|
575
|
+
}
|
|
576
|
+
if (!record.manage_token) {
|
|
577
|
+
io.err(`Site ${record.site_id} has no stored manage token. If you claimed it, it authenticates with your account — run \`flypod login\`.`);
|
|
578
|
+
return 1;
|
|
579
|
+
}
|
|
580
|
+
io.err(`Manage token for ${record.site_id} — treat it like a password.
|
|
581
|
+
`);
|
|
582
|
+
io.out(record.manage_token);
|
|
583
|
+
return 0;
|
|
584
|
+
}
|
|
523
585
|
async function forget(args, io) {
|
|
524
586
|
if (args.help) {
|
|
525
587
|
showSubHelp("forget", io);
|
|
@@ -610,12 +672,12 @@ async function resolveSiteAndThread(f, io) {
|
|
|
610
672
|
thread_id: f.positionals[0]
|
|
611
673
|
};
|
|
612
674
|
}
|
|
613
|
-
function requireCommentWriteToken(
|
|
614
|
-
if (!
|
|
675
|
+
function requireCommentWriteToken(token2, io) {
|
|
676
|
+
if (!token2) {
|
|
615
677
|
io.err("Not signed in. Run `flypod login` or set FLYPOD_TOKEN.");
|
|
616
678
|
return 3;
|
|
617
679
|
}
|
|
618
|
-
if (
|
|
680
|
+
if (token2.startsWith("fk_")) {
|
|
619
681
|
io.err("comments operations require an account session or agent token");
|
|
620
682
|
return 3;
|
|
621
683
|
}
|
|
@@ -1001,360 +1063,6 @@ function multiselect(opts) {
|
|
|
1001
1063
|
});
|
|
1002
1064
|
}
|
|
1003
1065
|
|
|
1004
|
-
// src/cli/skill.ts
|
|
1005
|
-
import { mkdir, readFile as readFile2, stat, writeFile } from "node:fs/promises";
|
|
1006
|
-
import { homedir } from "node:os";
|
|
1007
|
-
import { dirname, join } from "node:path";
|
|
1008
|
-
var SKILL_NAME = "flypod";
|
|
1009
|
-
var SKILL_DESCRIPTION = "Deploy any folder of static files to a live public URL with flypod (flypod.dev) — no account, config, or build pipeline needed. " + "Use when the user wants to deploy, publish, ship, share, or host a static site, build output, preview, or demo, or asks to put a finished build online or get a URL for it.";
|
|
1010
|
-
var MARK_BEGIN = `<!-- ${SKILL_NAME}:begin -->`;
|
|
1011
|
-
var MARK_END = `<!-- ${SKILL_NAME}:end -->`;
|
|
1012
|
-
function renderBody(sub) {
|
|
1013
|
-
return `flypod turns any folder of static files into a live, public URL with a single
|
|
1014
|
-
command. No account, no config, no build step of its own — you bring the built
|
|
1015
|
-
files, flypod hosts them. Reach for it the moment a build exists and the user
|
|
1016
|
-
wants it online: a site, a preview, a demo, a one-off share.
|
|
1017
|
-
|
|
1018
|
-
${sub} The happy path
|
|
1019
|
-
|
|
1020
|
-
1. Make sure the site is built — there is a folder of static files to ship
|
|
1021
|
-
(e.g. \`dist/\`, \`build/\`, \`out/\`). flypod ships files; it does not build them.
|
|
1022
|
-
2. Deploy that folder. Prefer \`--json\` so you can read the result:
|
|
1023
|
-
|
|
1024
|
-
\`\`\`sh
|
|
1025
|
-
npx flypod ./dist --json
|
|
1026
|
-
\`\`\`
|
|
1027
|
-
|
|
1028
|
-
If flypod is installed globally, drop the \`npx\`: \`flypod ./dist --json\`.
|
|
1029
|
-
3. Read the \`url\` field from the JSON and give it to the user. That is the live
|
|
1030
|
-
site. That's the whole loop.
|
|
1031
|
-
|
|
1032
|
-
If you omit the path, flypod auto-detects a build folder, trying \`dist\`,
|
|
1033
|
-
\`build\`, \`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\`
|
|
1034
|
-
(each must contain an \`index.html\`). When in doubt, pass the path explicitly.
|
|
1035
|
-
|
|
1036
|
-
${sub} Is flypod installed?
|
|
1037
|
-
|
|
1038
|
-
Run \`flypod --version\`. If it is missing, **do not install anything** — just
|
|
1039
|
-
prefix commands with \`npx\`: \`npx flypod ...\` downloads and runs it on the fly.
|
|
1040
|
-
To install once: \`npm install -g flypod\`.
|
|
1041
|
-
|
|
1042
|
-
${sub} Reading the result
|
|
1043
|
-
|
|
1044
|
-
\`npx flypod ./dist --json\` prints a JSON object on stdout:
|
|
1045
|
-
|
|
1046
|
-
\`\`\`json
|
|
1047
|
-
{
|
|
1048
|
-
"ok": true,
|
|
1049
|
-
"url": "https://ab12cd34.flypod.dev",
|
|
1050
|
-
"site_id": "ab12cd34",
|
|
1051
|
-
"manage_token": "…",
|
|
1052
|
-
"claim_token": "…",
|
|
1053
|
-
"expires_at": 1782929906088,
|
|
1054
|
-
"files": 12,
|
|
1055
|
-
"bytes": 1234567,
|
|
1056
|
-
"elapsed_ms": 812
|
|
1057
|
-
}
|
|
1058
|
-
\`\`\`
|
|
1059
|
-
|
|
1060
|
-
- \`url\` — the live site. Always surface this to the user.
|
|
1061
|
-
- \`manage_token\` — save it; it is needed to redeploy, roll back, or delete the site.
|
|
1062
|
-
- \`claim_token\` — save it; it attaches an anonymous site to an account later.
|
|
1063
|
-
- \`expires_at\` — anonymous deploys are ephemeral (~14 days); \`null\` once owned.
|
|
1064
|
-
|
|
1065
|
-
Treat \`manage_token\` and \`claim_token\` as secrets — don't paste them into chat
|
|
1066
|
-
unless the user asks. Without \`--json\`, use quiet mode to capture the URL in a
|
|
1067
|
-
shell variable: \`URL=$(npx flypod ./dist -q)\` (URL on stdout, token on stderr).
|
|
1068
|
-
|
|
1069
|
-
${sub} Anonymous vs. signed in
|
|
1070
|
-
|
|
1071
|
-
- **Anonymous (default):** zero auth. The first deploy just works and the site
|
|
1072
|
-
expires in ~14 days. Best for previews and throwaways.
|
|
1073
|
-
- **Signed in:** deploys are attributed to an account, never expire, and show up
|
|
1074
|
-
in \`flypod list\`. Sign in once via the browser:
|
|
1075
|
-
|
|
1076
|
-
\`\`\`sh
|
|
1077
|
-
flypod login
|
|
1078
|
-
\`\`\`
|
|
1079
|
-
|
|
1080
|
-
For agents and CI, skip the session file entirely — set a session token in the
|
|
1081
|
-
environment and every deploy is attributed to the account:
|
|
1082
|
-
|
|
1083
|
-
\`\`\`sh
|
|
1084
|
-
FLYPOD_TOKEN=<session-token> npx flypod ./dist --json
|
|
1085
|
-
\`\`\`
|
|
1086
|
-
|
|
1087
|
-
${sub} Other commands
|
|
1088
|
-
|
|
1089
|
-
\`\`\`sh
|
|
1090
|
-
flypod list # sites you own (requires sign in)
|
|
1091
|
-
flypod claim <site_id> <token> # attach an anonymous deploy to your account
|
|
1092
|
-
flypod logout # forget the saved session token
|
|
1093
|
-
flypod --help # full usage
|
|
1094
|
-
\`\`\`
|
|
1095
|
-
|
|
1096
|
-
${sub} Rules of thumb
|
|
1097
|
-
|
|
1098
|
-
- Build first. Point flypod at the **output** folder, never the project root or source.
|
|
1099
|
-
- Prefer \`--json\` and read \`url\`. Use \`-q\`/\`--quiet\` when you only need the URL.
|
|
1100
|
-
- flypod hosts **static files only** (HTML/CSS/JS/assets). It runs no server or backend.
|
|
1101
|
-
- A missing \`flypod\` binary is fine — use \`npx flypod\`; never block on installing it.`;
|
|
1102
|
-
}
|
|
1103
|
-
function standaloneMarkdown() {
|
|
1104
|
-
return `# Deploy with flypod
|
|
1105
|
-
|
|
1106
|
-
${renderBody("##")}
|
|
1107
|
-
`;
|
|
1108
|
-
}
|
|
1109
|
-
function embedSection() {
|
|
1110
|
-
return `${MARK_BEGIN}
|
|
1111
|
-
## Deploying with flypod
|
|
1112
|
-
|
|
1113
|
-
${renderBody("###")}
|
|
1114
|
-
${MARK_END}`;
|
|
1115
|
-
}
|
|
1116
|
-
function claudeSkillFile() {
|
|
1117
|
-
return `---
|
|
1118
|
-
name: ${SKILL_NAME}
|
|
1119
|
-
description: ${SKILL_DESCRIPTION}
|
|
1120
|
-
---
|
|
1121
|
-
|
|
1122
|
-
${standaloneMarkdown()}`;
|
|
1123
|
-
}
|
|
1124
|
-
function cursorRuleFile() {
|
|
1125
|
-
return `---
|
|
1126
|
-
description: ${SKILL_DESCRIPTION}
|
|
1127
|
-
globs:
|
|
1128
|
-
alwaysApply: false
|
|
1129
|
-
---
|
|
1130
|
-
|
|
1131
|
-
${standaloneMarkdown()}`;
|
|
1132
|
-
}
|
|
1133
|
-
async function exists(path) {
|
|
1134
|
-
try {
|
|
1135
|
-
await stat(path);
|
|
1136
|
-
return true;
|
|
1137
|
-
} catch {
|
|
1138
|
-
return false;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
async function anyExists(root, rels) {
|
|
1142
|
-
for (const rel of rels) {
|
|
1143
|
-
if (await exists(join(root, rel)))
|
|
1144
|
-
return true;
|
|
1145
|
-
}
|
|
1146
|
-
return false;
|
|
1147
|
-
}
|
|
1148
|
-
var TARGETS = [
|
|
1149
|
-
{
|
|
1150
|
-
id: "agents",
|
|
1151
|
-
label: "AGENTS.md",
|
|
1152
|
-
detail: "universal — Codex, Cursor, Copilot, Gemini, Zed, Jules, +more",
|
|
1153
|
-
kind: "embed",
|
|
1154
|
-
alwaysDefault: true,
|
|
1155
|
-
projectPath: (root) => join(root, "AGENTS.md"),
|
|
1156
|
-
globalPath: () => join(homedir(), ".codex", "AGENTS.md"),
|
|
1157
|
-
detect: () => Promise.resolve(true),
|
|
1158
|
-
render: embedSection
|
|
1159
|
-
},
|
|
1160
|
-
{
|
|
1161
|
-
id: "claude",
|
|
1162
|
-
label: "Claude Code",
|
|
1163
|
-
detail: ".claude/skills/flypod/SKILL.md — loaded on demand",
|
|
1164
|
-
kind: "skill",
|
|
1165
|
-
alwaysDefault: true,
|
|
1166
|
-
projectPath: (root) => join(root, ".claude", "skills", SKILL_NAME, "SKILL.md"),
|
|
1167
|
-
globalPath: () => join(homedir(), ".claude", "skills", SKILL_NAME, "SKILL.md"),
|
|
1168
|
-
detect: (root) => anyExists(root, [".claude", "CLAUDE.md"]),
|
|
1169
|
-
render: claudeSkillFile
|
|
1170
|
-
},
|
|
1171
|
-
{
|
|
1172
|
-
id: "cursor",
|
|
1173
|
-
label: "Cursor",
|
|
1174
|
-
detail: ".cursor/rules/flypod.mdc",
|
|
1175
|
-
kind: "rules",
|
|
1176
|
-
alwaysDefault: false,
|
|
1177
|
-
projectPath: (root) => join(root, ".cursor", "rules", `${SKILL_NAME}.mdc`),
|
|
1178
|
-
globalPath: () => null,
|
|
1179
|
-
detect: (root) => anyExists(root, [".cursor", ".cursorrules"]),
|
|
1180
|
-
render: cursorRuleFile
|
|
1181
|
-
},
|
|
1182
|
-
{
|
|
1183
|
-
id: "copilot",
|
|
1184
|
-
label: "GitHub Copilot",
|
|
1185
|
-
detail: ".github/copilot-instructions.md",
|
|
1186
|
-
kind: "embed",
|
|
1187
|
-
alwaysDefault: false,
|
|
1188
|
-
projectPath: (root) => join(root, ".github", "copilot-instructions.md"),
|
|
1189
|
-
globalPath: () => null,
|
|
1190
|
-
detect: (root) => anyExists(root, [".github"]),
|
|
1191
|
-
render: embedSection
|
|
1192
|
-
},
|
|
1193
|
-
{
|
|
1194
|
-
id: "windsurf",
|
|
1195
|
-
label: "Windsurf",
|
|
1196
|
-
detail: ".windsurf/rules/flypod.md",
|
|
1197
|
-
kind: "rules",
|
|
1198
|
-
alwaysDefault: false,
|
|
1199
|
-
projectPath: (root) => join(root, ".windsurf", "rules", `${SKILL_NAME}.md`),
|
|
1200
|
-
globalPath: () => null,
|
|
1201
|
-
detect: (root) => anyExists(root, [".windsurf", ".windsurfrules"]),
|
|
1202
|
-
render: standaloneMarkdown
|
|
1203
|
-
},
|
|
1204
|
-
{
|
|
1205
|
-
id: "cline",
|
|
1206
|
-
label: "Cline",
|
|
1207
|
-
detail: ".clinerules/flypod.md",
|
|
1208
|
-
kind: "rules",
|
|
1209
|
-
alwaysDefault: false,
|
|
1210
|
-
projectPath: (root) => join(root, ".clinerules", `${SKILL_NAME}.md`),
|
|
1211
|
-
globalPath: () => null,
|
|
1212
|
-
detect: (root) => anyExists(root, [".clinerules"]),
|
|
1213
|
-
render: standaloneMarkdown
|
|
1214
|
-
},
|
|
1215
|
-
{
|
|
1216
|
-
id: "roo",
|
|
1217
|
-
label: "Roo Code",
|
|
1218
|
-
detail: ".roo/rules/flypod.md",
|
|
1219
|
-
kind: "rules",
|
|
1220
|
-
alwaysDefault: false,
|
|
1221
|
-
projectPath: (root) => join(root, ".roo", "rules", `${SKILL_NAME}.md`),
|
|
1222
|
-
globalPath: () => null,
|
|
1223
|
-
detect: (root) => anyExists(root, [".roo", ".roorules"]),
|
|
1224
|
-
render: standaloneMarkdown
|
|
1225
|
-
},
|
|
1226
|
-
{
|
|
1227
|
-
id: "gemini",
|
|
1228
|
-
label: "Gemini CLI",
|
|
1229
|
-
detail: "GEMINI.md",
|
|
1230
|
-
kind: "embed",
|
|
1231
|
-
alwaysDefault: false,
|
|
1232
|
-
projectPath: (root) => join(root, "GEMINI.md"),
|
|
1233
|
-
globalPath: () => join(homedir(), ".gemini", "GEMINI.md"),
|
|
1234
|
-
detect: (root) => anyExists(root, ["GEMINI.md", ".gemini"]),
|
|
1235
|
-
render: embedSection
|
|
1236
|
-
}
|
|
1237
|
-
];
|
|
1238
|
-
function spliceBlock(existing, section) {
|
|
1239
|
-
const begin = existing.indexOf(MARK_BEGIN);
|
|
1240
|
-
const end = existing.indexOf(MARK_END);
|
|
1241
|
-
if (begin !== -1 && end !== -1 && end > begin) {
|
|
1242
|
-
const before = existing.slice(0, begin);
|
|
1243
|
-
const after = existing.slice(end + MARK_END.length);
|
|
1244
|
-
return `${before}${section}${after}`;
|
|
1245
|
-
}
|
|
1246
|
-
const trimmed = existing.replace(/\s+$/, "");
|
|
1247
|
-
return trimmed ? `${trimmed}
|
|
1248
|
-
|
|
1249
|
-
${section}
|
|
1250
|
-
` : `${section}
|
|
1251
|
-
`;
|
|
1252
|
-
}
|
|
1253
|
-
async function writeTarget(target, path) {
|
|
1254
|
-
const had = await exists(path);
|
|
1255
|
-
const current = had ? await readFile2(path, "utf8") : "";
|
|
1256
|
-
let next;
|
|
1257
|
-
if (target.kind === "embed") {
|
|
1258
|
-
next = spliceBlock(current, target.render());
|
|
1259
|
-
} else {
|
|
1260
|
-
next = target.render();
|
|
1261
|
-
}
|
|
1262
|
-
if (had && current === next)
|
|
1263
|
-
return { target, path, status: "unchanged" };
|
|
1264
|
-
await mkdir(dirname(path), { recursive: true });
|
|
1265
|
-
await writeFile(path, next, "utf8");
|
|
1266
|
-
return { target, path, status: had ? "updated" : "created" };
|
|
1267
|
-
}
|
|
1268
|
-
async function buildPlan(root, env, global) {
|
|
1269
|
-
const entries = [];
|
|
1270
|
-
for (const target of TARGETS) {
|
|
1271
|
-
const path = global ? target.globalPath(env) : target.projectPath(root);
|
|
1272
|
-
if (!path)
|
|
1273
|
-
continue;
|
|
1274
|
-
const detected = await target.detect(root, env);
|
|
1275
|
-
entries.push({
|
|
1276
|
-
target,
|
|
1277
|
-
path,
|
|
1278
|
-
detected,
|
|
1279
|
-
defaultOn: target.alwaysDefault || detected
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
return entries;
|
|
1283
|
-
}
|
|
1284
|
-
async function installSkill(args, io) {
|
|
1285
|
-
const env = io.env ?? process.env;
|
|
1286
|
-
const root = args.cwd ?? process.cwd();
|
|
1287
|
-
const global = Boolean(args.global);
|
|
1288
|
-
const plan = await buildPlan(root, env, global);
|
|
1289
|
-
if (args.list) {
|
|
1290
|
-
io.err(global ? "flypod skill targets (global):" : "flypod skill targets (this project):");
|
|
1291
|
-
io.err("");
|
|
1292
|
-
for (const e of plan) {
|
|
1293
|
-
const mark = e.defaultOn ? "●" : "○";
|
|
1294
|
-
const tag = e.target.alwaysDefault ? "default" : e.detected ? "detected" : "available";
|
|
1295
|
-
io.out(`${mark} ${e.target.id} ${tag} ${e.path}`);
|
|
1296
|
-
}
|
|
1297
|
-
io.err("");
|
|
1298
|
-
io.err("● = installed by default. Run `flypod install skill` to write them.");
|
|
1299
|
-
return 0;
|
|
1300
|
-
}
|
|
1301
|
-
let chosen;
|
|
1302
|
-
if (args.all) {
|
|
1303
|
-
chosen = plan.map((e) => e.target.id);
|
|
1304
|
-
} else if (args.targets && args.targets.length > 0) {
|
|
1305
|
-
const known = new Set(plan.map((e) => e.target.id));
|
|
1306
|
-
const unknown = args.targets.filter((id) => !known.has(id));
|
|
1307
|
-
if (unknown.length > 0) {
|
|
1308
|
-
io.err(`flypod: unknown target(s): ${unknown.join(", ")}`);
|
|
1309
|
-
io.err(`Known targets: ${TARGETS.map((t) => t.id).join(", ")}`);
|
|
1310
|
-
return 2;
|
|
1311
|
-
}
|
|
1312
|
-
chosen = args.targets;
|
|
1313
|
-
} else if (args.picker) {
|
|
1314
|
-
const picked = await args.picker(plan);
|
|
1315
|
-
if (picked === null) {
|
|
1316
|
-
io.err("Cancelled. Nothing written.");
|
|
1317
|
-
return 130;
|
|
1318
|
-
}
|
|
1319
|
-
chosen = picked;
|
|
1320
|
-
} else {
|
|
1321
|
-
chosen = plan.filter((e) => e.defaultOn).map((e) => e.target.id);
|
|
1322
|
-
}
|
|
1323
|
-
const selected = plan.filter((e) => chosen.includes(e.target.id));
|
|
1324
|
-
if (selected.length === 0) {
|
|
1325
|
-
io.err("No targets selected. Nothing written.");
|
|
1326
|
-
return 0;
|
|
1327
|
-
}
|
|
1328
|
-
if (args.dryRun) {
|
|
1329
|
-
io.err("Would write:");
|
|
1330
|
-
for (const e of selected)
|
|
1331
|
-
io.out(e.path);
|
|
1332
|
-
return 0;
|
|
1333
|
-
}
|
|
1334
|
-
const results = [];
|
|
1335
|
-
for (const e of selected) {
|
|
1336
|
-
try {
|
|
1337
|
-
results.push(await writeTarget(e.target, e.path));
|
|
1338
|
-
} catch (error) {
|
|
1339
|
-
io.err(`flypod: failed to write ${e.path}: ${error.message}`);
|
|
1340
|
-
return 1;
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
const verb = {
|
|
1344
|
-
created: "created",
|
|
1345
|
-
updated: "updated",
|
|
1346
|
-
unchanged: "up to date"
|
|
1347
|
-
};
|
|
1348
|
-
for (const r of results) {
|
|
1349
|
-
io.err(` ${r.status === "unchanged" ? "·" : "✓"} ${verb[r.status]} ${r.path}`);
|
|
1350
|
-
io.out(r.path);
|
|
1351
|
-
}
|
|
1352
|
-
const changed = results.filter((r) => r.status !== "unchanged").length;
|
|
1353
|
-
io.err("");
|
|
1354
|
-
io.err(changed > 0 ? `Your agents now know how to deploy with flypod. Try asking one to "deploy this with flypod".` : "Everything was already up to date.");
|
|
1355
|
-
return 0;
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
1066
|
// src/ui.ts
|
|
1359
1067
|
var ESC2 = "\x1B[";
|
|
1360
1068
|
function envBool(name) {
|
|
@@ -1465,6 +1173,7 @@ var SUBCOMMANDS = new Set([
|
|
|
1465
1173
|
"versions",
|
|
1466
1174
|
"rollback",
|
|
1467
1175
|
"forget",
|
|
1176
|
+
"token",
|
|
1468
1177
|
"login",
|
|
1469
1178
|
"logout",
|
|
1470
1179
|
"list",
|
|
@@ -1473,15 +1182,15 @@ var SUBCOMMANDS = new Set([
|
|
|
1473
1182
|
"comments"
|
|
1474
1183
|
]);
|
|
1475
1184
|
var TARGET_FLAGS = {
|
|
1476
|
-
"--agents": "agents",
|
|
1477
|
-
"--agents-md": "agents",
|
|
1478
1185
|
"--claude": "claude",
|
|
1479
|
-
"--
|
|
1480
|
-
"--
|
|
1481
|
-
"--
|
|
1482
|
-
"--
|
|
1483
|
-
"--
|
|
1484
|
-
"--
|
|
1186
|
+
"--agents": "agents",
|
|
1187
|
+
"--cursor": "agents",
|
|
1188
|
+
"--codex": "agents",
|
|
1189
|
+
"--copilot": "agents",
|
|
1190
|
+
"--gemini": "agents",
|
|
1191
|
+
"--windsurf": "agents",
|
|
1192
|
+
"--cline": "agents",
|
|
1193
|
+
"--roo": "agents"
|
|
1485
1194
|
};
|
|
1486
1195
|
var INSTALL_FLAG_SPEC = {
|
|
1487
1196
|
"--all": "bool",
|
|
@@ -1556,21 +1265,25 @@ async function runSubcommand(name, argv) {
|
|
|
1556
1265
|
};
|
|
1557
1266
|
switch (name) {
|
|
1558
1267
|
case "update": {
|
|
1559
|
-
const { positionals, site, token, json, quiet, help } = parseSub(argv);
|
|
1560
|
-
return update({ path: positionals[0], site, token, json, quiet, help }, io);
|
|
1268
|
+
const { positionals, site, token: token2, json, quiet, help } = parseSub(argv);
|
|
1269
|
+
return update({ path: positionals[0], site, token: token2, json, quiet, help }, io);
|
|
1561
1270
|
}
|
|
1562
1271
|
case "versions": {
|
|
1563
|
-
const { site, token, json, help } = parseSub(argv);
|
|
1564
|
-
return versions({ site, token, json, help }, io);
|
|
1272
|
+
const { site, token: token2, json, help } = parseSub(argv);
|
|
1273
|
+
return versions({ site, token: token2, json, help }, io);
|
|
1565
1274
|
}
|
|
1566
1275
|
case "rollback": {
|
|
1567
|
-
const { positionals, site, token, json, help } = parseSub(argv);
|
|
1568
|
-
return rollback({ version: positionals[0], site, token, json, help }, io);
|
|
1276
|
+
const { positionals, site, token: token2, json, help } = parseSub(argv);
|
|
1277
|
+
return rollback({ version: positionals[0], site, token: token2, json, help }, io);
|
|
1569
1278
|
}
|
|
1570
1279
|
case "forget": {
|
|
1571
1280
|
const { site, help } = parseSub(argv);
|
|
1572
1281
|
return forget({ site, help }, io);
|
|
1573
1282
|
}
|
|
1283
|
+
case "token": {
|
|
1284
|
+
const { site, help } = parseSub(argv);
|
|
1285
|
+
return token({ site, help }, io);
|
|
1286
|
+
}
|
|
1574
1287
|
case "login": {
|
|
1575
1288
|
const { flags } = parseFlags(argv, LOGIN_FLAG_SPEC);
|
|
1576
1289
|
return login({
|
|
@@ -1596,16 +1309,16 @@ async function runSubcommand(name, argv) {
|
|
|
1596
1309
|
}
|
|
1597
1310
|
}
|
|
1598
1311
|
function shortHome(path) {
|
|
1599
|
-
const home =
|
|
1312
|
+
const home = homedir();
|
|
1600
1313
|
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
1601
1314
|
}
|
|
1602
1315
|
async function runInstall(argv, io) {
|
|
1603
1316
|
const noun = argv.find((a) => !a.startsWith("-"));
|
|
1604
1317
|
if (noun !== "skill" && noun !== "skills") {
|
|
1605
|
-
io.err("Usage: flypod install skill [
|
|
1318
|
+
io.err("Usage: flypod install skill [--claude] [--agents] [--global] [--list] [--dry-run]");
|
|
1606
1319
|
io.err("");
|
|
1607
1320
|
io.err("Teaches your coding agents (Claude Code, Codex, Cursor, …) how to deploy");
|
|
1608
|
-
io.err("with flypod by writing
|
|
1321
|
+
io.err("with flypod by writing an Agent Skill into .claude/skills/ and .agents/skills/.");
|
|
1609
1322
|
return 2;
|
|
1610
1323
|
}
|
|
1611
1324
|
const { flags, unknown } = parseFlags(argv, INSTALL_FLAG_SPEC);
|
|
@@ -1635,8 +1348,8 @@ async function runInstall(argv, io) {
|
|
|
1635
1348
|
const choices = plan.map((e) => ({
|
|
1636
1349
|
id: e.target.id,
|
|
1637
1350
|
label: e.target.label,
|
|
1638
|
-
hint:
|
|
1639
|
-
checked:
|
|
1351
|
+
hint: e.target.detail,
|
|
1352
|
+
checked: true
|
|
1640
1353
|
}));
|
|
1641
1354
|
return multiselect({ title: "Install the flypod skill into:", choices, style });
|
|
1642
1355
|
} : undefined;
|
|
@@ -1645,14 +1358,14 @@ async function runInstall(argv, io) {
|
|
|
1645
1358
|
err: (line) => io.err(shortHome(line)),
|
|
1646
1359
|
env: io.env
|
|
1647
1360
|
};
|
|
1648
|
-
return installSkill({ targets, all, global, list: list2, dryRun, picker }, io2);
|
|
1361
|
+
return installSkill({ targets, all: all || yes, global, list: list2, dryRun, picker }, io2);
|
|
1649
1362
|
}
|
|
1650
1363
|
async function readVersion() {
|
|
1651
1364
|
const here = fileURLToPath(import.meta.url);
|
|
1652
1365
|
for (const rel of ["../../package.json", "../package.json"]) {
|
|
1653
1366
|
try {
|
|
1654
1367
|
const url = new URL(rel, `file://${here}`);
|
|
1655
|
-
const text = await
|
|
1368
|
+
const text = await readFile2(url, "utf8");
|
|
1656
1369
|
const version = JSON.parse(text).version;
|
|
1657
1370
|
if (version)
|
|
1658
1371
|
return version;
|
|
@@ -1693,21 +1406,33 @@ Targeting (update / versions / rollback):
|
|
|
1693
1406
|
--token <tok> A site's manage token, for acting on an anonymous site from a
|
|
1694
1407
|
machine that doesn't remember it. Owned sites use your login.
|
|
1695
1408
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1409
|
+
Ownership — two states, one command:
|
|
1410
|
+
A deploy with no account is TEMPORARY: live now, gone in 14 days. Run
|
|
1411
|
+
'flypod login' and it becomes YOURS: no expiry, listed on your account.
|
|
1412
|
+
Logging in claims EVERY temporary site this machine remembers, not just the
|
|
1413
|
+
last one — so "deploy now, log in whenever" works. You never need a token.
|
|
1414
|
+
|
|
1415
|
+
flypod login Sign in (opens your browser to confirm) and
|
|
1416
|
+
keep every site deployed from this machine.
|
|
1701
1417
|
flypod login --token <t> Save a session token directly (skip the browser).
|
|
1702
1418
|
Or set FLYPOD_TOKEN for agents/CI.
|
|
1703
1419
|
flypod logout Forget the saved session token.
|
|
1704
1420
|
flypod list List sites you own (JSON on stdout).
|
|
1705
|
-
flypod claim <id> <token> Attach
|
|
1421
|
+
flypod claim <id> <token> Attach one anonymous deploy to your account.
|
|
1422
|
+
'flypod login' is the easier path.
|
|
1706
1423
|
flypod forget [--site <id>] Drop this folder's remembered site link.
|
|
1424
|
+
flypod token [--site <id>] Print a site's manage token on stdout. Deploys
|
|
1425
|
+
don't show it — it's saved for you — so you only
|
|
1426
|
+
need this to act on a site from a machine that
|
|
1427
|
+
doesn't remember it. Treat it like a password.
|
|
1707
1428
|
|
|
1708
1429
|
Agents:
|
|
1709
|
-
flypod install skill Teach your coding agents
|
|
1710
|
-
|
|
1430
|
+
flypod install skill Teach your coding agents how to deploy with
|
|
1431
|
+
flypod. Writes an Agent Skill into
|
|
1432
|
+
.claude/skills/flypod/ (Claude Code) and
|
|
1433
|
+
.agents/skills/flypod/ (Codex, Cursor, Gemini
|
|
1434
|
+
CLI, Copilot). Add --global for your home dir,
|
|
1435
|
+
--list to see the paths, --dry-run to preview.
|
|
1711
1436
|
|
|
1712
1437
|
Deploy flags:
|
|
1713
1438
|
--comments Enable comments on the new site (mode: anonymous).
|
|
@@ -1732,13 +1457,17 @@ Comments (off by default — enabling is one command):
|
|
|
1732
1457
|
|
|
1733
1458
|
Output:
|
|
1734
1459
|
--json Emit a stable JSON result on stdout (for agents/scripts).
|
|
1735
|
-
|
|
1460
|
+
expires_at is epoch ms, or null once the site is yours.
|
|
1461
|
+
'warnings' lists problems that survived the deploy, each with
|
|
1462
|
+
a fix_recipe; 'healed' lists what flypod fixed for you.
|
|
1463
|
+
-q, --quiet Print only the URL on stdout, and nothing else.
|
|
1736
1464
|
-h, --help Show this help. -v, --version Show the flypod version.
|
|
1737
1465
|
|
|
1738
1466
|
Environment:
|
|
1739
1467
|
FLYPOD_TOKEN Deploy as your account without logging in (agents / CI)
|
|
1740
1468
|
DEPLOY_URL Override the deploy server (default: https://flypod.dev)
|
|
1741
1469
|
FLYPOD_CONFIG_DIR Override where the CLI keeps its session + folder memory
|
|
1470
|
+
FLYPOD_SHOW_TOKEN Set to 1 to print the manage token inline on deploy
|
|
1742
1471
|
NO_COLOR Disable ANSI colors
|
|
1743
1472
|
FORCE_COLOR Force ANSI colors even when stderr is not a TTY
|
|
1744
1473
|
|
|
@@ -1798,7 +1527,7 @@ async function main() {
|
|
|
1798
1527
|
|
|
1799
1528
|
`);
|
|
1800
1529
|
if (!apiKey) {
|
|
1801
|
-
process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · ")}${style.bold("flypod login")}${style.dim("
|
|
1530
|
+
process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · deploy now, ")}${style.bold("flypod login")}${style.dim(" later to keep it")}
|
|
1802
1531
|
|
|
1803
1532
|
`);
|
|
1804
1533
|
}
|
|
@@ -1829,7 +1558,7 @@ async function main() {
|
|
|
1829
1558
|
const started = Date.now();
|
|
1830
1559
|
let result;
|
|
1831
1560
|
try {
|
|
1832
|
-
result = await deploySite({ baseUrl, files, apiKey });
|
|
1561
|
+
result = await deploySite({ baseUrl, files, apiKey, source: client.source });
|
|
1833
1562
|
} catch (error) {
|
|
1834
1563
|
spinner.fail("Deploy failed.");
|
|
1835
1564
|
fail2(error.message, args, style, { dimOnly: true });
|
|
@@ -1837,6 +1566,7 @@ async function main() {
|
|
|
1837
1566
|
const elapsed = Date.now() - started;
|
|
1838
1567
|
spinner.success(`Deployed in ${fmtSeconds(elapsed)}`);
|
|
1839
1568
|
const owned = typeof result.owner_account_id === "string";
|
|
1569
|
+
let linkSaved = true;
|
|
1840
1570
|
try {
|
|
1841
1571
|
await linkProject(process.cwd(), {
|
|
1842
1572
|
site_id: result.site_id,
|
|
@@ -1847,7 +1577,9 @@ async function main() {
|
|
|
1847
1577
|
last_used: Date.now(),
|
|
1848
1578
|
version_id: result.version_id
|
|
1849
1579
|
});
|
|
1850
|
-
} catch {
|
|
1580
|
+
} catch {
|
|
1581
|
+
linkSaved = false;
|
|
1582
|
+
}
|
|
1851
1583
|
let commentsEnabled = false;
|
|
1852
1584
|
if (args.comments) {
|
|
1853
1585
|
if (!apiKey) {
|
|
@@ -1887,6 +1619,8 @@ async function main() {
|
|
|
1887
1619
|
files: fileNames.length,
|
|
1888
1620
|
bytes: totalBytes,
|
|
1889
1621
|
elapsed_ms: elapsed,
|
|
1622
|
+
healed: result.healed ?? [],
|
|
1623
|
+
warnings: result.warnings ?? [],
|
|
1890
1624
|
...args.comments ? { comments_enabled: commentsEnabled, comments_mode: args.commentsMode } : {}
|
|
1891
1625
|
}, null, 2)}
|
|
1892
1626
|
`);
|
|
@@ -1895,7 +1629,8 @@ async function main() {
|
|
|
1895
1629
|
if (args.quiet) {
|
|
1896
1630
|
process.stdout.write(`${result.url}
|
|
1897
1631
|
`);
|
|
1898
|
-
|
|
1632
|
+
if (!linkSaved && !owned)
|
|
1633
|
+
process.stderr.write(`${result.manage_token}
|
|
1899
1634
|
`);
|
|
1900
1635
|
return;
|
|
1901
1636
|
}
|
|
@@ -1910,7 +1645,7 @@ async function main() {
|
|
|
1910
1645
|
process.stderr.write(` ${rule}
|
|
1911
1646
|
|
|
1912
1647
|
`);
|
|
1913
|
-
const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days
|
|
1648
|
+
const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days · \`flypod login\` keeps this and every other site you deployed here` : result.owner_account_id ? "never . attributed to your account" : "never (claimed)";
|
|
1914
1649
|
process.stderr.write(` ${style.muted("expires")} ${style.dim(expiry)}
|
|
1915
1650
|
|
|
1916
1651
|
`);
|
|
@@ -1919,9 +1654,17 @@ async function main() {
|
|
|
1919
1654
|
` + ` ${style.muted("history")} ${style.bold("flypod versions")}
|
|
1920
1655
|
|
|
1921
1656
|
`);
|
|
1922
|
-
|
|
1657
|
+
if (!linkSaved && !owned) {
|
|
1658
|
+
process.stderr.write(` ${style.err("!")} ${style.bold("Couldn't remember this site")} ${style.dim(`— can't write ${projectsFilePath()}`)}
|
|
1659
|
+
` + ` ${style.dim("Save this manage token now — without it you can't update or claim this site:")}
|
|
1660
|
+
` + ` ${style.accent(result.manage_token)}
|
|
1923
1661
|
|
|
1924
1662
|
`);
|
|
1663
|
+
} else if (process.env.FLYPOD_SHOW_TOKEN) {
|
|
1664
|
+
process.stderr.write(` ${style.dim(`manage token ${result.manage_token} — remembered for this folder; needed only with --site elsewhere`)}
|
|
1665
|
+
|
|
1666
|
+
`);
|
|
1667
|
+
}
|
|
1925
1668
|
process.stdout.write(`${result.url}
|
|
1926
1669
|
`);
|
|
1927
1670
|
}
|