flypod 0.16.1 → 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 +165 -41
- package/dist/bin/deploy.js +877 -383
- package/dist/{cli-8h0vc7g2.js → cli-4d5fkx95.js} +842 -83
- 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/client.d.ts +15 -3
- package/dist/src/cli/commands.d.ts +4 -0
- package/dist/src/cli/errors.d.ts +105 -1
- package/dist/src/cli/install-id.d.ts +42 -0
- package/dist/src/cli/limits.d.ts +45 -1
- 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 +26 -5
- package/dist/src/cli/source.d.ts +3 -1
- package/dist/src/cli/telemetry.d.ts +38 -0
- package/dist/src/cli-error-codes.d.ts +28 -0
- package/dist/src/cli.d.ts +16 -3
- package/dist/src/cli.js +1 -1
- package/dist/src/client-meta.d.ts +50 -0
- package/dist/src/deploy-source.d.ts +20 -0
- package/dist/src/ingest-error.d.ts +58 -1
- package/dist/src/upload-shape.d.ts +57 -0
- package/package.json +4 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/cli.ts
|
|
2
|
-
import { readdir, readFile as
|
|
3
|
-
import {
|
|
2
|
+
import { readdir, readFile as readFile4, realpath, stat as stat2 } from "node:fs/promises";
|
|
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";
|
|
@@ -18,8 +19,47 @@ function coerceSource(value) {
|
|
|
18
19
|
return DEPLOY_SOURCES.includes(normalized) ? normalized : "unknown";
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
// src/cli/
|
|
22
|
-
import {
|
|
22
|
+
// src/cli/install-id.ts
|
|
23
|
+
import { randomBytes } from "node:crypto";
|
|
24
|
+
import { readFile } from "node:fs/promises";
|
|
25
|
+
import { join as join2 } from "node:path";
|
|
26
|
+
|
|
27
|
+
// src/cli/agent-env.ts
|
|
28
|
+
var set = (v) => v !== undefined && v.trim() !== "" && v.trim() !== "0";
|
|
29
|
+
function fromAiAgent(value) {
|
|
30
|
+
const name = value.trim().toLowerCase();
|
|
31
|
+
if (name.startsWith("claude"))
|
|
32
|
+
return "claude_code";
|
|
33
|
+
if (name.startsWith("codex"))
|
|
34
|
+
return "codex";
|
|
35
|
+
if (name.startsWith("cursor"))
|
|
36
|
+
return "cursor";
|
|
37
|
+
if (name.startsWith("gemini"))
|
|
38
|
+
return "gemini";
|
|
39
|
+
if (name.startsWith("opencode"))
|
|
40
|
+
return "opencode";
|
|
41
|
+
return "other";
|
|
42
|
+
}
|
|
43
|
+
function detectCodingAgent(env) {
|
|
44
|
+
if (set(env.AI_AGENT))
|
|
45
|
+
return fromAiAgent(env.AI_AGENT);
|
|
46
|
+
if (set(env.CLAUDECODE) || set(env.CLAUDE_CODE_ENTRYPOINT))
|
|
47
|
+
return "claude_code";
|
|
48
|
+
if (set(env.CURSOR_AGENT))
|
|
49
|
+
return "cursor";
|
|
50
|
+
if (set(env.GEMINI_CLI))
|
|
51
|
+
return "gemini";
|
|
52
|
+
if (set(env.CODEX_SANDBOX) || set(env.CODEX_SANDBOX_NETWORK_DISABLED) || set(env.CODEX_THREAD_ID) || set(env.CODEX_MANAGED_BY_NPM)) {
|
|
53
|
+
return "codex";
|
|
54
|
+
}
|
|
55
|
+
return "none";
|
|
56
|
+
}
|
|
57
|
+
function detectCi(env) {
|
|
58
|
+
const ci = (env.CI ?? "").trim().toLowerCase();
|
|
59
|
+
if (ci !== "" && ci !== "0" && ci !== "false")
|
|
60
|
+
return true;
|
|
61
|
+
return env.GITHUB_ACTIONS === "true";
|
|
62
|
+
}
|
|
23
63
|
|
|
24
64
|
// src/cli/paths.ts
|
|
25
65
|
import { mkdir, rename, writeFile } from "node:fs/promises";
|
|
@@ -52,11 +92,86 @@ async function atomicWriteFile(path, content) {
|
|
|
52
92
|
await rename(tmp, path);
|
|
53
93
|
}
|
|
54
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
|
+
|
|
55
169
|
// src/cli/session.ts
|
|
170
|
+
import { readFile as readFile2, unlink } from "node:fs/promises";
|
|
56
171
|
async function loadSession(env) {
|
|
57
172
|
try {
|
|
58
173
|
const path = sessionFilePath(env);
|
|
59
|
-
const text = await
|
|
174
|
+
const text = await readFile2(path, "utf8");
|
|
60
175
|
const parsed = JSON.parse(text);
|
|
61
176
|
if (typeof parsed?.session_token === "string" && typeof parsed?.base_url === "string" && typeof parsed?.created_at === "number") {
|
|
62
177
|
return parsed;
|
|
@@ -82,9 +197,485 @@ async function clearSession(env) {
|
|
|
82
197
|
}
|
|
83
198
|
|
|
84
199
|
// src/cli/skill.ts
|
|
85
|
-
import { mkdir as mkdir2, readFile as
|
|
200
|
+
import { mkdir as mkdir2, readFile as readFile3, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
86
201
|
import { homedir as homedir2 } from "node:os";
|
|
87
|
-
import { dirname as dirname2, join as
|
|
202
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
203
|
+
|
|
204
|
+
// src/cli/screen.ts
|
|
205
|
+
var WIDTH = 66;
|
|
206
|
+
var GUTTER = 10;
|
|
207
|
+
var id = (s) => s;
|
|
208
|
+
var PLAIN = {
|
|
209
|
+
dim: id,
|
|
210
|
+
bold: id,
|
|
211
|
+
muted: id,
|
|
212
|
+
accent: id,
|
|
213
|
+
ok: id,
|
|
214
|
+
err: id,
|
|
215
|
+
warn: id
|
|
216
|
+
};
|
|
217
|
+
function wrap(text, width) {
|
|
218
|
+
const lines = [];
|
|
219
|
+
for (const paragraph of text.split(`
|
|
220
|
+
`)) {
|
|
221
|
+
let line = "";
|
|
222
|
+
for (const word of paragraph.split(/\s+/).filter(Boolean)) {
|
|
223
|
+
if (line && line.length + 1 + word.length > width) {
|
|
224
|
+
lines.push(line);
|
|
225
|
+
line = word;
|
|
226
|
+
} else {
|
|
227
|
+
line = line ? `${line} ${word}` : word;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
lines.push(line);
|
|
231
|
+
}
|
|
232
|
+
return lines;
|
|
233
|
+
}
|
|
234
|
+
function headline(text, detail, s) {
|
|
235
|
+
return ` ${s.ok("✓")} ${text}${detail ? s.dim(` · ${detail}`) : ""}`;
|
|
236
|
+
}
|
|
237
|
+
function hero(url, s) {
|
|
238
|
+
return ` ${s.bold(s.accent(url))}`;
|
|
239
|
+
}
|
|
240
|
+
function field(label, value, hint, s) {
|
|
241
|
+
return ` ${s.muted(label.padEnd(GUTTER))}${value}${hint ? ` ${s.dim(hint)}` : ""}`;
|
|
242
|
+
}
|
|
243
|
+
function notice(title, body, s) {
|
|
244
|
+
return [
|
|
245
|
+
` ${(s.warn ?? id)("!")} ${s.bold(title)}`,
|
|
246
|
+
...wrap(body, WIDTH - 4).map((line) => ` ${s.dim(line)}`),
|
|
247
|
+
""
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
function failure(error, fix, s) {
|
|
251
|
+
const [first = "", ...rest] = wrap(error, WIDTH - 4);
|
|
252
|
+
return [
|
|
253
|
+
` ${(s.err ?? id)("✗")} ${first}`,
|
|
254
|
+
...rest.map((line) => ` ${line}`),
|
|
255
|
+
...fix ? wrap(fix, WIDTH - 4).map((line) => ` ${s.dim(line)}`) : []
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
function shortVersion(versionId) {
|
|
259
|
+
return versionId.slice(0, 8);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/upload-limits.ts
|
|
263
|
+
var HOSTED_UPLOAD_LIMITS = {
|
|
264
|
+
maxFiles: 200,
|
|
265
|
+
maxTotalBytes: 10 * 1024 * 1024,
|
|
266
|
+
maxZipBytes: 12 * 1024 * 1024
|
|
267
|
+
};
|
|
268
|
+
function uploadLimitsFor(baseUrl) {
|
|
269
|
+
try {
|
|
270
|
+
const host = new URL(baseUrl).hostname;
|
|
271
|
+
return host === "flypod.dev" || host.endsWith(".flypod.dev") ? HOSTED_UPLOAD_LIMITS : null;
|
|
272
|
+
} catch {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function storedZipBytes(files) {
|
|
277
|
+
const encoder = new TextEncoder;
|
|
278
|
+
let total = 22;
|
|
279
|
+
for (const [name, bytes] of Object.entries(files)) {
|
|
280
|
+
total += 76 + 2 * encoder.encode(name).byteLength + bytes.byteLength;
|
|
281
|
+
}
|
|
282
|
+
return total;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// src/cli/telemetry.ts
|
|
286
|
+
var REPORT_TIMEOUT_MS = 1500;
|
|
287
|
+
var TELEMETRY_PATH = "/telemetry/cli";
|
|
288
|
+
var NOT_FAILURES = new Set(["authorization_pending"]);
|
|
289
|
+
var run = null;
|
|
290
|
+
var pending = new Set;
|
|
291
|
+
function startFailureReports(opts) {
|
|
292
|
+
if (opts.help) {
|
|
293
|
+
run = null;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
run = {
|
|
297
|
+
verb: opts.verb,
|
|
298
|
+
env: opts.env ?? process.env,
|
|
299
|
+
fetch: opts.fetch ?? fetch,
|
|
300
|
+
cwd: opts.cwd ?? process.cwd(),
|
|
301
|
+
stdoutPiped: !(opts.stdoutIsTTY ?? process.stdout.isTTY)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function reportFailure(err, args) {
|
|
305
|
+
const current = run;
|
|
306
|
+
if (!current || telemetryOptedOut(current.env))
|
|
307
|
+
return;
|
|
308
|
+
if (NOT_FAILURES.has(err.code))
|
|
309
|
+
return;
|
|
310
|
+
const agent = current.stdoutPiped || Boolean(args.json);
|
|
311
|
+
const sent = send(current, reportBody(err, current.verb, agent)).catch(() => {});
|
|
312
|
+
pending.add(sent);
|
|
313
|
+
sent.finally(() => pending.delete(sent));
|
|
314
|
+
}
|
|
315
|
+
async function flushFailureReports() {
|
|
316
|
+
if (pending.size === 0)
|
|
317
|
+
return;
|
|
318
|
+
let timer;
|
|
319
|
+
await Promise.race([
|
|
320
|
+
Promise.allSettled([...pending]),
|
|
321
|
+
new Promise((resolve) => {
|
|
322
|
+
timer = setTimeout(resolve, REPORT_TIMEOUT_MS + 50);
|
|
323
|
+
})
|
|
324
|
+
]);
|
|
325
|
+
clearTimeout(timer);
|
|
326
|
+
}
|
|
327
|
+
async function send(r, body) {
|
|
328
|
+
const controller = new AbortController;
|
|
329
|
+
const timer = setTimeout(() => controller.abort(), REPORT_TIMEOUT_MS);
|
|
330
|
+
try {
|
|
331
|
+
const session = await loadSession(r.env).catch(() => null);
|
|
332
|
+
const { baseUrl } = resolveCredentials(r.env, session);
|
|
333
|
+
if (!uploadLimitsFor(baseUrl))
|
|
334
|
+
return;
|
|
335
|
+
const headers = {
|
|
336
|
+
...await identityHeaders(r.env),
|
|
337
|
+
[SOURCE_HEADER]: await resolveCliSource(r.env, r.cwd, { stdoutIsTTY: !r.stdoutPiped }),
|
|
338
|
+
"content-type": "application/json"
|
|
339
|
+
};
|
|
340
|
+
const res = await r.fetch(new URL(TELEMETRY_PATH, baseUrl).toString(), {
|
|
341
|
+
method: "POST",
|
|
342
|
+
headers,
|
|
343
|
+
body: JSON.stringify(body),
|
|
344
|
+
signal: controller.signal
|
|
345
|
+
});
|
|
346
|
+
await res.body?.cancel().catch(() => {});
|
|
347
|
+
} finally {
|
|
348
|
+
clearTimeout(timer);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function runtime() {
|
|
352
|
+
if ("Deno" in globalThis)
|
|
353
|
+
return "deno";
|
|
354
|
+
return process.versions.bun ? "bun" : "node";
|
|
355
|
+
}
|
|
356
|
+
function reportBody(err, verb, agent) {
|
|
357
|
+
const body = {
|
|
358
|
+
code: err.code,
|
|
359
|
+
verb,
|
|
360
|
+
os: process.platform,
|
|
361
|
+
node: (process.versions.node ?? "").split(".")[0],
|
|
362
|
+
runtime: runtime(),
|
|
363
|
+
agent
|
|
364
|
+
};
|
|
365
|
+
if (err.status !== undefined)
|
|
366
|
+
body.status = err.status;
|
|
367
|
+
for (const [key, value] of Object.entries(err.telemetry ?? {})) {
|
|
368
|
+
if (typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
|
|
369
|
+
body[key] = value;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return body;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// src/cli/errors.ts
|
|
376
|
+
var USAGE_CODES = new Set([
|
|
377
|
+
"usage",
|
|
378
|
+
"unknown_command",
|
|
379
|
+
"unknown_flag",
|
|
380
|
+
"interactive_login_required"
|
|
381
|
+
]);
|
|
382
|
+
var AUTH_CODES = new Set([
|
|
383
|
+
"not_signed_in",
|
|
384
|
+
"unauthorized",
|
|
385
|
+
"token_rejected",
|
|
386
|
+
"no_token",
|
|
387
|
+
"login_denied"
|
|
388
|
+
]);
|
|
389
|
+
var RETRY_CODES = new Set([
|
|
390
|
+
"rate_limited",
|
|
391
|
+
"server_error",
|
|
392
|
+
"network",
|
|
393
|
+
"authorization_pending",
|
|
394
|
+
"login_timeout"
|
|
395
|
+
]);
|
|
396
|
+
function exitCodeFor(code) {
|
|
397
|
+
if (USAGE_CODES.has(code))
|
|
398
|
+
return 2;
|
|
399
|
+
if (AUTH_CODES.has(code))
|
|
400
|
+
return 3;
|
|
401
|
+
if (RETRY_CODES.has(code))
|
|
402
|
+
return 4;
|
|
403
|
+
return 1;
|
|
404
|
+
}
|
|
405
|
+
function errorEnvelope(err) {
|
|
406
|
+
return {
|
|
407
|
+
ok: false,
|
|
408
|
+
code: err.code,
|
|
409
|
+
error: err.error,
|
|
410
|
+
...err.fix ? { fix: err.fix } : {},
|
|
411
|
+
...err.status !== undefined ? { status: err.status } : {},
|
|
412
|
+
...err.extra ?? {}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function emitError(err, args, io, _opts = {}) {
|
|
416
|
+
if (args.json) {
|
|
417
|
+
io.out(JSON.stringify(errorEnvelope(err)));
|
|
418
|
+
} else {
|
|
419
|
+
for (const line of failure(err.error, err.fix, io.style ?? PLAIN))
|
|
420
|
+
io.err(line);
|
|
421
|
+
}
|
|
422
|
+
reportFailure(err, args);
|
|
423
|
+
return exitCodeFor(err.code);
|
|
424
|
+
}
|
|
425
|
+
function fail(code, error, args, io, opts = {}) {
|
|
426
|
+
return emitError({ code, error, fix: opts.fix, status: opts.status, extra: opts.extra }, args, io, { prefix: opts.prefix });
|
|
427
|
+
}
|
|
428
|
+
async function readServerMessage(res) {
|
|
429
|
+
const text = await res.text().catch(() => "");
|
|
430
|
+
if (!text)
|
|
431
|
+
return { message: `HTTP ${res.status}` };
|
|
432
|
+
try {
|
|
433
|
+
const body = JSON.parse(text);
|
|
434
|
+
const message = typeof body.error === "string" ? body.error : typeof body.message === "string" ? body.message : text;
|
|
435
|
+
return {
|
|
436
|
+
message,
|
|
437
|
+
code: typeof body.code === "string" ? body.code : undefined,
|
|
438
|
+
json: true,
|
|
439
|
+
...typeof body.fix === "string" && body.fix ? { fix: body.fix } : {},
|
|
440
|
+
...typeof body.limit === "string" ? { limit: body.limit } : {},
|
|
441
|
+
...typeof body.request_id === "string" && body.request_id ? { requestId: body.request_id } : {}
|
|
442
|
+
};
|
|
443
|
+
} catch {
|
|
444
|
+
const cfError = cloudflareErrorNumber(text);
|
|
445
|
+
return {
|
|
446
|
+
message: text.length > 200 ? `${text.slice(0, 200)}…` : text,
|
|
447
|
+
...cfError !== undefined ? { cfError } : {}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
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
|
+
};
|
|
459
|
+
async function classifyResponse(res, ctx) {
|
|
460
|
+
const said = await readServerMessage(res);
|
|
461
|
+
const err = classifyParsed(res, said, ctx);
|
|
462
|
+
if (said.fix)
|
|
463
|
+
err.fix = said.fix;
|
|
464
|
+
if (err.code === "too_large" && said.limit && SIZE_LIMITS.includes(said.limit)) {
|
|
465
|
+
err.telemetry = { ...err.telemetry, limit: said.limit };
|
|
466
|
+
}
|
|
467
|
+
return err;
|
|
468
|
+
}
|
|
469
|
+
var UNAUTHORIZED_FIX = "Run `flypod login`, or pass --token <manage_token> for a site this machine does not remember.";
|
|
470
|
+
var SIZE_LIMITS = ["files", "total_bytes", "zip_bytes"];
|
|
471
|
+
function classifyParsed(res, said, ctx) {
|
|
472
|
+
const { message, code: serverCode, json } = said;
|
|
473
|
+
const status = res.status;
|
|
474
|
+
const site = ctx.siteId ? ` ${ctx.siteId}` : "";
|
|
475
|
+
const base = { status, error: message };
|
|
476
|
+
if (serverCode === "token_rejected") {
|
|
477
|
+
return {
|
|
478
|
+
...base,
|
|
479
|
+
code: "token_rejected",
|
|
480
|
+
error: "The credential you sent was not accepted, so nothing was deployed.",
|
|
481
|
+
fix: "Run `flypod login` again, or set a valid FLYPOD_TOKEN (unset it to deploy anonymously)."
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
if (serverCode === "challenge_required" || /challenge required/i.test(message)) {
|
|
485
|
+
return {
|
|
486
|
+
...base,
|
|
487
|
+
code: "challenge_required",
|
|
488
|
+
error: "The server wants a human challenge for this deploy.",
|
|
489
|
+
fix: "Run `flypod login` and deploy again: signed-in deploys skip the challenge."
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
switch (status) {
|
|
493
|
+
case 401:
|
|
494
|
+
case 403:
|
|
495
|
+
if (!json && message !== `HTTP ${status}`) {
|
|
496
|
+
return {
|
|
497
|
+
...base,
|
|
498
|
+
code: "network",
|
|
499
|
+
error: `Something between this machine and the server refused the request (HTTP ${status}): ${message}`,
|
|
500
|
+
fix: "Check the proxy or firewall settings (and DEPLOY_URL, if set), then retry."
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
if (serverCode === "blocked") {
|
|
504
|
+
return {
|
|
505
|
+
...base,
|
|
506
|
+
code: "blocked",
|
|
507
|
+
error: `Deploy refused: ${message}`,
|
|
508
|
+
fix: "The content tripped the abuse guard. Remove the flagged files and try again."
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
...base,
|
|
513
|
+
code: "unauthorized",
|
|
514
|
+
error: `Not authorized for site${site}.`,
|
|
515
|
+
fix: UNAUTHORIZED_FIX
|
|
516
|
+
};
|
|
517
|
+
case 404:
|
|
518
|
+
return ctx.siteScoped ? {
|
|
519
|
+
...base,
|
|
520
|
+
code: "site_gone",
|
|
521
|
+
error: `Site${site} is gone (expired or deleted).`,
|
|
522
|
+
fix: "Run `flypod` to create a new site."
|
|
523
|
+
} : { ...base, code: "not_found", error: message };
|
|
524
|
+
case 409:
|
|
525
|
+
return {
|
|
526
|
+
...base,
|
|
527
|
+
code: "already_claimed",
|
|
528
|
+
error: `Site${site} already belongs to another account.`
|
|
529
|
+
};
|
|
530
|
+
case 400:
|
|
531
|
+
return { ...base, code: "invalid_upload", error: `Rejected: ${message}` };
|
|
532
|
+
case 413:
|
|
533
|
+
return {
|
|
534
|
+
...base,
|
|
535
|
+
code: "too_large",
|
|
536
|
+
error: /^upload too large\.?$/i.test(message) ? "The upload is larger than the server accepts." : `The server refused the upload: ${message.replace(/\.$/, "")}.`,
|
|
537
|
+
fix: "Shrink the build (fewer files, smaller assets) or split it. See flypod.dev/limits."
|
|
538
|
+
};
|
|
539
|
+
case 429:
|
|
540
|
+
return {
|
|
541
|
+
...base,
|
|
542
|
+
code: "rate_limited",
|
|
543
|
+
error: "Too many requests from this network right now.",
|
|
544
|
+
fix: "Wait a minute and retry the same command.",
|
|
545
|
+
extra: retryAfter(res)
|
|
546
|
+
};
|
|
547
|
+
default:
|
|
548
|
+
if (status >= 500)
|
|
549
|
+
return serverError(status, said, ctx.verb);
|
|
550
|
+
return { ...base, code: "bad_request", error: `${ctx.verb}: ${message}` };
|
|
551
|
+
}
|
|
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
|
+
}
|
|
578
|
+
function retryAfter(res) {
|
|
579
|
+
const raw = res.headers.get("retry-after");
|
|
580
|
+
const seconds = raw ? Number(raw) : Number.NaN;
|
|
581
|
+
return Number.isFinite(seconds) ? { retry_after_s: seconds } : {};
|
|
582
|
+
}
|
|
583
|
+
function noBuildDir(message) {
|
|
584
|
+
const cut = message.indexOf(". ");
|
|
585
|
+
if (cut === -1)
|
|
586
|
+
return { code: "no_build_dir", error: message };
|
|
587
|
+
return { code: "no_build_dir", error: message.slice(0, cut + 1), fix: message.slice(cut + 2) };
|
|
588
|
+
}
|
|
589
|
+
function networkError(e, baseUrl) {
|
|
590
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
591
|
+
const host = baseUrl ? ` ${safeHost(baseUrl)}` : "";
|
|
592
|
+
return {
|
|
593
|
+
code: "network",
|
|
594
|
+
error: `Could not reach the flypod server${host}: ${reason}`,
|
|
595
|
+
fix: "Check your connection (and DEPLOY_URL, if set), then retry."
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function safeHost(url) {
|
|
599
|
+
try {
|
|
600
|
+
return new URL(url).host;
|
|
601
|
+
} catch {
|
|
602
|
+
return url;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
var NO_SITE = {
|
|
606
|
+
code: "no_site",
|
|
607
|
+
error: "No flypod site is linked to this folder.",
|
|
608
|
+
fix: "Run `flypod` here to create one, or pass --site <id>."
|
|
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
|
+
}
|
|
668
|
+
var NOT_SIGNED_IN = {
|
|
669
|
+
code: "not_signed_in",
|
|
670
|
+
error: "Not signed in.",
|
|
671
|
+
fix: "Run `flypod login`, or set FLYPOD_TOKEN."
|
|
672
|
+
};
|
|
673
|
+
function unexpectedError(e) {
|
|
674
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
675
|
+
return { code: "unexpected", error: `unexpected error: ${reason}` };
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// src/cli/skill.ts
|
|
88
679
|
var SKILL_NAME = "flypod";
|
|
89
680
|
var SKILL_DESCRIPTION = "Deploy a folder of static files or Markdown to a live, public URL anyone can open — no account, no config. " + "Use it when the user asks to deploy, publish, or share something built; " + "when a build has just finished and someone else needs to look at it; " + "when a report, research write-up, or set of Markdown notes should become a browsable site instead of a file; " + "or when a screenshot or a local dev server will not do because the recipient must open it themselves. " + "Static output only — flypod serves files, and does not run a server or build them.";
|
|
90
681
|
function yamlScalar(value) {
|
|
@@ -146,6 +737,12 @@ A version id is a hash of the files, so deploying byte-identical content again
|
|
|
146
737
|
is a no-op: same hash, same version, no new entry in the history. A redundant
|
|
147
738
|
\`flypod update\` is free, and needs no guard.
|
|
148
739
|
|
|
740
|
+
## How long versions last
|
|
741
|
+
|
|
742
|
+
The live version stays as long as the site does. Any other version is deleted
|
|
743
|
+
seven days after it was deployed, so \`flypod rollback\` can reach back about a
|
|
744
|
+
week; \`flypod versions\` shows what is still there.
|
|
745
|
+
|
|
149
746
|
## Typical loop
|
|
150
747
|
|
|
151
748
|
\`\`\`sh
|
|
@@ -264,7 +861,7 @@ flypod comments off --site <site_id> # disable; existing data is preserve
|
|
|
264
861
|
| --- | --- |
|
|
265
862
|
| \`anonymous\` | anyone with the link, no sign-in — best for quick previews |
|
|
266
863
|
| \`passcode\` | anyone holding the passcode you set with \`--passcode\` |
|
|
267
|
-
| \`approved\` |
|
|
864
|
+
| \`approved\` | anyone with the link, but each comment stays hidden until the owner approves it — best for anything semi-public |
|
|
268
865
|
|
|
269
866
|
Default when you pass \`--comments\` with no mode: \`anonymous\`.
|
|
270
867
|
|
|
@@ -292,10 +889,13 @@ flypod comments reopen <site_id> <thread_id>
|
|
|
292
889
|
## Authorization
|
|
293
890
|
|
|
294
891
|
Read verbs follow the site's own policy. **Write verbs — \`post\`, \`resolve\`,
|
|
295
|
-
\`reopen\`, and the \`enable\`/\`mode\`/\`off\` verbs — need an account session
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
892
|
+
\`reopen\`, and the \`enable\`/\`mode\`/\`off\` verbs — need an account session**, and
|
|
893
|
+
\`enable\`/\`mode\`/\`off\` only work on a site that account owns. Run \`flypod login\`,
|
|
894
|
+
or set \`FLYPOD_TOKEN\` to a session token. With no credential they fail with
|
|
895
|
+
\`not_signed_in\` (exit 3). A token starting \`fk_\` is a retired API key that flypod
|
|
896
|
+
no longer accepts for anything: \`post\`, \`resolve\` and \`reopen\` refuse it before
|
|
897
|
+
sending (\`unauthorized\`, exit 3), and a deploy that carries one fails with
|
|
898
|
+
\`token_rejected\`. \`reference/troubleshooting.md\` has the full exit-code table.
|
|
299
899
|
|
|
300
900
|
## The review loop
|
|
301
901
|
|
|
@@ -320,27 +920,43 @@ var troubleshootingReference = {
|
|
|
320
920
|
| \`0\` | success |
|
|
321
921
|
| \`1\` | runtime error you can act on — no build folder, site gone, upload rejected or blocked |
|
|
322
922
|
| \`2\` | usage error — unknown flag or bad arguments, or a login that needs a browser |
|
|
323
|
-
| \`3\` | auth — not signed in, credential refused (\`token_rejected\`), sign-in denied |
|
|
923
|
+
| \`3\` | auth — not signed in, credential refused (\`unauthorized\`, \`token_rejected\`), no manage token held (\`no_token\`), sign-in denied |
|
|
324
924
|
| \`4\` | retryable — rate limited, server 5xx, network failure (including a proxy refusing the request), sign-in still pending |
|
|
325
925
|
|
|
326
926
|
The exit code follows the failure's \`code\`, on every verb. With \`--json\`, every
|
|
327
927
|
failure prints one line on stdout and nothing on stderr:
|
|
328
928
|
|
|
329
929
|
\`\`\`json
|
|
330
|
-
{"ok": false, "code": "rate_limited", "error": "…", "fix": "Wait a minute and retry the same command.", "retry_after_s": 30}
|
|
930
|
+
{"ok": false, "code": "rate_limited", "error": "…", "fix": "Wait a minute and retry the same command.", "status": 429, "retry_after_s": 30}
|
|
331
931
|
\`\`\`
|
|
332
932
|
|
|
333
933
|
Branch on \`code\` (stable), never on \`error\` (prose). \`fix\` is the literal next
|
|
334
|
-
step when there is one. Codes you will meet: \`no_build_dir\`, \`no_files\`,
|
|
934
|
+
step when there is one; \`status\` is the HTTP status when a server answered. Codes you will meet: \`no_build_dir\`, \`no_files\`,
|
|
335
935
|
\`no_site\`, \`not_signed_in\`, \`unauthorized\`, \`token_rejected\`, \`site_gone\`,
|
|
336
936
|
\`invalid_upload\`, \`too_large\`, \`blocked\`, \`challenge_required\`,
|
|
337
937
|
\`rate_limited\`, \`server_error\`, \`network\`, \`unknown_flag\`, \`usage\`.
|
|
338
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
|
+
|
|
339
943
|
\`usage\` includes a value flag given no value (\`--site needs a value\`) and a
|
|
340
944
|
\`--mode\` that is not \`anonymous\`, \`passcode\` or \`approved\`. \`unknown_flag\`
|
|
341
945
|
names the closest real flag when there is one. \`no_build_dir\` also covers a
|
|
342
|
-
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
|
|
343
949
|
(at most 200 files, 10 MB of files, 12 MB as an upload) and names the largest files.
|
|
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.
|
|
344
960
|
|
|
345
961
|
Rarer ones: \`unknown_command\` (a verb that does not exist — \`flypod verisons\`
|
|
346
962
|
fails this way with \`"fix": "flypod versions"\` instead of deploying a folder
|
|
@@ -374,6 +990,10 @@ Each warning has a \`code\` and a \`fix_recipe\` naming the change to make.
|
|
|
374
990
|
- \`missing-index\` — nothing is served at \`/\`. Name the entry file \`index.html\`.
|
|
375
991
|
- \`not-spa\` — the page ships scripts but also has visible body content, so
|
|
376
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.
|
|
377
997
|
|
|
378
998
|
\`healed\` lists what flypod fixed on your behalf. \`spa-fallback\` there means it
|
|
379
999
|
recognised a single-page app, so unknown paths serve \`index.html\` and
|
|
@@ -401,6 +1021,11 @@ it would otherwise outlive.
|
|
|
401
1021
|
| \`FLYPOD_TOKEN\` | Deploy as your account without logging in (agents / CI) |
|
|
402
1022
|
| \`DEPLOY_URL\` | Point at a different flypod server (default \`https://flypod.dev\`) |
|
|
403
1023
|
| \`FLYPOD_CONFIG_DIR\` | Relocate the session + folder→site memory |
|
|
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) |
|
|
1025
|
+
|
|
1026
|
+
\`FLYPOD_TOKEN\` wins over a saved \`flypod login\` session; \`--token\` and a site's own
|
|
1027
|
+
stored manage token win over both. \`FLYPOD_API_KEY\` is read only as a last-resort
|
|
1028
|
+
fallback for older setups.
|
|
404
1029
|
|
|
405
1030
|
## Getting the full command surface
|
|
406
1031
|
|
|
@@ -428,12 +1053,17 @@ files; flypod serves them.
|
|
|
428
1053
|
|
|
429
1054
|
1. Build first, if the project has a build — flypod serves files, it does not
|
|
430
1055
|
make them. You want a folder whose contents *are* the finished site.
|
|
431
|
-
2. Deploy it:
|
|
1056
|
+
2. Deploy it. **The first time**, \`flypod\` makes the site:
|
|
432
1057
|
|
|
433
1058
|
\`\`\`sh
|
|
434
1059
|
npx flypod ./dist --json
|
|
435
1060
|
\`\`\`
|
|
436
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
|
+
|
|
437
1067
|
3. Read \`url\` from the JSON and give it to the user.
|
|
438
1068
|
|
|
439
1069
|
**Done when** the user has the URL, and \`warnings\` is empty or you have told
|
|
@@ -441,7 +1071,10 @@ them what is in it.
|
|
|
441
1071
|
|
|
442
1072
|
Omit the path and flypod auto-detects a build folder, trying \`dist\`, \`build\`,
|
|
443
1073
|
\`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\` — each of
|
|
444
|
-
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.
|
|
445
1078
|
|
|
446
1079
|
A single file deploys too: \`flypod report.html\`. For several, deploy the folder.
|
|
447
1080
|
|
|
@@ -515,11 +1148,12 @@ When the user wants to sign in and you have no browser, do not run a bare
|
|
|
515
1148
|
|
|
516
1149
|
\`\`\`sh
|
|
517
1150
|
flypod login --json
|
|
518
|
-
# {"ok":false,"code":"interactive_login_required","verification_uri_complete":"https://…","user_code":"ABCD-1234","device_code":"…","
|
|
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}
|
|
519
1152
|
\`\`\`
|
|
520
1153
|
|
|
521
|
-
It exits at once (code 2). Give the user the URL and the
|
|
522
|
-
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:
|
|
523
1157
|
|
|
524
1158
|
\`\`\`sh
|
|
525
1159
|
flypod login --device-code <device_code> --json
|
|
@@ -527,6 +1161,11 @@ flypod login --device-code <device_code> --json
|
|
|
527
1161
|
# {"ok":false,"code":"authorization_pending",…} — exit 4, ask again later
|
|
528
1162
|
\`\`\`
|
|
529
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
|
+
|
|
530
1169
|
A successful login also attaches every temporary site this machine deployed;
|
|
531
1170
|
\`attached\` lists them.
|
|
532
1171
|
|
|
@@ -555,8 +1194,8 @@ choosing between iterations. It is off by default because it makes replaced
|
|
|
555
1194
|
versions public: do not turn it on for a site where an earlier version held
|
|
556
1195
|
something that was removed on purpose. With it on, \`--json\` carries a
|
|
557
1196
|
\`history_url\` to give the user (two versions side by side), and
|
|
558
|
-
\`flypod versions --json\` a \`url\` for each version.
|
|
559
|
-
|
|
1197
|
+
\`flypod versions --json\` a \`url\` for each version. A version that is not live is
|
|
1198
|
+
deleted seven days after it was deployed, so the timeline shows about a week.
|
|
560
1199
|
|
|
561
1200
|
## Where sites live
|
|
562
1201
|
|
|
@@ -621,30 +1260,30 @@ var TARGETS = [
|
|
|
621
1260
|
id: "claude",
|
|
622
1261
|
label: "Claude Code",
|
|
623
1262
|
detail: ".claude/skills/flypod/ — loaded on demand",
|
|
624
|
-
projectDir: (root) =>
|
|
625
|
-
globalDir: (env) =>
|
|
1263
|
+
projectDir: (root) => join3(root, ".claude", "skills", SKILL_NAME),
|
|
1264
|
+
globalDir: (env) => join3(home(env), ".claude", "skills", SKILL_NAME)
|
|
626
1265
|
},
|
|
627
1266
|
{
|
|
628
1267
|
id: "agents",
|
|
629
1268
|
label: "Agent Skills (shared)",
|
|
630
1269
|
detail: ".agents/skills/flypod/ — Codex, Cursor, Gemini CLI, Copilot",
|
|
631
|
-
projectDir: (root) =>
|
|
632
|
-
globalDir: (env) =>
|
|
1270
|
+
projectDir: (root) => join3(root, ".agents", "skills", SKILL_NAME),
|
|
1271
|
+
globalDir: (env) => join3(home(env), ".agents", "skills", SKILL_NAME)
|
|
633
1272
|
}
|
|
634
1273
|
];
|
|
635
1274
|
var LEGACY_PATHS = [
|
|
636
1275
|
"AGENTS.md",
|
|
637
1276
|
"GEMINI.md",
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
1277
|
+
join3(".github", "copilot-instructions.md"),
|
|
1278
|
+
join3(".cursor", "rules", `${SKILL_NAME}.mdc`),
|
|
1279
|
+
join3(".windsurf", "rules", `${SKILL_NAME}.md`),
|
|
1280
|
+
join3(".clinerules", `${SKILL_NAME}.md`),
|
|
1281
|
+
join3(".roo", "rules", `${SKILL_NAME}.md`)
|
|
643
1282
|
];
|
|
644
1283
|
var LEGACY_SHARED = new Set([
|
|
645
1284
|
"AGENTS.md",
|
|
646
1285
|
"GEMINI.md",
|
|
647
|
-
|
|
1286
|
+
join3(".github", "copilot-instructions.md")
|
|
648
1287
|
]);
|
|
649
1288
|
var LEGACY_MARK = `<!-- ${SKILL_NAME}:begin -->`;
|
|
650
1289
|
async function exists(path) {
|
|
@@ -658,7 +1297,7 @@ async function exists(path) {
|
|
|
658
1297
|
async function legacyArtifacts(root) {
|
|
659
1298
|
const found = [];
|
|
660
1299
|
for (const rel of LEGACY_PATHS) {
|
|
661
|
-
const path =
|
|
1300
|
+
const path = join3(root, rel);
|
|
662
1301
|
if (!await exists(path))
|
|
663
1302
|
continue;
|
|
664
1303
|
if (!LEGACY_SHARED.has(rel)) {
|
|
@@ -666,7 +1305,7 @@ async function legacyArtifacts(root) {
|
|
|
666
1305
|
continue;
|
|
667
1306
|
}
|
|
668
1307
|
try {
|
|
669
|
-
if ((await
|
|
1308
|
+
if ((await readFile3(path, "utf8")).includes(LEGACY_MARK))
|
|
670
1309
|
found.push(rel);
|
|
671
1310
|
} catch {}
|
|
672
1311
|
}
|
|
@@ -674,17 +1313,35 @@ async function legacyArtifacts(root) {
|
|
|
674
1313
|
}
|
|
675
1314
|
async function skillInstalledIn(root) {
|
|
676
1315
|
for (const target of TARGETS) {
|
|
677
|
-
if (await exists(
|
|
1316
|
+
if (await exists(join3(target.projectDir(root), "SKILL.md")))
|
|
678
1317
|
return true;
|
|
679
1318
|
}
|
|
680
1319
|
return (await legacyArtifacts(root)).length > 0;
|
|
681
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
|
+
}
|
|
682
1339
|
async function writeTarget(target, dir) {
|
|
683
1340
|
const results = [];
|
|
684
1341
|
for (const [rel, content] of Object.entries(skillFiles())) {
|
|
685
|
-
const path =
|
|
1342
|
+
const path = join3(dir, rel);
|
|
686
1343
|
const had = await exists(path);
|
|
687
|
-
if (had && await
|
|
1344
|
+
if (had && await readFile3(path, "utf8") === content) {
|
|
688
1345
|
results.push({ target, path, status: "unchanged" });
|
|
689
1346
|
continue;
|
|
690
1347
|
}
|
|
@@ -700,12 +1357,23 @@ async function buildPlan(root, env, global) {
|
|
|
700
1357
|
dir: global ? target.globalDir(env) : target.projectDir(root)
|
|
701
1358
|
}));
|
|
702
1359
|
}
|
|
703
|
-
async function installSkill(args,
|
|
1360
|
+
async function installSkill(args, callerIo) {
|
|
1361
|
+
const json = Boolean(args.json);
|
|
1362
|
+
const io = json ? { ...callerIo, err: () => {}, out: () => {} } : callerIo;
|
|
1363
|
+
const emit = (value) => callerIo.out(JSON.stringify(value));
|
|
704
1364
|
const env = io.env ?? process.env;
|
|
705
1365
|
const root = args.cwd ?? process.cwd();
|
|
706
1366
|
const global = Boolean(args.global);
|
|
707
1367
|
const plan = await buildPlan(root, env, global);
|
|
708
1368
|
if (args.list) {
|
|
1369
|
+
if (json) {
|
|
1370
|
+
emit({
|
|
1371
|
+
ok: true,
|
|
1372
|
+
global,
|
|
1373
|
+
targets: plan.map((e) => ({ id: e.target.id, detail: e.target.detail, dir: e.dir }))
|
|
1374
|
+
});
|
|
1375
|
+
return 0;
|
|
1376
|
+
}
|
|
709
1377
|
io.err(global ? "flypod skill targets (global):" : "flypod skill targets (this project):");
|
|
710
1378
|
io.err("");
|
|
711
1379
|
for (const e of plan)
|
|
@@ -717,14 +1385,14 @@ async function installSkill(args, io) {
|
|
|
717
1385
|
let chosen;
|
|
718
1386
|
if (args.targets && args.targets.length > 0) {
|
|
719
1387
|
const known = new Set(plan.map((e) => e.target.id));
|
|
720
|
-
const unknown = args.targets.filter((
|
|
1388
|
+
const unknown = args.targets.filter((id2) => !known.has(id2));
|
|
721
1389
|
if (unknown.length > 0) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
1390
|
+
return fail("usage", `flypod install skill: unknown target(s): ${unknown.join(", ")}`, { json }, callerIo, {
|
|
1391
|
+
fix: `Known targets: ${TARGETS.map((t) => t.id).join(", ")}.`
|
|
1392
|
+
});
|
|
725
1393
|
}
|
|
726
1394
|
chosen = args.targets;
|
|
727
|
-
} else if (args.picker && !args.all) {
|
|
1395
|
+
} else if (args.picker && !args.all && !json) {
|
|
728
1396
|
const picked = await args.picker(plan);
|
|
729
1397
|
if (picked === null) {
|
|
730
1398
|
io.err("Cancelled. Nothing written.");
|
|
@@ -736,14 +1404,24 @@ async function installSkill(args, io) {
|
|
|
736
1404
|
}
|
|
737
1405
|
const selected = plan.filter((e) => chosen.includes(e.target.id));
|
|
738
1406
|
if (selected.length === 0) {
|
|
1407
|
+
if (json)
|
|
1408
|
+
emit({ ok: true, targets: [], files: [] });
|
|
739
1409
|
io.err("No targets selected. Nothing written.");
|
|
740
1410
|
return 0;
|
|
741
1411
|
}
|
|
742
1412
|
if (args.dryRun) {
|
|
1413
|
+
if (json) {
|
|
1414
|
+
emit({
|
|
1415
|
+
ok: true,
|
|
1416
|
+
dry_run: true,
|
|
1417
|
+
files: selected.flatMap((e) => Object.keys(skillFiles()).map((rel) => join3(e.dir, rel)))
|
|
1418
|
+
});
|
|
1419
|
+
return 0;
|
|
1420
|
+
}
|
|
743
1421
|
io.err("Would write:");
|
|
744
1422
|
for (const e of selected) {
|
|
745
1423
|
for (const rel of Object.keys(skillFiles()))
|
|
746
|
-
io.out(
|
|
1424
|
+
io.out(join3(e.dir, rel));
|
|
747
1425
|
}
|
|
748
1426
|
return 0;
|
|
749
1427
|
}
|
|
@@ -752,8 +1430,7 @@ async function installSkill(args, io) {
|
|
|
752
1430
|
try {
|
|
753
1431
|
results.push(...await writeTarget(e.target, e.dir));
|
|
754
1432
|
} catch (error) {
|
|
755
|
-
|
|
756
|
-
return 1;
|
|
1433
|
+
return fail("unexpected", `Failed to write ${e.dir}: ${error.message}`, { json }, callerIo);
|
|
757
1434
|
}
|
|
758
1435
|
}
|
|
759
1436
|
for (const e of selected) {
|
|
@@ -766,27 +1443,42 @@ async function installSkill(args, io) {
|
|
|
766
1443
|
const changed = results.filter((r) => r.status !== "unchanged").length;
|
|
767
1444
|
io.err("");
|
|
768
1445
|
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.");
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
1446
|
+
const legacy = global ? [] : await legacyArtifacts(root);
|
|
1447
|
+
if (json) {
|
|
1448
|
+
emit({
|
|
1449
|
+
ok: true,
|
|
1450
|
+
targets: selected.map((e) => ({
|
|
1451
|
+
id: e.target.id,
|
|
1452
|
+
dir: e.dir,
|
|
1453
|
+
changed: results.some((r) => r.target.id === e.target.id && r.status !== "unchanged")
|
|
1454
|
+
})),
|
|
1455
|
+
files: results.map((r) => ({ path: r.path, status: r.status })),
|
|
1456
|
+
legacy
|
|
1457
|
+
});
|
|
1458
|
+
return 0;
|
|
1459
|
+
}
|
|
1460
|
+
if (legacy.length > 0) {
|
|
1461
|
+
io.err("");
|
|
1462
|
+
io.err("These older flypod instruction files are still in the project:");
|
|
1463
|
+
for (const rel of legacy)
|
|
1464
|
+
io.err(` ${rel}`);
|
|
1465
|
+
io.err("They now duplicate the skill, and their content is out of date.");
|
|
1466
|
+
io.err("Removing the flypod parts is safe — the skill above replaces them.");
|
|
779
1467
|
}
|
|
780
1468
|
return 0;
|
|
781
1469
|
}
|
|
782
1470
|
|
|
783
1471
|
// src/cli/source.ts
|
|
784
|
-
async function resolveCliSource(env, cwd) {
|
|
1472
|
+
async function resolveCliSource(env, cwd, opts = {}) {
|
|
785
1473
|
const explicit = env.FLYPOD_SOURCE;
|
|
786
1474
|
if (explicit)
|
|
787
1475
|
return coerceSource(explicit);
|
|
788
1476
|
try {
|
|
789
|
-
|
|
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";
|
|
790
1482
|
} catch {
|
|
791
1483
|
return "cli";
|
|
792
1484
|
}
|
|
@@ -800,7 +1492,7 @@ function resolveCredentials(env, session, overrides) {
|
|
|
800
1492
|
const baseUrl = overrides?.baseUrl ?? session?.base_url ?? env.DEPLOY_URL ?? "https://flypod.dev";
|
|
801
1493
|
return { token, baseUrl };
|
|
802
1494
|
}
|
|
803
|
-
function buildClient(token, baseUrl, fetchImpl, source = "library") {
|
|
1495
|
+
function buildClient(token, baseUrl, fetchImpl, source = "library", extraHeaders = {}) {
|
|
804
1496
|
async function request(method, path, init = {}) {
|
|
805
1497
|
const url = new URL(path, baseUrl);
|
|
806
1498
|
if (init.query) {
|
|
@@ -809,7 +1501,11 @@ function buildClient(token, baseUrl, fetchImpl, source = "library") {
|
|
|
809
1501
|
url.searchParams.set(key, value);
|
|
810
1502
|
}
|
|
811
1503
|
}
|
|
812
|
-
const headers = {
|
|
1504
|
+
const headers = {
|
|
1505
|
+
...extraHeaders,
|
|
1506
|
+
...init.headers,
|
|
1507
|
+
[SOURCE_HEADER]: source
|
|
1508
|
+
};
|
|
813
1509
|
if (token)
|
|
814
1510
|
headers.authorization = `Bearer ${token}`;
|
|
815
1511
|
if (init.json !== undefined)
|
|
@@ -836,7 +1532,7 @@ function buildClient(token, baseUrl, fetchImpl, source = "library") {
|
|
|
836
1532
|
claimSite: (siteId, claimToken) => request("POST", `/sites/${siteId}/claim`, { json: { claim_token: claimToken } }),
|
|
837
1533
|
bulkAttach: (sites) => request("POST", "/account/bulk-attach", { json: { sites } }),
|
|
838
1534
|
getSite: (siteId) => request("GET", `/sites/${siteId}`),
|
|
839
|
-
createSite: (zip) => request("POST", "/sites", { zip }),
|
|
1535
|
+
createSite: (zip, opts) => request("POST", "/sites", { zip, headers: opts?.relink ? { [RELINK_HEADER]: "1" } : {} }),
|
|
840
1536
|
redeploy: (siteId, zip) => request("POST", `/sites/${siteId}/deploys`, { zip }),
|
|
841
1537
|
rollback: (siteId, versionId) => request("POST", `/sites/${siteId}/rollback`, { json: { version_id: versionId } }),
|
|
842
1538
|
setTimeline: (siteId, enabled) => request("POST", `/sites/${siteId}/timeline`, { json: { enabled } }),
|
|
@@ -853,7 +1549,8 @@ async function createClient(opts) {
|
|
|
853
1549
|
const session = await loadSession(env);
|
|
854
1550
|
const { token, baseUrl } = resolveCredentials(env, session, opts.overrides);
|
|
855
1551
|
const source = await resolveCliSource(env, opts.cwd ?? process.cwd());
|
|
856
|
-
|
|
1552
|
+
const identity = await identityHeaders(env).catch(() => ({}));
|
|
1553
|
+
return buildClient(token, baseUrl, fetchImpl, source, identity);
|
|
857
1554
|
}
|
|
858
1555
|
|
|
859
1556
|
// ../../node_modules/.bun/fflate@0.8.3/node_modules/fflate/esm/index.mjs
|
|
@@ -1514,19 +2211,81 @@ var BUILD_DIR_CANDIDATES = [
|
|
|
1514
2211
|
"public",
|
|
1515
2212
|
"_site"
|
|
1516
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
|
+
}
|
|
1517
2272
|
async function resolveDeployDir(opts = {}) {
|
|
1518
2273
|
if (opts.explicit)
|
|
1519
2274
|
return opts.explicit;
|
|
1520
2275
|
const cwd = opts.cwd ?? process.cwd();
|
|
1521
2276
|
for (const candidate of BUILD_DIR_CANDIDATES) {
|
|
1522
|
-
const dir =
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
2277
|
+
const dir = join4(cwd, candidate);
|
|
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;
|
|
1529
2286
|
}
|
|
2287
|
+
if (await deployableAsIs(cwd))
|
|
2288
|
+
return cwd;
|
|
1530
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\`.`);
|
|
1531
2290
|
}
|
|
1532
2291
|
var DEFAULT_IGNORES = [
|
|
@@ -1576,10 +2335,10 @@ function compileRule(line, source) {
|
|
|
1576
2335
|
const re = new RegExp(anchored ? `^${body}$` : `(?:^|/)${body}$`);
|
|
1577
2336
|
return { re, negate, dirOnly, source };
|
|
1578
2337
|
}
|
|
1579
|
-
function ignoredBy(rules, rel,
|
|
2338
|
+
function ignoredBy(rules, rel, isDir2) {
|
|
1580
2339
|
let verdict = null;
|
|
1581
2340
|
for (const rule of rules) {
|
|
1582
|
-
if (rule.dirOnly && !
|
|
2341
|
+
if (rule.dirOnly && !isDir2)
|
|
1583
2342
|
continue;
|
|
1584
2343
|
if (rule.re.test(rel))
|
|
1585
2344
|
verdict = rule.negate ? null : rule.source;
|
|
@@ -1590,11 +2349,11 @@ async function collectFiles(path) {
|
|
|
1590
2349
|
const info = await stat2(path);
|
|
1591
2350
|
if (info.isFile()) {
|
|
1592
2351
|
const name = path.split("/").pop() ?? "index.html";
|
|
1593
|
-
return { files: { [name]: await
|
|
2352
|
+
return { files: { [name]: await readFile4(path) }, skipped: [] };
|
|
1594
2353
|
}
|
|
1595
2354
|
const rules = DEFAULT_IGNORES.map((p) => compileRule(p, "default"));
|
|
1596
2355
|
try {
|
|
1597
|
-
const text = await
|
|
2356
|
+
const text = await readFile4(join4(path, IGNORE_FILE), "utf8");
|
|
1598
2357
|
for (const line of text.split(/\r?\n/)) {
|
|
1599
2358
|
const rule = compileRule(line, "flypodignore");
|
|
1600
2359
|
if (rule)
|
|
@@ -1607,28 +2366,28 @@ async function collectFiles(path) {
|
|
|
1607
2366
|
const active = new Set([root]);
|
|
1608
2367
|
async function walk(current, currentReal) {
|
|
1609
2368
|
for (const entry of await readdir(current, { withFileTypes: true })) {
|
|
1610
|
-
const full =
|
|
2369
|
+
const full = join4(current, entry.name);
|
|
1611
2370
|
const rel = relative(path, full).split("\\").join("/");
|
|
1612
2371
|
if (rel === IGNORE_FILE)
|
|
1613
2372
|
continue;
|
|
1614
|
-
let
|
|
2373
|
+
let isDir2 = entry.isDirectory();
|
|
1615
2374
|
let real;
|
|
1616
2375
|
if (entry.isSymbolicLink()) {
|
|
1617
2376
|
try {
|
|
1618
2377
|
real = await realpath(full);
|
|
1619
|
-
|
|
2378
|
+
isDir2 = (await stat2(real)).isDirectory();
|
|
1620
2379
|
} catch {
|
|
1621
2380
|
skipped.push({ path: rel, reason: "broken_symlink" });
|
|
1622
2381
|
continue;
|
|
1623
2382
|
}
|
|
1624
2383
|
}
|
|
1625
|
-
const reason = ignoredBy(rules, rel,
|
|
2384
|
+
const reason = ignoredBy(rules, rel, isDir2);
|
|
1626
2385
|
if (reason) {
|
|
1627
|
-
skipped.push({ path:
|
|
2386
|
+
skipped.push({ path: isDir2 ? `${rel}/` : rel, reason });
|
|
1628
2387
|
continue;
|
|
1629
2388
|
}
|
|
1630
|
-
if (
|
|
1631
|
-
const childReal = real ??
|
|
2389
|
+
if (isDir2) {
|
|
2390
|
+
const childReal = real ?? join4(currentReal, entry.name);
|
|
1632
2391
|
if (real !== undefined) {
|
|
1633
2392
|
const inside = real === root || real.startsWith(`${root}${sep}`);
|
|
1634
2393
|
if (!inside) {
|
|
@@ -1644,7 +2403,7 @@ async function collectFiles(path) {
|
|
|
1644
2403
|
await walk(full, childReal);
|
|
1645
2404
|
active.delete(childReal);
|
|
1646
2405
|
} else {
|
|
1647
|
-
files[rel] = await
|
|
2406
|
+
files[rel] = await readFile4(full);
|
|
1648
2407
|
}
|
|
1649
2408
|
}
|
|
1650
2409
|
}
|
|
@@ -1699,4 +2458,4 @@ class DeployError extends Error {
|
|
|
1699
2458
|
}
|
|
1700
2459
|
}
|
|
1701
2460
|
|
|
1702
|
-
export { projectsFilePath, atomicWriteFile, saveSession, clearSession, 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 };
|