flypod 0.18.0 → 0.19.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 +63 -27
- package/dist/bin/deploy.js +247 -43
- package/dist/{cli-4d5fkx95.js → cli-qtqg73w5.js} +434 -231
- package/dist/src/cli/agent-guide.d.ts +16 -0
- package/dist/src/cli/commands.d.ts +25 -1
- package/dist/src/cli/errors.d.ts +4 -1
- package/dist/src/cli/install-id.d.ts +16 -6
- package/dist/src/cli/invoked-via.d.ts +6 -0
- package/dist/src/cli/pending-login.d.ts +17 -0
- package/dist/src/cli-error-codes.d.ts +8 -0
- package/dist/src/cli.js +1 -1
- package/dist/src/client-meta.d.ts +33 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/cli.ts
|
|
2
|
-
import { readdir, readFile as readFile4, realpath, stat as
|
|
3
|
-
import { homedir as
|
|
4
|
-
import { join as
|
|
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";
|
|
5
5
|
|
|
6
6
|
// src/deploy-source.ts
|
|
7
7
|
var SOURCE_HEADER = "x-flypod-source";
|
|
@@ -21,8 +21,8 @@ function coerceSource(value) {
|
|
|
21
21
|
|
|
22
22
|
// src/cli/install-id.ts
|
|
23
23
|
import { randomBytes } from "node:crypto";
|
|
24
|
-
import { readFile } from "node:fs/promises";
|
|
25
|
-
import { join as
|
|
24
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
25
|
+
import { join as join4 } from "node:path";
|
|
26
26
|
|
|
27
27
|
// src/cli/agent-env.ts
|
|
28
28
|
var set = (v) => v !== undefined && v.trim() !== "" && v.trim() !== "0";
|
|
@@ -61,145 +61,15 @@ function detectCi(env) {
|
|
|
61
61
|
return env.GITHUB_ACTIONS === "true";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
// src/cli/
|
|
65
|
-
import {
|
|
66
|
-
import { homedir
|
|
67
|
-
import { dirname, join } from "node:path";
|
|
68
|
-
function configDir(env = process.env) {
|
|
69
|
-
if (env.FLYPOD_CONFIG_DIR)
|
|
70
|
-
return env.FLYPOD_CONFIG_DIR;
|
|
71
|
-
const os = platform();
|
|
72
|
-
if (os === "darwin") {
|
|
73
|
-
return join(homedir(), "Library", "Application Support", "flypod");
|
|
74
|
-
}
|
|
75
|
-
if (os === "win32") {
|
|
76
|
-
const appData = env.APPDATA ?? join(homedir(), "AppData", "Roaming");
|
|
77
|
-
return join(appData, "flypod");
|
|
78
|
-
}
|
|
79
|
-
const xdg = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
80
|
-
return join(xdg, "flypod");
|
|
81
|
-
}
|
|
82
|
-
function sessionFilePath(env = process.env) {
|
|
83
|
-
return join(configDir(env), "session.json");
|
|
84
|
-
}
|
|
85
|
-
function projectsFilePath(env = process.env) {
|
|
86
|
-
return join(configDir(env), "projects.json");
|
|
87
|
-
}
|
|
88
|
-
async function atomicWriteFile(path, content) {
|
|
89
|
-
await mkdir(dirname(path), { recursive: true });
|
|
90
|
-
const tmp = `${path}.tmp`;
|
|
91
|
-
await writeFile(tmp, content, { mode: 384 });
|
|
92
|
-
await rename(tmp, path);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/cli/install-id.ts
|
|
96
|
-
var ID_RE = /^[A-Za-z0-9_-]{16,64}$/;
|
|
97
|
-
var VERSION_RE = /^\d{1,3}\.\d{1,3}\.\d{1,3}(?:-[0-9A-Za-z.-]{1,20})?$/;
|
|
98
|
-
var INSTALL_HEADER = "x-flypod-install";
|
|
99
|
-
var INSTALL_NEW_HEADER = "x-flypod-install-new";
|
|
100
|
-
var VERSION_HEADER = "x-flypod-version";
|
|
101
|
-
var RELINK_HEADER = "x-flypod-relink";
|
|
102
|
-
var AGENT_HEADER = "x-flypod-agent";
|
|
103
|
-
var CI_HEADER = "x-flypod-ci";
|
|
104
|
-
function telemetryOptedOut(env) {
|
|
105
|
-
const dnt = env.DO_NOT_TRACK;
|
|
106
|
-
if (dnt !== undefined && !["", "0", "false"].includes(dnt.trim().toLowerCase()))
|
|
107
|
-
return true;
|
|
108
|
-
const own = env.FLYPOD_TELEMETRY;
|
|
109
|
-
return own !== undefined && ["0", "false", "off", "no"].includes(own.trim().toLowerCase());
|
|
110
|
-
}
|
|
111
|
-
function installFilePath(env = process.env) {
|
|
112
|
-
return join2(configDir(env), "install.json");
|
|
113
|
-
}
|
|
114
|
-
var cache = new Map;
|
|
115
|
-
function installId(env = process.env) {
|
|
116
|
-
if (telemetryOptedOut(env))
|
|
117
|
-
return Promise.resolve(null);
|
|
118
|
-
let path;
|
|
119
|
-
try {
|
|
120
|
-
path = installFilePath(env);
|
|
121
|
-
} catch {
|
|
122
|
-
return Promise.resolve(null);
|
|
123
|
-
}
|
|
124
|
-
let pending = cache.get(path);
|
|
125
|
-
if (!pending) {
|
|
126
|
-
pending = loadOrCreate(path);
|
|
127
|
-
cache.set(path, pending);
|
|
128
|
-
}
|
|
129
|
-
return pending;
|
|
130
|
-
}
|
|
131
|
-
async function loadOrCreate(path) {
|
|
132
|
-
try {
|
|
133
|
-
const saved = JSON.parse(await readFile(path, "utf8"));
|
|
134
|
-
if (typeof saved.install_id === "string" && ID_RE.test(saved.install_id)) {
|
|
135
|
-
return { id: saved.install_id, isNew: false };
|
|
136
|
-
}
|
|
137
|
-
} catch {}
|
|
138
|
-
const id = randomBytes(16).toString("base64url");
|
|
139
|
-
try {
|
|
140
|
-
await atomicWriteFile(path, `${JSON.stringify({ install_id: id, created_at: new Date().toISOString() }, null, 2)}
|
|
141
|
-
`);
|
|
142
|
-
} catch {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
return { id, isNew: true };
|
|
146
|
-
}
|
|
147
|
-
var version;
|
|
148
|
-
function setCliVersion(v) {
|
|
149
|
-
version = VERSION_RE.test(v) ? v : undefined;
|
|
150
|
-
}
|
|
151
|
-
async function identityHeaders(env) {
|
|
152
|
-
const headers = {};
|
|
153
|
-
if (version)
|
|
154
|
-
headers[VERSION_HEADER] = version;
|
|
155
|
-
const install = await installId(env);
|
|
156
|
-
if (install) {
|
|
157
|
-
headers[INSTALL_HEADER] = install.id;
|
|
158
|
-
if (install.isNew)
|
|
159
|
-
headers[INSTALL_NEW_HEADER] = "1";
|
|
160
|
-
}
|
|
161
|
-
if (!telemetryOptedOut(env)) {
|
|
162
|
-
headers[AGENT_HEADER] = detectCodingAgent(env);
|
|
163
|
-
headers[CI_HEADER] = detectCi(env) ? "1" : "0";
|
|
164
|
-
}
|
|
165
|
-
return headers;
|
|
166
|
-
}
|
|
167
|
-
var FIRST_RUN_NOTICE = "flypod counts deploys with a random id. DO_NOT_TRACK=1 stops it.";
|
|
168
|
-
|
|
169
|
-
// src/cli/session.ts
|
|
170
|
-
import { readFile as readFile2, unlink } from "node:fs/promises";
|
|
171
|
-
async function loadSession(env) {
|
|
172
|
-
try {
|
|
173
|
-
const path = sessionFilePath(env);
|
|
174
|
-
const text = await readFile2(path, "utf8");
|
|
175
|
-
const parsed = JSON.parse(text);
|
|
176
|
-
if (typeof parsed?.session_token === "string" && typeof parsed?.base_url === "string" && typeof parsed?.created_at === "number") {
|
|
177
|
-
return parsed;
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
} catch {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
async function saveSession(session, env) {
|
|
185
|
-
const path = sessionFilePath(env);
|
|
186
|
-
await atomicWriteFile(path, `${JSON.stringify(session, null, 2)}
|
|
187
|
-
`);
|
|
188
|
-
return path;
|
|
189
|
-
}
|
|
190
|
-
async function clearSession(env) {
|
|
191
|
-
try {
|
|
192
|
-
await unlink(sessionFilePath(env));
|
|
193
|
-
return true;
|
|
194
|
-
} catch {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
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";
|
|
198
68
|
|
|
199
69
|
// src/cli/skill.ts
|
|
200
|
-
import { mkdir as mkdir2, readFile as
|
|
70
|
+
import { mkdir as mkdir2, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
201
71
|
import { homedir as homedir2 } from "node:os";
|
|
202
|
-
import { dirname as dirname2, join as
|
|
72
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
203
73
|
|
|
204
74
|
// src/cli/screen.ts
|
|
205
75
|
var WIDTH = 66;
|
|
@@ -282,6 +152,85 @@ function storedZipBytes(files) {
|
|
|
282
152
|
return total;
|
|
283
153
|
}
|
|
284
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
|
+
|
|
285
234
|
// src/cli/telemetry.ts
|
|
286
235
|
var REPORT_TIMEOUT_MS = 1500;
|
|
287
236
|
var TELEMETRY_PATH = "/telemetry/cli";
|
|
@@ -333,7 +282,7 @@ async function send(r, body) {
|
|
|
333
282
|
if (!uploadLimitsFor(baseUrl))
|
|
334
283
|
return;
|
|
335
284
|
const headers = {
|
|
336
|
-
...await identityHeaders(r.env),
|
|
285
|
+
...await identityHeaders(r.env, { cwd: r.cwd }),
|
|
337
286
|
[SOURCE_HEADER]: await resolveCliSource(r.env, r.cwd, { stdoutIsTTY: !r.stdoutPiped }),
|
|
338
287
|
"content-type": "application/json"
|
|
339
288
|
};
|
|
@@ -631,7 +580,7 @@ function unauthorizedFor(ctx) {
|
|
|
631
580
|
const base = {
|
|
632
581
|
code: "unauthorized",
|
|
633
582
|
status: ctx.status,
|
|
634
|
-
telemetry: { credential: ctx.sent }
|
|
583
|
+
telemetry: { credential: ctx.sent, known: ctx.known, target: ctx.target }
|
|
635
584
|
};
|
|
636
585
|
const id2 = ctx.siteId;
|
|
637
586
|
switch (ctx.sent) {
|
|
@@ -952,11 +901,14 @@ video or images, it says so and names the folder or the \`.flypodignore\` lines
|
|
|
952
901
|
|
|
953
902
|
\`no_site\` carries a \`reason\`: \`never_linked\` (run \`flypod\` to make the site),
|
|
954
903
|
\`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
|
|
904
|
+
\`flypod login --json\` to keep it), \`gone\` (the site no longer exists: run \`flypod\`), or
|
|
956
905
|
\`other_folder\` (a folder above or below this one is linked: the \`fix\` gives the
|
|
957
906
|
\`--site <id>\` command). \`unauthorized\` on a version verb says what to do with the
|
|
958
907
|
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.
|
|
908
|
+
signed in to, flypod retries as that account by itself. Plain \`flypod\` in a
|
|
909
|
+
folder that already has a site is an update, so it fails the same ways; its
|
|
910
|
+
\`fix\` then also names \`flypod --new\`, for when a separate site is what the
|
|
911
|
+
user wants.
|
|
960
912
|
|
|
961
913
|
Rarer ones: \`unknown_command\` (a verb that does not exist — \`flypod verisons\`
|
|
962
914
|
fails this way with \`"fix": "flypod versions"\` instead of deploying a folder
|
|
@@ -990,10 +942,10 @@ Each warning has a \`code\` and a \`fix_recipe\` naming the change to make.
|
|
|
990
942
|
- \`missing-index\` — nothing is served at \`/\`. Name the entry file \`index.html\`.
|
|
991
943
|
- \`not-spa\` — the page ships scripts but also has visible body content, so
|
|
992
944
|
client-side routing fallback stays off and deep links will 404 on refresh.
|
|
993
|
-
- \`new-site-in-linked-folder
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
945
|
+
- \`new-site-in-linked-folder\`: \`flypod --new\` made a separate site from a
|
|
946
|
+
folder that already had one. Both are live; do not redo it. This folder now
|
|
947
|
+
updates the new site; to ship to the earlier URL, run the
|
|
948
|
+
\`flypod update --site <id>\` the warning names.
|
|
997
949
|
|
|
998
950
|
\`healed\` lists what flypod fixed on your behalf. \`spa-fallback\` there means it
|
|
999
951
|
recognised a single-page app, so unknown paths serve \`index.html\` and
|
|
@@ -1021,7 +973,7 @@ it would otherwise outlive.
|
|
|
1021
973
|
| \`FLYPOD_TOKEN\` | Deploy as your account without logging in (agents / CI) |
|
|
1022
974
|
| \`DEPLOY_URL\` | Point at a different flypod server (default \`https://flypod.dev\`) |
|
|
1023
975
|
| \`FLYPOD_CONFIG_DIR\` | Relocate the session + folder→site memory |
|
|
1024
|
-
| \`DO_NOT_TRACK\` | \`1\` turns off the CLI's random install id, the
|
|
976
|
+
| \`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) |
|
|
1025
977
|
|
|
1026
978
|
\`FLYPOD_TOKEN\` wins over a saved \`flypod login\` session; \`--token\` and a site's own
|
|
1027
979
|
stored manage token win over both. \`FLYPOD_API_KEY\` is read only as a last-resort
|
|
@@ -1059,10 +1011,11 @@ files; flypod serves them.
|
|
|
1059
1011
|
npx flypod ./dist --json
|
|
1060
1012
|
\`\`\`
|
|
1061
1013
|
|
|
1062
|
-
**Every later deploy**
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
\`new
|
|
1014
|
+
**Every later deploy** from the same folder updates that site: plain
|
|
1015
|
+
\`flypod\` again (or \`flypod update\`, the explicit spelling) ships a new
|
|
1016
|
+
version to the URL the user already has, and the receipt says
|
|
1017
|
+
\`"action": "updated"\` (see "Shipping a change"). \`flypod --new\` makes a
|
|
1018
|
+
separate site; run it only when the user asks for one.
|
|
1066
1019
|
|
|
1067
1020
|
3. Read \`url\` from the JSON and give it to the user.
|
|
1068
1021
|
|
|
@@ -1086,6 +1039,7 @@ is the normal path rather than a fallback. To install once: \`npm install -g fly
|
|
|
1086
1039
|
\`\`\`json
|
|
1087
1040
|
{
|
|
1088
1041
|
"ok": true,
|
|
1042
|
+
"action": "created",
|
|
1089
1043
|
"url": "https://a3f1c2d4e5b60789.flypod.page",
|
|
1090
1044
|
"site_id": "a3f1c2d4e5b60789",
|
|
1091
1045
|
"version_id": "…",
|
|
@@ -1093,10 +1047,12 @@ is the normal path rather than a fallback. To install once: \`npm install -g fly
|
|
|
1093
1047
|
"healed": ["spa-fallback"],
|
|
1094
1048
|
"warnings": [],
|
|
1095
1049
|
"link_saved": true,
|
|
1096
|
-
"next": { "update": "flypod update", "versions": "flypod versions", "rollback": "flypod rollback", "keep": "flypod login" }
|
|
1050
|
+
"next": { "update": "flypod update", "versions": "flypod versions", "rollback": "flypod rollback", "keep": "flypod login --json" }
|
|
1097
1051
|
}
|
|
1098
1052
|
\`\`\`
|
|
1099
1053
|
|
|
1054
|
+
- \`action\`: \`"created"\` on a folder's first deploy, \`"updated"\` when the
|
|
1055
|
+
folder already had a site and this run added a version to it.
|
|
1100
1056
|
- \`url\` — the live site. Give it to the user. Read it from the JSON rather than
|
|
1101
1057
|
assembling it: every site is served at \`https://<site_id>.flypod.page\`, on a
|
|
1102
1058
|
different domain from the API and docs (\`flypod.dev\`).
|
|
@@ -1108,7 +1064,8 @@ is the normal path rather than a fallback. To install once: \`npm install -g fly
|
|
|
1108
1064
|
- \`expires_at\` — epoch **milliseconds** while the site is temporary, \`null\` once
|
|
1109
1065
|
it belongs to an account.
|
|
1110
1066
|
- \`next\` — the literal commands for what comes after. \`next.update\` is how a
|
|
1111
|
-
change is shipped to this same URL.
|
|
1067
|
+
change is shipped to this same URL. \`next.keep\`, while the site is
|
|
1068
|
+
temporary, is how it is kept (see below).
|
|
1112
1069
|
- \`link_saved\` — whether \`flypod update\` works from this folder with no flags.
|
|
1113
1070
|
When it is \`false\` (a read-only config dir, typical of CI), the \`next\`
|
|
1114
1071
|
commands carry \`--site <id>\` and the receipt also has a \`manage_token\`:
|
|
@@ -1143,42 +1100,54 @@ account from the start, with no browser:
|
|
|
1143
1100
|
FLYPOD_TOKEN=<session-token> npx flypod ./dist --json
|
|
1144
1101
|
\`\`\`
|
|
1145
1102
|
|
|
1146
|
-
When the user wants to
|
|
1147
|
-
|
|
1103
|
+
When the user wants to keep the site and you have no browser, run the
|
|
1104
|
+
receipt's \`next.keep\`, which is \`flypod login\` with \`--json\` (without it, in
|
|
1105
|
+
a terminal, login waits for a browser):
|
|
1148
1106
|
|
|
1149
1107
|
\`\`\`sh
|
|
1150
1108
|
flypod login --json
|
|
1151
1109
|
# {"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}
|
|
1152
1110
|
\`\`\`
|
|
1153
1111
|
|
|
1154
|
-
It exits at once (code 2). Give the user
|
|
1155
|
-
|
|
1156
|
-
|
|
1112
|
+
It exits at once (code 2). Give the user \`verification_uri_complete\` and the
|
|
1113
|
+
\`user_code\` and ask them to confirm. That is all; there is nothing to poll.
|
|
1114
|
+
Once they have confirmed, your next flypod command of any kind (a deploy,
|
|
1115
|
+
\`flypod list\`) finishes signing in by itself, keeps every temporary site this
|
|
1116
|
+
machine deployed, and runs signed in.
|
|
1117
|
+
|
|
1118
|
+
To finish at once instead (the user has just said they confirmed), pass the
|
|
1119
|
+
\`device_code\` (not the \`user_code\`) from that output:
|
|
1157
1120
|
|
|
1158
1121
|
\`\`\`sh
|
|
1159
1122
|
flypod login --device-code <device_code> --json
|
|
1160
1123
|
# {"ok":true,"logged_in":true,"attached":[…],"skipped":[]} — or
|
|
1161
|
-
# {"ok":false,"code":"authorization_pending",…} — exit 4
|
|
1124
|
+
# {"ok":false,"code":"authorization_pending",…} — exit 4
|
|
1162
1125
|
\`\`\`
|
|
1163
1126
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
\`"ok":true\` you are signed in,
|
|
1127
|
+
It waits up to 25 seconds for the confirmation. \`authorization_pending\` means
|
|
1128
|
+
the user has not confirmed yet: carry on with the work, and the next command
|
|
1129
|
+
finishes it once they do. \`login_expired\` means the code is spent (expired,
|
|
1130
|
+
or already used): if an earlier run printed \`"ok":true\` you are signed in,
|
|
1131
|
+
otherwise start again with \`flypod login --json\`.
|
|
1168
1132
|
|
|
1169
1133
|
A successful login also attaches every temporary site this machine deployed;
|
|
1170
1134
|
\`attached\` lists them.
|
|
1171
1135
|
|
|
1172
1136
|
## Shipping a change
|
|
1173
1137
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1138
|
+
In a folder that already has a site, plain \`flypod\` adds a version to it and
|
|
1139
|
+
the URL holds. \`flypod update\` does the same and says so outright (it also
|
|
1140
|
+
takes \`--site <id>\` from any other folder):
|
|
1177
1141
|
|
|
1178
1142
|
\`\`\`sh
|
|
1179
1143
|
flypod update ./dist
|
|
1180
1144
|
\`\`\`
|
|
1181
1145
|
|
|
1146
|
+
\`flypod --new\` **forks** the site: a separate site on a new URL, while the link
|
|
1147
|
+
you already gave the user stays on the earlier one. Run it only when the user
|
|
1148
|
+
asks for a second site; the receipt then carries \`replaced_link\` and a
|
|
1149
|
+
\`new-site-in-linked-folder\` warning.
|
|
1150
|
+
|
|
1182
1151
|
### Let a reviewer compare versions
|
|
1183
1152
|
|
|
1184
1153
|
\`\`\`sh
|
|
@@ -1260,30 +1229,30 @@ var TARGETS = [
|
|
|
1260
1229
|
id: "claude",
|
|
1261
1230
|
label: "Claude Code",
|
|
1262
1231
|
detail: ".claude/skills/flypod/ — loaded on demand",
|
|
1263
|
-
projectDir: (root) =>
|
|
1264
|
-
globalDir: (env) =>
|
|
1232
|
+
projectDir: (root) => join2(root, ".claude", "skills", SKILL_NAME),
|
|
1233
|
+
globalDir: (env) => join2(home(env), ".claude", "skills", SKILL_NAME)
|
|
1265
1234
|
},
|
|
1266
1235
|
{
|
|
1267
1236
|
id: "agents",
|
|
1268
1237
|
label: "Agent Skills (shared)",
|
|
1269
1238
|
detail: ".agents/skills/flypod/ — Codex, Cursor, Gemini CLI, Copilot",
|
|
1270
|
-
projectDir: (root) =>
|
|
1271
|
-
globalDir: (env) =>
|
|
1239
|
+
projectDir: (root) => join2(root, ".agents", "skills", SKILL_NAME),
|
|
1240
|
+
globalDir: (env) => join2(home(env), ".agents", "skills", SKILL_NAME)
|
|
1272
1241
|
}
|
|
1273
1242
|
];
|
|
1274
1243
|
var LEGACY_PATHS = [
|
|
1275
1244
|
"AGENTS.md",
|
|
1276
1245
|
"GEMINI.md",
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1246
|
+
join2(".github", "copilot-instructions.md"),
|
|
1247
|
+
join2(".cursor", "rules", `${SKILL_NAME}.mdc`),
|
|
1248
|
+
join2(".windsurf", "rules", `${SKILL_NAME}.md`),
|
|
1249
|
+
join2(".clinerules", `${SKILL_NAME}.md`),
|
|
1250
|
+
join2(".roo", "rules", `${SKILL_NAME}.md`)
|
|
1282
1251
|
];
|
|
1283
1252
|
var LEGACY_SHARED = new Set([
|
|
1284
1253
|
"AGENTS.md",
|
|
1285
1254
|
"GEMINI.md",
|
|
1286
|
-
|
|
1255
|
+
join2(".github", "copilot-instructions.md")
|
|
1287
1256
|
]);
|
|
1288
1257
|
var LEGACY_MARK = `<!-- ${SKILL_NAME}:begin -->`;
|
|
1289
1258
|
async function exists(path) {
|
|
@@ -1297,7 +1266,7 @@ async function exists(path) {
|
|
|
1297
1266
|
async function legacyArtifacts(root) {
|
|
1298
1267
|
const found = [];
|
|
1299
1268
|
for (const rel of LEGACY_PATHS) {
|
|
1300
|
-
const path =
|
|
1269
|
+
const path = join2(root, rel);
|
|
1301
1270
|
if (!await exists(path))
|
|
1302
1271
|
continue;
|
|
1303
1272
|
if (!LEGACY_SHARED.has(rel)) {
|
|
@@ -1305,7 +1274,7 @@ async function legacyArtifacts(root) {
|
|
|
1305
1274
|
continue;
|
|
1306
1275
|
}
|
|
1307
1276
|
try {
|
|
1308
|
-
if ((await
|
|
1277
|
+
if ((await readFile2(path, "utf8")).includes(LEGACY_MARK))
|
|
1309
1278
|
found.push(rel);
|
|
1310
1279
|
} catch {}
|
|
1311
1280
|
}
|
|
@@ -1313,7 +1282,7 @@ async function legacyArtifacts(root) {
|
|
|
1313
1282
|
}
|
|
1314
1283
|
async function skillInstalledIn(root) {
|
|
1315
1284
|
for (const target of TARGETS) {
|
|
1316
|
-
if (await exists(
|
|
1285
|
+
if (await exists(join2(target.projectDir(root), "SKILL.md")))
|
|
1317
1286
|
return true;
|
|
1318
1287
|
}
|
|
1319
1288
|
return (await legacyArtifacts(root)).length > 0;
|
|
@@ -1322,16 +1291,16 @@ function globalSkillDirs(env) {
|
|
|
1322
1291
|
const h = home(env);
|
|
1323
1292
|
return [
|
|
1324
1293
|
...TARGETS.map((t) => t.globalDir(env)),
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1294
|
+
join2(h, ".codex", "skills", SKILL_NAME),
|
|
1295
|
+
join2(h, ".cursor", "skills", SKILL_NAME),
|
|
1296
|
+
join2(h, ".gemini", "skills", SKILL_NAME),
|
|
1297
|
+
join2(h, ".copilot", "skills", SKILL_NAME),
|
|
1298
|
+
join2(h, ".config", "opencode", "skills", SKILL_NAME)
|
|
1330
1299
|
];
|
|
1331
1300
|
}
|
|
1332
1301
|
async function skillInstalledGlobally(env) {
|
|
1333
1302
|
for (const dir of globalSkillDirs(env)) {
|
|
1334
|
-
if (await exists(
|
|
1303
|
+
if (await exists(join2(dir, "SKILL.md")))
|
|
1335
1304
|
return true;
|
|
1336
1305
|
}
|
|
1337
1306
|
return false;
|
|
@@ -1339,9 +1308,9 @@ async function skillInstalledGlobally(env) {
|
|
|
1339
1308
|
async function writeTarget(target, dir) {
|
|
1340
1309
|
const results = [];
|
|
1341
1310
|
for (const [rel, content] of Object.entries(skillFiles())) {
|
|
1342
|
-
const path =
|
|
1311
|
+
const path = join2(dir, rel);
|
|
1343
1312
|
const had = await exists(path);
|
|
1344
|
-
if (had && await
|
|
1313
|
+
if (had && await readFile2(path, "utf8") === content) {
|
|
1345
1314
|
results.push({ target, path, status: "unchanged" });
|
|
1346
1315
|
continue;
|
|
1347
1316
|
}
|
|
@@ -1414,14 +1383,14 @@ async function installSkill(args, callerIo) {
|
|
|
1414
1383
|
emit({
|
|
1415
1384
|
ok: true,
|
|
1416
1385
|
dry_run: true,
|
|
1417
|
-
files: selected.flatMap((e) => Object.keys(skillFiles()).map((rel) =>
|
|
1386
|
+
files: selected.flatMap((e) => Object.keys(skillFiles()).map((rel) => join2(e.dir, rel)))
|
|
1418
1387
|
});
|
|
1419
1388
|
return 0;
|
|
1420
1389
|
}
|
|
1421
1390
|
io.err("Would write:");
|
|
1422
1391
|
for (const e of selected) {
|
|
1423
1392
|
for (const rel of Object.keys(skillFiles()))
|
|
1424
|
-
io.out(
|
|
1393
|
+
io.out(join2(e.dir, rel));
|
|
1425
1394
|
}
|
|
1426
1395
|
return 0;
|
|
1427
1396
|
}
|
|
@@ -1468,22 +1437,255 @@ async function installSkill(args, callerIo) {
|
|
|
1468
1437
|
return 0;
|
|
1469
1438
|
}
|
|
1470
1439
|
|
|
1471
|
-
// src/cli/
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1440
|
+
// src/cli/agent-guide.ts
|
|
1441
|
+
var MAX_LEVELS = 4;
|
|
1442
|
+
var MAX_BYTES = 32 * 1024;
|
|
1443
|
+
var MAX_RULES = 20;
|
|
1444
|
+
var NEEDLE = "flypod";
|
|
1445
|
+
var FILES = [
|
|
1446
|
+
["agents_md", "AGENTS.md"],
|
|
1447
|
+
["claude_md", "CLAUDE.md"],
|
|
1448
|
+
["claude_md", join3(".claude", "CLAUDE.md")],
|
|
1449
|
+
["cursor_rules", ".cursorrules"],
|
|
1450
|
+
["copilot", join3(".github", "copilot-instructions.md")],
|
|
1451
|
+
["gemini_md", "GEMINI.md"]
|
|
1452
|
+
];
|
|
1453
|
+
async function mentions(path) {
|
|
1454
|
+
let fh;
|
|
1476
1455
|
try {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
return agentRun && await skillInstalledGlobally(env) ? "skill" : "cli";
|
|
1456
|
+
fh = await open(path, "r");
|
|
1457
|
+
const buf = new Uint8Array(MAX_BYTES);
|
|
1458
|
+
const { bytesRead } = await fh.read(buf, 0, MAX_BYTES, 0);
|
|
1459
|
+
return new TextDecoder().decode(buf.subarray(0, bytesRead)).toLowerCase().includes(NEEDLE);
|
|
1482
1460
|
} catch {
|
|
1483
|
-
return
|
|
1461
|
+
return false;
|
|
1462
|
+
} finally {
|
|
1463
|
+
await fh?.close().catch(() => {});
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
async function cursorRulesMention(dir) {
|
|
1467
|
+
let names;
|
|
1468
|
+
try {
|
|
1469
|
+
names = await readdir(join3(dir, ".cursor", "rules"));
|
|
1470
|
+
} catch {
|
|
1471
|
+
return false;
|
|
1472
|
+
}
|
|
1473
|
+
const rules = names.filter((n) => /\.mdc?$/i.test(n)).slice(0, MAX_RULES);
|
|
1474
|
+
for (const name of rules) {
|
|
1475
|
+
if (await mentions(join3(dir, ".cursor", "rules", name)))
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
async function guideIn(dir) {
|
|
1481
|
+
if (await skillInstalledIn(dir).catch(() => false))
|
|
1482
|
+
return "skill";
|
|
1483
|
+
for (const [kind, rel] of FILES) {
|
|
1484
|
+
if (await mentions(join3(dir, rel)))
|
|
1485
|
+
return kind;
|
|
1486
|
+
if (rel === ".cursorrules" && await cursorRulesMention(dir))
|
|
1487
|
+
return "cursor_rules";
|
|
1488
|
+
}
|
|
1489
|
+
return null;
|
|
1490
|
+
}
|
|
1491
|
+
async function isRepoRoot(dir) {
|
|
1492
|
+
try {
|
|
1493
|
+
await stat2(join3(dir, ".git"));
|
|
1494
|
+
return true;
|
|
1495
|
+
} catch {
|
|
1496
|
+
return false;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
async function detectAgentGuide(cwd, opts = {}) {
|
|
1500
|
+
try {
|
|
1501
|
+
const home2 = resolve(opts.home ?? homedir3());
|
|
1502
|
+
let dir = resolve(cwd);
|
|
1503
|
+
for (let level = 0;level < MAX_LEVELS + 1; level++) {
|
|
1504
|
+
if (dir === home2)
|
|
1505
|
+
break;
|
|
1506
|
+
const found = await guideIn(dir);
|
|
1507
|
+
if (found)
|
|
1508
|
+
return found;
|
|
1509
|
+
if (await isRepoRoot(dir))
|
|
1510
|
+
break;
|
|
1511
|
+
const parent = dirname3(dir);
|
|
1512
|
+
if (parent === dir)
|
|
1513
|
+
break;
|
|
1514
|
+
dir = parent;
|
|
1515
|
+
}
|
|
1516
|
+
return "none";
|
|
1517
|
+
} catch {
|
|
1518
|
+
return "none";
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
var cache = new Map;
|
|
1522
|
+
function agentGuideFor(cwd, opts = {}) {
|
|
1523
|
+
const key = `${resolve(cwd)}\x00${opts.home ?? ""}`;
|
|
1524
|
+
let pending2 = cache.get(key);
|
|
1525
|
+
if (!pending2) {
|
|
1526
|
+
pending2 = detectAgentGuide(cwd, opts);
|
|
1527
|
+
cache.set(key, pending2);
|
|
1528
|
+
}
|
|
1529
|
+
return pending2;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// src/cli/invoked-via.ts
|
|
1533
|
+
import { realpathSync } from "node:fs";
|
|
1534
|
+
function norm(p) {
|
|
1535
|
+
return p.replace(/\\/g, "/").toLowerCase();
|
|
1536
|
+
}
|
|
1537
|
+
function real(p) {
|
|
1538
|
+
try {
|
|
1539
|
+
return realpathSync(p);
|
|
1540
|
+
} catch {
|
|
1541
|
+
return p;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
function manager(env) {
|
|
1545
|
+
const ua = (env.npm_config_user_agent ?? "").trim().toLowerCase();
|
|
1546
|
+
const name = ua.split("/")[0] ?? "";
|
|
1547
|
+
if (name)
|
|
1548
|
+
return name;
|
|
1549
|
+
const exec = norm(env.npm_execpath ?? "");
|
|
1550
|
+
if (exec.includes("pnpm"))
|
|
1551
|
+
return "pnpm";
|
|
1552
|
+
if (exec.includes("yarn"))
|
|
1553
|
+
return "yarn";
|
|
1554
|
+
if (exec.includes("bun"))
|
|
1555
|
+
return "bun";
|
|
1556
|
+
return exec ? "npm" : "";
|
|
1557
|
+
}
|
|
1558
|
+
function fetched(path, env) {
|
|
1559
|
+
if (path.includes("/_npx/"))
|
|
1560
|
+
return "npx";
|
|
1561
|
+
if (/\/bunx-[^/]*\//.test(path))
|
|
1562
|
+
return "bunx";
|
|
1563
|
+
if (/\/pnpm(-cache)?\/dlx\//.test(path))
|
|
1564
|
+
return "pnpm_dlx";
|
|
1565
|
+
if (/\/dlx-[^/]*\//.test(path)) {
|
|
1566
|
+
const by = manager(env);
|
|
1567
|
+
if (by === "yarn" || /\/xfs-[^/]*\//.test(path))
|
|
1568
|
+
return "yarn_dlx";
|
|
1569
|
+
if (by === "pnpm")
|
|
1570
|
+
return "pnpm_dlx";
|
|
1571
|
+
}
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
var GLOBAL_PATTERNS = [
|
|
1575
|
+
/\/lib\/node_modules\//,
|
|
1576
|
+
/\/npm\/node_modules\//,
|
|
1577
|
+
/\/\.bun\/install\/global\//,
|
|
1578
|
+
/\/pnpm\/global\//,
|
|
1579
|
+
/\/yarn\/global\//,
|
|
1580
|
+
/\/\.volta\/tools\//
|
|
1581
|
+
];
|
|
1582
|
+
function detectInvokedVia(env, script, cwd) {
|
|
1583
|
+
try {
|
|
1584
|
+
const path = script ? norm(real(script)) : "";
|
|
1585
|
+
const viaPath = path ? fetched(path, env) : null;
|
|
1586
|
+
if (viaPath)
|
|
1587
|
+
return viaPath;
|
|
1588
|
+
const lifecycle = (env.npm_lifecycle_event ?? "").trim();
|
|
1589
|
+
if (lifecycle && lifecycle !== "npx" && lifecycle !== "bunx")
|
|
1590
|
+
return "script";
|
|
1591
|
+
const at = path.indexOf("/node_modules/");
|
|
1592
|
+
if (at > 0) {
|
|
1593
|
+
const root = path.slice(0, at);
|
|
1594
|
+
const here = norm(real(cwd)).replace(/\/+$/, "");
|
|
1595
|
+
if (here === root || here.startsWith(`${root}/`))
|
|
1596
|
+
return "local";
|
|
1597
|
+
if (GLOBAL_PATTERNS.some((re) => re.test(path)))
|
|
1598
|
+
return "global";
|
|
1599
|
+
}
|
|
1600
|
+
if (env.npm_command === "exec" || lifecycle === "npx")
|
|
1601
|
+
return "npx";
|
|
1602
|
+
if (lifecycle === "bunx")
|
|
1603
|
+
return "bunx";
|
|
1604
|
+
return "other";
|
|
1605
|
+
} catch {
|
|
1606
|
+
return "other";
|
|
1484
1607
|
}
|
|
1485
1608
|
}
|
|
1486
1609
|
|
|
1610
|
+
// src/cli/install-id.ts
|
|
1611
|
+
var ID_RE = /^[A-Za-z0-9_-]{16,64}$/;
|
|
1612
|
+
var VERSION_RE = /^\d{1,3}\.\d{1,3}\.\d{1,3}(?:-[0-9A-Za-z.-]{1,20})?$/;
|
|
1613
|
+
var INSTALL_HEADER = "x-flypod-install";
|
|
1614
|
+
var INSTALL_NEW_HEADER = "x-flypod-install-new";
|
|
1615
|
+
var VERSION_HEADER = "x-flypod-version";
|
|
1616
|
+
var RELINK_HEADER = "x-flypod-relink";
|
|
1617
|
+
var AGENT_HEADER = "x-flypod-agent";
|
|
1618
|
+
var CI_HEADER = "x-flypod-ci";
|
|
1619
|
+
var INVOKED_VIA_HEADER = "x-flypod-invoked-via";
|
|
1620
|
+
var AGENT_GUIDE_HEADER = "x-flypod-agent-guide";
|
|
1621
|
+
function telemetryOptedOut(env) {
|
|
1622
|
+
const dnt = env.DO_NOT_TRACK;
|
|
1623
|
+
if (dnt !== undefined && !["", "0", "false"].includes(dnt.trim().toLowerCase()))
|
|
1624
|
+
return true;
|
|
1625
|
+
const own = env.FLYPOD_TELEMETRY;
|
|
1626
|
+
return own !== undefined && ["0", "false", "off", "no"].includes(own.trim().toLowerCase());
|
|
1627
|
+
}
|
|
1628
|
+
function installFilePath(env = process.env) {
|
|
1629
|
+
return join4(configDir(env), "install.json");
|
|
1630
|
+
}
|
|
1631
|
+
var cache2 = new Map;
|
|
1632
|
+
function installId(env = process.env) {
|
|
1633
|
+
if (telemetryOptedOut(env))
|
|
1634
|
+
return Promise.resolve(null);
|
|
1635
|
+
let path;
|
|
1636
|
+
try {
|
|
1637
|
+
path = installFilePath(env);
|
|
1638
|
+
} catch {
|
|
1639
|
+
return Promise.resolve(null);
|
|
1640
|
+
}
|
|
1641
|
+
let pending2 = cache2.get(path);
|
|
1642
|
+
if (!pending2) {
|
|
1643
|
+
pending2 = loadOrCreate(path);
|
|
1644
|
+
cache2.set(path, pending2);
|
|
1645
|
+
}
|
|
1646
|
+
return pending2;
|
|
1647
|
+
}
|
|
1648
|
+
async function loadOrCreate(path) {
|
|
1649
|
+
try {
|
|
1650
|
+
const saved = JSON.parse(await readFile3(path, "utf8"));
|
|
1651
|
+
if (typeof saved.install_id === "string" && ID_RE.test(saved.install_id)) {
|
|
1652
|
+
return { id: saved.install_id, isNew: false };
|
|
1653
|
+
}
|
|
1654
|
+
} catch {}
|
|
1655
|
+
const id2 = randomBytes(16).toString("base64url");
|
|
1656
|
+
try {
|
|
1657
|
+
await atomicWriteFile(path, `${JSON.stringify({ install_id: id2, created_at: new Date().toISOString() }, null, 2)}
|
|
1658
|
+
`);
|
|
1659
|
+
} catch {
|
|
1660
|
+
return null;
|
|
1661
|
+
}
|
|
1662
|
+
return { id: id2, isNew: true };
|
|
1663
|
+
}
|
|
1664
|
+
var version;
|
|
1665
|
+
function setCliVersion(v) {
|
|
1666
|
+
version = VERSION_RE.test(v) ? v : undefined;
|
|
1667
|
+
}
|
|
1668
|
+
async function identityHeaders(env, opts = {}) {
|
|
1669
|
+
const headers = {};
|
|
1670
|
+
if (version)
|
|
1671
|
+
headers[VERSION_HEADER] = version;
|
|
1672
|
+
const install = await installId(env);
|
|
1673
|
+
if (install) {
|
|
1674
|
+
headers[INSTALL_HEADER] = install.id;
|
|
1675
|
+
if (install.isNew)
|
|
1676
|
+
headers[INSTALL_NEW_HEADER] = "1";
|
|
1677
|
+
}
|
|
1678
|
+
if (!telemetryOptedOut(env)) {
|
|
1679
|
+
headers[AGENT_HEADER] = detectCodingAgent(env);
|
|
1680
|
+
headers[CI_HEADER] = detectCi(env) ? "1" : "0";
|
|
1681
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
1682
|
+
headers[INVOKED_VIA_HEADER] = detectInvokedVia(env, opts.script ?? process.argv[1], cwd);
|
|
1683
|
+
headers[AGENT_GUIDE_HEADER] = await agentGuideFor(cwd, { home: env.HOME });
|
|
1684
|
+
}
|
|
1685
|
+
return headers;
|
|
1686
|
+
}
|
|
1687
|
+
var FIRST_RUN_NOTICE = "flypod counts deploys with a random id. DO_NOT_TRACK=1 stops it.";
|
|
1688
|
+
|
|
1487
1689
|
// src/cli/client.ts
|
|
1488
1690
|
var DEVICE_CLIENT_ID = "flypod-cli";
|
|
1489
1691
|
var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -1548,8 +1750,9 @@ async function createClient(opts) {
|
|
|
1548
1750
|
const fetchImpl = opts.fetch ?? fetch;
|
|
1549
1751
|
const session = await loadSession(env);
|
|
1550
1752
|
const { token, baseUrl } = resolveCredentials(env, session, opts.overrides);
|
|
1551
|
-
const
|
|
1552
|
-
const
|
|
1753
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
1754
|
+
const source = await resolveCliSource(env, cwd);
|
|
1755
|
+
const identity = await identityHeaders(env, { cwd }).catch(() => ({}));
|
|
1553
1756
|
return buildClient(token, baseUrl, fetchImpl, source, identity);
|
|
1554
1757
|
}
|
|
1555
1758
|
|
|
@@ -2226,14 +2429,14 @@ var SOURCE_MARKERS = [
|
|
|
2226
2429
|
];
|
|
2227
2430
|
async function isFile(path) {
|
|
2228
2431
|
try {
|
|
2229
|
-
return (await
|
|
2432
|
+
return (await stat3(path)).isFile();
|
|
2230
2433
|
} catch {
|
|
2231
2434
|
return false;
|
|
2232
2435
|
}
|
|
2233
2436
|
}
|
|
2234
2437
|
async function isDir(path) {
|
|
2235
2438
|
try {
|
|
2236
|
-
return (await
|
|
2439
|
+
return (await stat3(path)).isDirectory();
|
|
2237
2440
|
} catch {
|
|
2238
2441
|
return false;
|
|
2239
2442
|
}
|
|
@@ -2241,30 +2444,30 @@ async function isDir(path) {
|
|
|
2241
2444
|
async function nestedSite(dir) {
|
|
2242
2445
|
let names;
|
|
2243
2446
|
try {
|
|
2244
|
-
names = (await
|
|
2447
|
+
names = (await readdir2(dir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
2245
2448
|
} catch {
|
|
2246
2449
|
return null;
|
|
2247
2450
|
}
|
|
2248
2451
|
const found = [];
|
|
2249
2452
|
for (const name of names) {
|
|
2250
|
-
const sub =
|
|
2251
|
-
if (await isFile(
|
|
2453
|
+
const sub = join5(dir, name);
|
|
2454
|
+
if (await isFile(join5(sub, "index.html")))
|
|
2252
2455
|
found.push(sub);
|
|
2253
|
-
else if (await isFile(
|
|
2254
|
-
found.push(
|
|
2456
|
+
else if (await isFile(join5(sub, "browser", "index.html")))
|
|
2457
|
+
found.push(join5(sub, "browser"));
|
|
2255
2458
|
if (found.length > 1)
|
|
2256
2459
|
return null;
|
|
2257
2460
|
}
|
|
2258
2461
|
return found[0] ?? null;
|
|
2259
2462
|
}
|
|
2260
2463
|
async function deployableAsIs(dir) {
|
|
2261
|
-
const at =
|
|
2262
|
-
if (at ===
|
|
2464
|
+
const at = resolve2(dir);
|
|
2465
|
+
if (at === resolve2(homedir4()) || at === parse(at).root)
|
|
2263
2466
|
return false;
|
|
2264
|
-
if (!await isFile(
|
|
2467
|
+
if (!await isFile(join5(at, "index.html")))
|
|
2265
2468
|
return false;
|
|
2266
2469
|
for (const marker of SOURCE_MARKERS) {
|
|
2267
|
-
if (await isFile(
|
|
2470
|
+
if (await isFile(join5(at, marker)))
|
|
2268
2471
|
return false;
|
|
2269
2472
|
}
|
|
2270
2473
|
return true;
|
|
@@ -2274,12 +2477,12 @@ async function resolveDeployDir(opts = {}) {
|
|
|
2274
2477
|
return opts.explicit;
|
|
2275
2478
|
const cwd = opts.cwd ?? process.cwd();
|
|
2276
2479
|
for (const candidate of BUILD_DIR_CANDIDATES) {
|
|
2277
|
-
const dir =
|
|
2278
|
-
if (await isDir(dir) && await isFile(
|
|
2480
|
+
const dir = join5(cwd, candidate);
|
|
2481
|
+
if (await isDir(dir) && await isFile(join5(dir, "index.html")))
|
|
2279
2482
|
return dir;
|
|
2280
2483
|
}
|
|
2281
2484
|
for (const candidate of BUILD_DIR_CANDIDATES) {
|
|
2282
|
-
const dir =
|
|
2485
|
+
const dir = join5(cwd, candidate);
|
|
2283
2486
|
const nested = await isDir(dir) ? await nestedSite(dir) : null;
|
|
2284
2487
|
if (nested)
|
|
2285
2488
|
return nested;
|
|
@@ -2346,14 +2549,14 @@ function ignoredBy(rules, rel, isDir2) {
|
|
|
2346
2549
|
return verdict;
|
|
2347
2550
|
}
|
|
2348
2551
|
async function collectFiles(path) {
|
|
2349
|
-
const info = await
|
|
2552
|
+
const info = await stat3(path);
|
|
2350
2553
|
if (info.isFile()) {
|
|
2351
2554
|
const name = path.split("/").pop() ?? "index.html";
|
|
2352
2555
|
return { files: { [name]: await readFile4(path) }, skipped: [] };
|
|
2353
2556
|
}
|
|
2354
2557
|
const rules = DEFAULT_IGNORES.map((p) => compileRule(p, "default"));
|
|
2355
2558
|
try {
|
|
2356
|
-
const text = await readFile4(
|
|
2559
|
+
const text = await readFile4(join5(path, IGNORE_FILE), "utf8");
|
|
2357
2560
|
for (const line of text.split(/\r?\n/)) {
|
|
2358
2561
|
const rule = compileRule(line, "flypodignore");
|
|
2359
2562
|
if (rule)
|
|
@@ -2365,17 +2568,17 @@ async function collectFiles(path) {
|
|
|
2365
2568
|
const skipped = [];
|
|
2366
2569
|
const active = new Set([root]);
|
|
2367
2570
|
async function walk(current, currentReal) {
|
|
2368
|
-
for (const entry of await
|
|
2369
|
-
const full =
|
|
2571
|
+
for (const entry of await readdir2(current, { withFileTypes: true })) {
|
|
2572
|
+
const full = join5(current, entry.name);
|
|
2370
2573
|
const rel = relative(path, full).split("\\").join("/");
|
|
2371
2574
|
if (rel === IGNORE_FILE)
|
|
2372
2575
|
continue;
|
|
2373
2576
|
let isDir2 = entry.isDirectory();
|
|
2374
|
-
let
|
|
2577
|
+
let real2;
|
|
2375
2578
|
if (entry.isSymbolicLink()) {
|
|
2376
2579
|
try {
|
|
2377
|
-
|
|
2378
|
-
isDir2 = (await
|
|
2580
|
+
real2 = await realpath(full);
|
|
2581
|
+
isDir2 = (await stat3(real2)).isDirectory();
|
|
2379
2582
|
} catch {
|
|
2380
2583
|
skipped.push({ path: rel, reason: "broken_symlink" });
|
|
2381
2584
|
continue;
|
|
@@ -2387,14 +2590,14 @@ async function collectFiles(path) {
|
|
|
2387
2590
|
continue;
|
|
2388
2591
|
}
|
|
2389
2592
|
if (isDir2) {
|
|
2390
|
-
const childReal =
|
|
2391
|
-
if (
|
|
2392
|
-
const inside =
|
|
2593
|
+
const childReal = real2 ?? join5(currentReal, entry.name);
|
|
2594
|
+
if (real2 !== undefined) {
|
|
2595
|
+
const inside = real2 === root || real2.startsWith(`${root}${sep}`);
|
|
2393
2596
|
if (!inside) {
|
|
2394
2597
|
skipped.push({ path: `${rel}/`, reason: "symlink_outside" });
|
|
2395
2598
|
continue;
|
|
2396
2599
|
}
|
|
2397
|
-
if (active.has(
|
|
2600
|
+
if (active.has(real2)) {
|
|
2398
2601
|
skipped.push({ path: `${rel}/`, reason: "symlink_loop" });
|
|
2399
2602
|
continue;
|
|
2400
2603
|
}
|
|
@@ -2458,4 +2661,4 @@ class DeployError extends Error {
|
|
|
2458
2661
|
}
|
|
2459
2662
|
}
|
|
2460
2663
|
|
|
2461
|
-
export {
|
|
2664
|
+
export { detectCodingAgent, PLAIN, headline, hero, field, notice, failure, shortVersion, HOSTED_UPLOAD_LIMITS, uploadLimitsFor, storedZipBytes, configDir, 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 };
|