flypod 0.4.0 → 0.5.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 +3 -35
- package/dist/bin/deploy.js +60 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npx flypod ./dist
|
|
|
11
11
|
|
|
12
12
|
- **No auth to deploy** — POST a zip, receive a URL + one-time tokens
|
|
13
13
|
- **Ephemeral by default** — anonymous deploys expire in 14 days
|
|
14
|
-
- **Optional accounts** — sign in once at [`flypod.dev/account`](https://flypod.dev/account) and every site you've deployed from that browser becomes permanently yours. CLI keys (`fk_...`) drop anonymous expiry too.
|
|
14
|
+
- **Optional accounts** — sign in once at [`flypod.dev/account`](https://flypod.dev/account) and every site you've deployed from that browser becomes permanently yours. CLI keys (`fk_...`) drop anonymous expiry too.
|
|
15
15
|
- **Rollback built-in** — every deploy is versioned; roll back with a single call
|
|
16
16
|
- **Render loop** — optional headless screenshot + console capture on every deploy
|
|
17
17
|
|
|
@@ -235,7 +235,7 @@ console.log(result.manage_token); // one-time — save to redeploy / rollback /
|
|
|
235
235
|
| Option | Type | Default | Description |
|
|
236
236
|
|--------|------|---------|-------------|
|
|
237
237
|
| `files` | `Record<string, Uint8Array>` | — | File path → bytes map |
|
|
238
|
-
| `baseUrl` | `string` | `https://flypod.dev` | Override
|
|
238
|
+
| `baseUrl` | `string` | `https://flypod.dev` | Override the deploy server |
|
|
239
239
|
| `handle` | `(req) => Promise<Response>` | `fetch` | Injectable transport (used in tests) |
|
|
240
240
|
|
|
241
241
|
Returns a `DeployResult`:
|
|
@@ -311,39 +311,7 @@ For agents and CI, set `FLYPOD_API_KEY=fk_…` and the CLI sends it as
|
|
|
311
311
|
GitHub Actions, in your own code.
|
|
312
312
|
|
|
313
313
|
Login on the web uses **magic link** or **email + password** — pick the one you
|
|
314
|
-
prefer; both land you in the same account.
|
|
315
|
-
`anonymous` + `magicLink` + `apiKey` plugins plus core email/password on
|
|
316
|
-
Cloudflare Workers + Turso, with `onLinkAccount` powering bulk claim) is
|
|
317
|
-
documented at [docs/identity.md](https://github.com/sdserranog/flypod/blob/main/docs/identity.md).
|
|
318
|
-
|
|
319
|
-
---
|
|
320
|
-
|
|
321
|
-
## Self-hosting
|
|
322
|
-
|
|
323
|
-
```ts
|
|
324
|
-
import { createApp } from "flypod/server";
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
The server runs on [Cloudflare Workers](https://workers.cloudflare.com) (free tier). Deploy your own instance:
|
|
328
|
-
|
|
329
|
-
```sh
|
|
330
|
-
git clone https://github.com/sdserranog/flypod
|
|
331
|
-
cd flypod
|
|
332
|
-
bunx wrangler deploy
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
Environment variables / secrets:
|
|
336
|
-
|
|
337
|
-
| Variable | Default | Description |
|
|
338
|
-
|----------|---------|-------------|
|
|
339
|
-
| `BASE_HOST` | `flypod.dev` | Wildcard subdomain root |
|
|
340
|
-
| `PUBLIC_SCHEME` | `https` | `http` or `https` |
|
|
341
|
-
| `LIBSQL_URL` | — | Turso/libSQL connection URL |
|
|
342
|
-
| `LIBSQL_AUTH_TOKEN` | — | Turso auth token |
|
|
343
|
-
| `SAFE_BROWSING_KEY` | — | Enables Google Safe Browsing link scan |
|
|
344
|
-
| `BETTER_AUTH_SECRET` | — | _v0.2:_ Better Auth signing secret (32+ random bytes) |
|
|
345
|
-
| `RESEND_API_KEY` | — | _v0.2:_ Resend API key for magic-link email delivery |
|
|
346
|
-
| `RESEND_FROM` | `notifications@flypod.dev` | _v0.2:_ verified sender address for magic links |
|
|
314
|
+
prefer; both land you in the same account.
|
|
347
315
|
|
|
348
316
|
---
|
|
349
317
|
|
package/dist/bin/deploy.js
CHANGED
|
@@ -154,28 +154,61 @@ async function clearSession(env) {
|
|
|
154
154
|
function baseUrlFrom(env = process.env) {
|
|
155
155
|
return env.DEPLOY_URL ?? "https://flypod.dev";
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
|
|
157
|
+
async function openBrowser(url) {
|
|
158
|
+
const platform2 = process.platform;
|
|
159
|
+
const cmd = platform2 === "darwin" ? "open" : platform2 === "win32" ? "start" : "xdg-open";
|
|
160
|
+
await Bun.$`${cmd} ${url}`.quiet().nothrow();
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
var POLL_MAX_ATTEMPTS = 120;
|
|
163
|
+
async function login(_args, io) {
|
|
161
164
|
const env = io.env ?? process.env;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
io.err(
|
|
168
|
-
return
|
|
165
|
+
const baseUrl = baseUrlFrom(env);
|
|
166
|
+
const fetchImpl = io.fetch ?? fetch;
|
|
167
|
+
const openUrl = io.openUrl ?? openBrowser;
|
|
168
|
+
const startRes = await fetchImpl(`${baseUrl}/auth/device`, { method: "POST" });
|
|
169
|
+
if (!startRes.ok) {
|
|
170
|
+
io.err(`flypod login: server returned ${startRes.status}. Is the server running?`);
|
|
171
|
+
return 1;
|
|
169
172
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
const { device_code, user_code, verification_uri, interval } = await startRes.json();
|
|
174
|
+
const confirmUrl = `${verification_uri}?code=${user_code}`;
|
|
175
|
+
io.err("");
|
|
176
|
+
io.err(` Opening browser to complete sign-in...`);
|
|
177
|
+
io.err(` ${confirmUrl}`);
|
|
178
|
+
io.err("");
|
|
179
|
+
io.err(` Confirmation code: ${user_code}`);
|
|
180
|
+
io.err("");
|
|
181
|
+
await openUrl(confirmUrl);
|
|
182
|
+
const pollMs = (interval ?? 5) * 1000;
|
|
183
|
+
for (let attempt = 0;attempt < POLL_MAX_ATTEMPTS; attempt++) {
|
|
184
|
+
await new Promise((r) => setTimeout(r, attempt === 0 ? pollMs : pollMs));
|
|
185
|
+
const pollRes = await fetchImpl(`${baseUrl}/auth/device/token`, {
|
|
186
|
+
method: "POST",
|
|
187
|
+
headers: { "content-type": "application/json" },
|
|
188
|
+
body: JSON.stringify({ device_code })
|
|
189
|
+
});
|
|
190
|
+
if (pollRes.status === 202)
|
|
191
|
+
continue;
|
|
192
|
+
if (!pollRes.ok) {
|
|
193
|
+
const body = await pollRes.json().catch(() => ({}));
|
|
194
|
+
if (body.error === "denied") {
|
|
195
|
+
io.err("Authorization denied in browser.");
|
|
196
|
+
return 1;
|
|
197
|
+
}
|
|
198
|
+
if (body.error === "expired") {
|
|
199
|
+
io.err("Code expired. Run `flypod login` to try again.");
|
|
200
|
+
return 1;
|
|
201
|
+
}
|
|
202
|
+
io.err(`flypod login: unexpected error ${pollRes.status}.`);
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
const { api_key } = await pollRes.json();
|
|
206
|
+
const path = await saveSession({ api_key, base_url: baseUrl, created_at: Date.now() }, env);
|
|
207
|
+
io.err(`Logged in. Session saved to ${path}`);
|
|
208
|
+
return 0;
|
|
173
209
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
io.err(`Saved your key to ${path}`);
|
|
177
|
-
io.err(`Now using ${baseUrl} for every flypod command.`);
|
|
178
|
-
return 0;
|
|
210
|
+
io.err("Timed out waiting for browser authorization. Run `flypod login` to try again.");
|
|
211
|
+
return 1;
|
|
179
212
|
}
|
|
180
213
|
async function logout(_args, io) {
|
|
181
214
|
const env = io.env ?? process.env;
|
|
@@ -190,7 +223,7 @@ async function list(_args, io) {
|
|
|
190
223
|
const env = io.env ?? process.env;
|
|
191
224
|
const session = await loadSession(env);
|
|
192
225
|
if (!session) {
|
|
193
|
-
io.err("Not signed in. Run `flypod login
|
|
226
|
+
io.err("Not signed in. Run `flypod login` first.");
|
|
194
227
|
return 1;
|
|
195
228
|
}
|
|
196
229
|
const fetchImpl = io.fetch ?? fetch;
|
|
@@ -215,7 +248,7 @@ async function claim(args, io) {
|
|
|
215
248
|
const env = io.env ?? process.env;
|
|
216
249
|
const session = await loadSession(env);
|
|
217
250
|
if (!session) {
|
|
218
|
-
io.err("Not signed in. Run `flypod login
|
|
251
|
+
io.err("Not signed in. Run `flypod login` first.");
|
|
219
252
|
return 1;
|
|
220
253
|
}
|
|
221
254
|
if (!args.site_id || !args.token) {
|
|
@@ -244,7 +277,7 @@ async function keysCreate(_args, io) {
|
|
|
244
277
|
const env = io.env ?? process.env;
|
|
245
278
|
const session = await loadSession(env);
|
|
246
279
|
if (!session) {
|
|
247
|
-
io.err("Not signed in. Run `flypod login
|
|
280
|
+
io.err("Not signed in. Run `flypod login` first.");
|
|
248
281
|
return 1;
|
|
249
282
|
}
|
|
250
283
|
const fetchImpl = io.fetch ?? fetch;
|
|
@@ -285,7 +318,7 @@ async function healGone(target, io, env) {
|
|
|
285
318
|
io.err(`Site ${target.site_id} is gone (expired or deleted). Run 'flypod' to create a new one.`);
|
|
286
319
|
}
|
|
287
320
|
function unauthorized(target, io) {
|
|
288
|
-
io.err(`Unauthorized for ${target.site_id}. Run
|
|
321
|
+
io.err(`Unauthorized for ${target.site_id}. Run \`flypod login\` or pass --token <manage_token>.`);
|
|
289
322
|
}
|
|
290
323
|
async function fetchSite(target, args, io, env) {
|
|
291
324
|
const { baseUrl, auth } = await requestContext(target, args, env);
|
|
@@ -352,7 +385,6 @@ async function update(args, io) {
|
|
|
352
385
|
return 1;
|
|
353
386
|
}
|
|
354
387
|
const body = await res.json();
|
|
355
|
-
const noop = target.rec?.version_id !== undefined && body.version_id === target.rec.version_id;
|
|
356
388
|
await touchLink(target, body.version_id, env);
|
|
357
389
|
if (args.json) {
|
|
358
390
|
io.out(JSON.stringify({
|
|
@@ -363,7 +395,7 @@ async function update(args, io) {
|
|
|
363
395
|
}));
|
|
364
396
|
return 0;
|
|
365
397
|
}
|
|
366
|
-
io.err(
|
|
398
|
+
io.err(`→ version ${body.version_id} is now live`);
|
|
367
399
|
io.out(body.url);
|
|
368
400
|
return 0;
|
|
369
401
|
}
|
|
@@ -1068,18 +1100,6 @@ Run \`flypod --help\` for usage.
|
|
|
1068
1100
|
}
|
|
1069
1101
|
return out;
|
|
1070
1102
|
}
|
|
1071
|
-
function flag(argv, name) {
|
|
1072
|
-
const long = `--${name}`;
|
|
1073
|
-
const equals = `${long}=`;
|
|
1074
|
-
for (let i = 0;i < argv.length; i++) {
|
|
1075
|
-
const a = argv[i];
|
|
1076
|
-
if (a === long)
|
|
1077
|
-
return argv[i + 1];
|
|
1078
|
-
if (a.startsWith(equals))
|
|
1079
|
-
return a.slice(equals.length);
|
|
1080
|
-
}
|
|
1081
|
-
return;
|
|
1082
|
-
}
|
|
1083
1103
|
function parseSub(argv) {
|
|
1084
1104
|
const positionals = [];
|
|
1085
1105
|
let site;
|
|
@@ -1130,7 +1150,7 @@ async function runSubcommand(name, argv) {
|
|
|
1130
1150
|
return forget({ site }, io);
|
|
1131
1151
|
}
|
|
1132
1152
|
case "login":
|
|
1133
|
-
return login({
|
|
1153
|
+
return login({}, io);
|
|
1134
1154
|
case "logout":
|
|
1135
1155
|
return logout({}, io);
|
|
1136
1156
|
case "list":
|
|
@@ -1182,10 +1202,10 @@ async function runInstall(argv, io) {
|
|
|
1182
1202
|
io.err("Run `flypod install skill --list` to see available targets and flags.");
|
|
1183
1203
|
return 2;
|
|
1184
1204
|
}
|
|
1185
|
-
const has = (
|
|
1205
|
+
const has = (flag) => argv.includes(flag);
|
|
1186
1206
|
const targets = [];
|
|
1187
|
-
for (const [
|
|
1188
|
-
if (has(
|
|
1207
|
+
for (const [flag, id] of Object.entries(TARGET_FLAGS)) {
|
|
1208
|
+
if (has(flag) && !targets.includes(id))
|
|
1189
1209
|
targets.push(id);
|
|
1190
1210
|
}
|
|
1191
1211
|
const all = has("--all");
|