flypod 0.5.0 → 0.5.1
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/dist/bin/deploy.js +266 -56
- package/package.json +1 -1
package/dist/bin/deploy.js
CHANGED
|
@@ -154,17 +154,143 @@ async function clearSession(env) {
|
|
|
154
154
|
function baseUrlFrom(env = process.env) {
|
|
155
155
|
return env.DEPLOY_URL ?? "https://flypod.dev";
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
|
|
157
|
+
function siteUrlFrom(site_id, baseUrl) {
|
|
158
|
+
const host = new URL(baseUrl).host;
|
|
159
|
+
const scheme = new URL(baseUrl).protocol.replace(":", "");
|
|
160
|
+
return `${scheme}://${site_id}.${host}`;
|
|
161
|
+
}
|
|
162
|
+
var SUBCOMMAND_HELP = {
|
|
163
|
+
update: `flypod update [path] [flags]
|
|
164
|
+
|
|
165
|
+
Ship a new version of the site linked to this folder.
|
|
166
|
+
|
|
167
|
+
flypod update Re-deploy this folder as a new version.
|
|
168
|
+
flypod update ./dist Same, with an explicit path.
|
|
169
|
+
flypod update --site <id> Update any site by id (no folder memory needed).
|
|
170
|
+
flypod update --token <tok> Use a manage_token (anonymous sites).
|
|
171
|
+
|
|
172
|
+
Flags:
|
|
173
|
+
--site <id> Target a site by id instead of the linked folder.
|
|
174
|
+
--token <tok> Authorize with a manage_token.
|
|
175
|
+
--json Emit JSON on stdout (for agents/scripts).
|
|
176
|
+
-q, --quiet Minimal output.
|
|
177
|
+
-h, --help Show this help.`,
|
|
178
|
+
versions: `flypod versions [flags]
|
|
179
|
+
|
|
180
|
+
List every version of the site linked to this folder.
|
|
181
|
+
|
|
182
|
+
flypod versions Show version history for the linked site.
|
|
183
|
+
flypod versions --site <id> Show versions for a specific site.
|
|
184
|
+
|
|
185
|
+
Flags:
|
|
186
|
+
--site <id> Target a site by id.
|
|
187
|
+
--token <tok> Authorize with a manage_token.
|
|
188
|
+
--json Emit JSON on stdout.
|
|
189
|
+
-h, --help Show this help.`,
|
|
190
|
+
rollback: `flypod rollback [version] [flags]
|
|
191
|
+
|
|
192
|
+
Roll the site back to a previous version.
|
|
193
|
+
|
|
194
|
+
flypod rollback Roll back to the immediately previous version.
|
|
195
|
+
flypod rollback <version> Roll back to a specific version id (or prefix).
|
|
196
|
+
flypod rollback --site <id> Roll back a site by id.
|
|
197
|
+
|
|
198
|
+
Flags:
|
|
199
|
+
--site <id> Target a site by id.
|
|
200
|
+
--token <tok> Authorize with a manage_token.
|
|
201
|
+
--json Emit JSON on stdout.
|
|
202
|
+
-h, --help Show this help.`,
|
|
203
|
+
forget: `flypod forget [flags]
|
|
204
|
+
|
|
205
|
+
Drop this folder's remembered site link.
|
|
206
|
+
|
|
207
|
+
flypod forget Forget this folder's link.
|
|
208
|
+
flypod forget --site <id> Forget all folders linked to a site id.
|
|
209
|
+
|
|
210
|
+
Flags:
|
|
211
|
+
--site <id> Forget all links to this site.
|
|
212
|
+
-h, --help Show this help.`,
|
|
213
|
+
login: `flypod login [flags]
|
|
214
|
+
|
|
215
|
+
Authenticate with flypod.
|
|
216
|
+
|
|
217
|
+
flypod login Start the device-flow sign-in (open a browser).
|
|
218
|
+
flypod login --key fk_... Save an API key directly (for agents/CI).
|
|
219
|
+
|
|
220
|
+
Flags:
|
|
221
|
+
--key fk_... Save this API key (minted at flypod.dev/account).
|
|
222
|
+
-h, --help Show this help.`,
|
|
223
|
+
logout: `flypod logout
|
|
224
|
+
|
|
225
|
+
Forget the saved API key. Doesn't affect the server.`,
|
|
226
|
+
list: `flypod list
|
|
227
|
+
|
|
228
|
+
List sites you own (requires login or FLYPOD_API_KEY). Outputs JSON on stdout.`,
|
|
229
|
+
claim: `flypod claim <site_id> <claim_token>
|
|
230
|
+
|
|
231
|
+
Attach an anonymous deploy to your account (requires login or FLYPOD_API_KEY). Outputs JSON on stdout.`,
|
|
232
|
+
keys: `flypod keys create
|
|
233
|
+
|
|
234
|
+
Mint a new API key for agents / CI (requires login or FLYPOD_API_KEY). Outputs JSON on stdout.`,
|
|
235
|
+
install: `flypod install skill [targets] [flags]
|
|
236
|
+
|
|
237
|
+
Teach your coding agents (Claude Code, Codex, Cursor, …) how to deploy with flypod.
|
|
238
|
+
|
|
239
|
+
flypod install skill Interactive picker (TTY).
|
|
240
|
+
flypod install skill --claude Write Claude Code skill.
|
|
241
|
+
flypod install skill --all Write every supported target.
|
|
242
|
+
flypod install skill --global Write to home directory (for AGENTS.md, Claude, Gemini).
|
|
243
|
+
flypod install skill --list Print detected targets without writing.
|
|
244
|
+
flypod install skill --dry-run Show what would be written.
|
|
245
|
+
flypod install skill --yes Skip interactive confirmation.
|
|
246
|
+
|
|
247
|
+
Targets:
|
|
248
|
+
--agents AGENTS.md (Codex, Cursor, Copilot, Gemini, Windsurf, +more)
|
|
249
|
+
--claude Claude Code (.claude/skills/flypod/SKILL.md)
|
|
250
|
+
--cursor Cursor (.cursor/rules/flypod.mdc)
|
|
251
|
+
--copilot GitHub Copilot (.github/copilot-instructions.md)
|
|
252
|
+
--windsurf Windsurf (.windsurf/rules/flypod.md)
|
|
253
|
+
--cline Cline (.clinerules/flypod.md)
|
|
254
|
+
--roo Roo Code (.roo/rules/flypod.md)
|
|
255
|
+
--gemini Gemini CLI (GEMINI.md)
|
|
256
|
+
|
|
257
|
+
Flags:
|
|
258
|
+
--all Write every supported target.
|
|
259
|
+
--global Write to home directory instead of project root.
|
|
260
|
+
--list Print detected targets without writing.
|
|
261
|
+
--dry-run Show what would be written (alias: --print).
|
|
262
|
+
--yes, -y Skip the interactive picker.
|
|
263
|
+
-h, --help Show this help.`
|
|
264
|
+
};
|
|
265
|
+
function showSubHelp(name, io) {
|
|
266
|
+
const help = SUBCOMMAND_HELP[name];
|
|
267
|
+
if (help)
|
|
268
|
+
io.err(help);
|
|
269
|
+
else
|
|
270
|
+
io.err(`No help available for "${name}". Run \`flypod --help\` for usage.`);
|
|
271
|
+
}
|
|
272
|
+
function failJson(error, io) {
|
|
273
|
+
io.out(JSON.stringify({ ok: false, error }));
|
|
274
|
+
return 1;
|
|
161
275
|
}
|
|
162
276
|
var POLL_MAX_ATTEMPTS = 120;
|
|
163
|
-
async function login(
|
|
277
|
+
async function login(args, io) {
|
|
278
|
+
if (args.help) {
|
|
279
|
+
showSubHelp("login", io);
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
164
282
|
const env = io.env ?? process.env;
|
|
165
283
|
const baseUrl = baseUrlFrom(env);
|
|
284
|
+
if (args.key) {
|
|
285
|
+
if (!args.key.startsWith("fk_") || args.key.length < 20) {
|
|
286
|
+
io.err("Invalid key. Expected fk_ followed by at least 16 characters.");
|
|
287
|
+
return 2;
|
|
288
|
+
}
|
|
289
|
+
await saveSession({ api_key: args.key, base_url: baseUrl, created_at: Date.now() }, env);
|
|
290
|
+
io.err("Logged in.");
|
|
291
|
+
return 0;
|
|
292
|
+
}
|
|
166
293
|
const fetchImpl = io.fetch ?? fetch;
|
|
167
|
-
const openUrl = io.openUrl ?? openBrowser;
|
|
168
294
|
const startRes = await fetchImpl(`${baseUrl}/auth/device`, { method: "POST" });
|
|
169
295
|
if (!startRes.ok) {
|
|
170
296
|
io.err(`flypod login: server returned ${startRes.status}. Is the server running?`);
|
|
@@ -173,15 +299,14 @@ async function login(_args, io) {
|
|
|
173
299
|
const { device_code, user_code, verification_uri, interval } = await startRes.json();
|
|
174
300
|
const confirmUrl = `${verification_uri}?code=${user_code}`;
|
|
175
301
|
io.err("");
|
|
176
|
-
io.err(`
|
|
302
|
+
io.err(` Open this URL in your browser to sign in:`);
|
|
177
303
|
io.err(` ${confirmUrl}`);
|
|
178
304
|
io.err("");
|
|
179
305
|
io.err(` Confirmation code: ${user_code}`);
|
|
180
306
|
io.err("");
|
|
181
|
-
await openUrl(confirmUrl);
|
|
182
307
|
const pollMs = (interval ?? 5) * 1000;
|
|
183
308
|
for (let attempt = 0;attempt < POLL_MAX_ATTEMPTS; attempt++) {
|
|
184
|
-
await new Promise((r) => setTimeout(r,
|
|
309
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
185
310
|
const pollRes = await fetchImpl(`${baseUrl}/auth/device/token`, {
|
|
186
311
|
method: "POST",
|
|
187
312
|
headers: { "content-type": "application/json" },
|
|
@@ -203,8 +328,8 @@ async function login(_args, io) {
|
|
|
203
328
|
return 1;
|
|
204
329
|
}
|
|
205
330
|
const { api_key } = await pollRes.json();
|
|
206
|
-
|
|
207
|
-
io.err(
|
|
331
|
+
await saveSession({ api_key, base_url: baseUrl, created_at: Date.now() }, env);
|
|
332
|
+
io.err("Logged in.");
|
|
208
333
|
return 0;
|
|
209
334
|
}
|
|
210
335
|
io.err("Timed out waiting for browser authorization. Run `flypod login` to try again.");
|
|
@@ -222,13 +347,15 @@ async function logout(_args, io) {
|
|
|
222
347
|
async function list(_args, io) {
|
|
223
348
|
const env = io.env ?? process.env;
|
|
224
349
|
const session = await loadSession(env);
|
|
225
|
-
|
|
226
|
-
|
|
350
|
+
const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
|
|
351
|
+
const baseUrl = session?.base_url ?? baseUrlFrom(env);
|
|
352
|
+
if (!apiKey) {
|
|
353
|
+
io.err("Not signed in. Run `flypod login` first or set FLYPOD_API_KEY.");
|
|
227
354
|
return 1;
|
|
228
355
|
}
|
|
229
356
|
const fetchImpl = io.fetch ?? fetch;
|
|
230
|
-
const res = await fetchImpl(`${
|
|
231
|
-
headers: { authorization: `Bearer ${
|
|
357
|
+
const res = await fetchImpl(`${baseUrl}/account/sites`, {
|
|
358
|
+
headers: { authorization: `Bearer ${apiKey}` }
|
|
232
359
|
});
|
|
233
360
|
if (!res.ok) {
|
|
234
361
|
io.err(`flypod list: server returned ${res.status}.`);
|
|
@@ -240,15 +367,16 @@ async function list(_args, io) {
|
|
|
240
367
|
io.err("No sites yet. Run `flypod` in a folder to deploy one.");
|
|
241
368
|
return 0;
|
|
242
369
|
}
|
|
243
|
-
|
|
244
|
-
io.out(`${site.site_id} ${site.url}`);
|
|
370
|
+
io.out(JSON.stringify({ ok: true, sites }));
|
|
245
371
|
return 0;
|
|
246
372
|
}
|
|
247
373
|
async function claim(args, io) {
|
|
248
374
|
const env = io.env ?? process.env;
|
|
249
375
|
const session = await loadSession(env);
|
|
250
|
-
|
|
251
|
-
|
|
376
|
+
const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
|
|
377
|
+
const baseUrl = session?.base_url ?? baseUrlFrom(env);
|
|
378
|
+
if (!apiKey) {
|
|
379
|
+
io.err("Not signed in. Run `flypod login` first or set FLYPOD_API_KEY.");
|
|
252
380
|
return 1;
|
|
253
381
|
}
|
|
254
382
|
if (!args.site_id || !args.token) {
|
|
@@ -256,11 +384,11 @@ async function claim(args, io) {
|
|
|
256
384
|
return 2;
|
|
257
385
|
}
|
|
258
386
|
const fetchImpl = io.fetch ?? fetch;
|
|
259
|
-
const res = await fetchImpl(`${
|
|
387
|
+
const res = await fetchImpl(`${baseUrl}/sites/${args.site_id}/claim`, {
|
|
260
388
|
method: "POST",
|
|
261
389
|
headers: {
|
|
262
390
|
"content-type": "application/json",
|
|
263
|
-
authorization: `Bearer ${
|
|
391
|
+
authorization: `Bearer ${apiKey}`
|
|
264
392
|
},
|
|
265
393
|
body: JSON.stringify({ claim_token: args.token })
|
|
266
394
|
});
|
|
@@ -269,28 +397,30 @@ async function claim(args, io) {
|
|
|
269
397
|
return 1;
|
|
270
398
|
}
|
|
271
399
|
const body = await res.json();
|
|
272
|
-
io.out(body.site_id);
|
|
400
|
+
io.out(JSON.stringify({ ok: true, site_id: body.site_id, owner_account_id: body.owner_account_id }));
|
|
273
401
|
io.err(`Claimed. Owned by ${body.owner_account_id}.`);
|
|
274
402
|
return 0;
|
|
275
403
|
}
|
|
276
404
|
async function keysCreate(_args, io) {
|
|
277
405
|
const env = io.env ?? process.env;
|
|
278
406
|
const session = await loadSession(env);
|
|
279
|
-
|
|
280
|
-
|
|
407
|
+
const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
|
|
408
|
+
const baseUrl = session?.base_url ?? baseUrlFrom(env);
|
|
409
|
+
if (!apiKey) {
|
|
410
|
+
io.err("Not signed in. Run `flypod login` first or set FLYPOD_API_KEY.");
|
|
281
411
|
return 1;
|
|
282
412
|
}
|
|
283
413
|
const fetchImpl = io.fetch ?? fetch;
|
|
284
|
-
const res = await fetchImpl(`${
|
|
414
|
+
const res = await fetchImpl(`${baseUrl}/account/api-keys`, {
|
|
285
415
|
method: "POST",
|
|
286
|
-
headers: { authorization: `Bearer ${
|
|
416
|
+
headers: { authorization: `Bearer ${apiKey}` }
|
|
287
417
|
});
|
|
288
418
|
if (!res.ok) {
|
|
289
419
|
io.err(`flypod keys create: server returned ${res.status}.`);
|
|
290
420
|
return 1;
|
|
291
421
|
}
|
|
292
422
|
const body = await res.json();
|
|
293
|
-
io.out(body.api_key);
|
|
423
|
+
io.out(JSON.stringify({ ok: true, api_key: body.api_key }));
|
|
294
424
|
io.err("Save this now. You will not see it again.");
|
|
295
425
|
return 0;
|
|
296
426
|
}
|
|
@@ -306,7 +436,7 @@ async function resolveTarget(args, io) {
|
|
|
306
436
|
async function requestContext(target, args, env) {
|
|
307
437
|
const session = await loadSession(env);
|
|
308
438
|
const baseUrl = target.rec?.base_url ?? session?.base_url ?? baseUrlFrom(env);
|
|
309
|
-
const auth = args.token ?? target.rec?.manage_token ?? session?.api_key;
|
|
439
|
+
const auth = args.token ?? target.rec?.manage_token ?? session?.api_key ?? env.FLYPOD_API_KEY;
|
|
310
440
|
return { baseUrl, auth };
|
|
311
441
|
}
|
|
312
442
|
function authHeaders(auth, extra = {}) {
|
|
@@ -344,10 +474,16 @@ async function touchLink(target, version_id, env) {
|
|
|
344
474
|
}
|
|
345
475
|
}
|
|
346
476
|
async function update(args, io) {
|
|
477
|
+
if (args.help) {
|
|
478
|
+
showSubHelp("update", io);
|
|
479
|
+
return 0;
|
|
480
|
+
}
|
|
347
481
|
const env = io.env ?? process.env;
|
|
348
482
|
const cwd = io.cwd ?? process.cwd();
|
|
349
483
|
const target = await resolveTarget(args, io);
|
|
350
484
|
if (!target) {
|
|
485
|
+
if (args.json)
|
|
486
|
+
return failJson(NO_SITE, io);
|
|
351
487
|
io.err(NO_SITE);
|
|
352
488
|
return 1;
|
|
353
489
|
}
|
|
@@ -355,14 +491,20 @@ async function update(args, io) {
|
|
|
355
491
|
try {
|
|
356
492
|
dir = await resolveDeployDir({ cwd, explicit: args.path });
|
|
357
493
|
} catch (e) {
|
|
358
|
-
|
|
494
|
+
const msg = e.message;
|
|
495
|
+
if (args.json)
|
|
496
|
+
return failJson(msg, io);
|
|
497
|
+
io.err(msg);
|
|
359
498
|
return 1;
|
|
360
499
|
}
|
|
361
500
|
let files;
|
|
362
501
|
try {
|
|
363
502
|
files = await collectDist(dir);
|
|
364
503
|
} catch (e) {
|
|
365
|
-
|
|
504
|
+
const msg = `Could not read ${dir}: ${e.message}`;
|
|
505
|
+
if (args.json)
|
|
506
|
+
return failJson(msg, io);
|
|
507
|
+
io.err(msg);
|
|
366
508
|
return 1;
|
|
367
509
|
}
|
|
368
510
|
const { baseUrl, auth } = await requestContext(target, args, env);
|
|
@@ -395,14 +537,24 @@ async function update(args, io) {
|
|
|
395
537
|
}));
|
|
396
538
|
return 0;
|
|
397
539
|
}
|
|
540
|
+
if (args.quiet) {
|
|
541
|
+
io.out(body.url);
|
|
542
|
+
return 0;
|
|
543
|
+
}
|
|
398
544
|
io.err(`→ version ${body.version_id} is now live`);
|
|
399
545
|
io.out(body.url);
|
|
400
546
|
return 0;
|
|
401
547
|
}
|
|
402
548
|
async function versions(args, io) {
|
|
549
|
+
if (args.help) {
|
|
550
|
+
showSubHelp("versions", io);
|
|
551
|
+
return 0;
|
|
552
|
+
}
|
|
403
553
|
const env = io.env ?? process.env;
|
|
404
554
|
const target = await resolveTarget(args, io);
|
|
405
555
|
if (!target) {
|
|
556
|
+
if (args.json)
|
|
557
|
+
return failJson(NO_SITE, io);
|
|
406
558
|
io.err(NO_SITE);
|
|
407
559
|
return 1;
|
|
408
560
|
}
|
|
@@ -420,9 +572,15 @@ async function versions(args, io) {
|
|
|
420
572
|
return 0;
|
|
421
573
|
}
|
|
422
574
|
async function rollback(args, io) {
|
|
575
|
+
if (args.help) {
|
|
576
|
+
showSubHelp("rollback", io);
|
|
577
|
+
return 0;
|
|
578
|
+
}
|
|
423
579
|
const env = io.env ?? process.env;
|
|
424
580
|
const target = await resolveTarget(args, io);
|
|
425
581
|
if (!target) {
|
|
582
|
+
if (args.json)
|
|
583
|
+
return failJson(NO_SITE, io);
|
|
426
584
|
io.err(NO_SITE);
|
|
427
585
|
return 1;
|
|
428
586
|
}
|
|
@@ -439,20 +597,32 @@ async function rollback(args, io) {
|
|
|
439
597
|
else if (prefixed.length === 1)
|
|
440
598
|
chosen = prefixed[0]?.version_id;
|
|
441
599
|
else if (prefixed.length === 0) {
|
|
442
|
-
|
|
600
|
+
const msg = `No version matches '${args.version}'.`;
|
|
601
|
+
if (args.json)
|
|
602
|
+
return failJson(msg, io);
|
|
603
|
+
io.err(msg);
|
|
443
604
|
return 1;
|
|
444
605
|
} else {
|
|
445
|
-
|
|
606
|
+
const msg = `'${args.version}' is ambiguous — it matches ${prefixed.length} versions.`;
|
|
607
|
+
if (args.json)
|
|
608
|
+
return failJson(msg, io);
|
|
609
|
+
io.err(msg);
|
|
446
610
|
return 1;
|
|
447
611
|
}
|
|
448
612
|
} else {
|
|
449
613
|
if (vers.length < 2) {
|
|
450
|
-
|
|
614
|
+
const msg = "Only one version exists — nothing to roll back to.";
|
|
615
|
+
if (args.json)
|
|
616
|
+
return failJson(msg, io);
|
|
617
|
+
io.err(msg);
|
|
451
618
|
return 1;
|
|
452
619
|
}
|
|
453
620
|
const liveIdx = vers.findIndex((v) => v.version_id === live_version_id);
|
|
454
621
|
if (liveIdx <= 0) {
|
|
455
|
-
|
|
622
|
+
const msg = "Already at the oldest version.";
|
|
623
|
+
if (args.json)
|
|
624
|
+
return failJson(msg, io);
|
|
625
|
+
io.err(msg);
|
|
456
626
|
return 1;
|
|
457
627
|
}
|
|
458
628
|
chosen = vers[liveIdx - 1]?.version_id;
|
|
@@ -466,23 +636,38 @@ async function rollback(args, io) {
|
|
|
466
636
|
});
|
|
467
637
|
if (res.status === 404) {
|
|
468
638
|
await healGone(target, io, env);
|
|
639
|
+
if (args.json)
|
|
640
|
+
return failJson(`Site ${target.site_id} not found.`, io);
|
|
469
641
|
return 1;
|
|
470
642
|
}
|
|
471
643
|
if (!res.ok) {
|
|
472
|
-
|
|
644
|
+
const msg = `flypod rollback: server returned ${res.status}.`;
|
|
645
|
+
if (args.json)
|
|
646
|
+
return failJson(msg, io);
|
|
647
|
+
io.err(msg);
|
|
473
648
|
return 1;
|
|
474
649
|
}
|
|
475
650
|
const body = await res.json();
|
|
476
651
|
await touchLink(target, body.live_version_id, env);
|
|
652
|
+
const url = target.rec?.url ?? siteUrlFrom(target.site_id, baseUrl);
|
|
477
653
|
if (args.json) {
|
|
478
|
-
io.out(JSON.stringify({
|
|
654
|
+
io.out(JSON.stringify({
|
|
655
|
+
ok: true,
|
|
656
|
+
site_id: target.site_id,
|
|
657
|
+
live_version_id: body.live_version_id,
|
|
658
|
+
url
|
|
659
|
+
}));
|
|
479
660
|
return 0;
|
|
480
661
|
}
|
|
481
662
|
io.err(`→ rolled back to ${body.live_version_id}`);
|
|
482
|
-
io.out(
|
|
663
|
+
io.out(url);
|
|
483
664
|
return 0;
|
|
484
665
|
}
|
|
485
666
|
async function forget(args, io) {
|
|
667
|
+
if (args.help) {
|
|
668
|
+
showSubHelp("forget", io);
|
|
669
|
+
return 0;
|
|
670
|
+
}
|
|
486
671
|
const env = io.env ?? process.env;
|
|
487
672
|
if (args.site) {
|
|
488
673
|
const n = await forgetSite(args.site, env);
|
|
@@ -1106,13 +1291,14 @@ function parseSub(argv) {
|
|
|
1106
1291
|
let token;
|
|
1107
1292
|
let json = false;
|
|
1108
1293
|
let quiet = false;
|
|
1294
|
+
let help = false;
|
|
1109
1295
|
for (let i = 0;i < argv.length; i++) {
|
|
1110
1296
|
const a = argv[i];
|
|
1111
|
-
if (a === "--site")
|
|
1297
|
+
if (a === "--site" && i + 1 < argv.length)
|
|
1112
1298
|
site = argv[++i];
|
|
1113
1299
|
else if (a.startsWith("--site="))
|
|
1114
1300
|
site = a.slice("--site=".length);
|
|
1115
|
-
else if (a === "--token")
|
|
1301
|
+
else if (a === "--token" && i + 1 < argv.length)
|
|
1116
1302
|
token = argv[++i];
|
|
1117
1303
|
else if (a.startsWith("--token="))
|
|
1118
1304
|
token = a.slice("--token=".length);
|
|
@@ -1120,10 +1306,12 @@ function parseSub(argv) {
|
|
|
1120
1306
|
json = true;
|
|
1121
1307
|
else if (a === "-q" || a === "--quiet")
|
|
1122
1308
|
quiet = true;
|
|
1309
|
+
else if (a === "-h" || a === "--help")
|
|
1310
|
+
help = true;
|
|
1123
1311
|
else if (!a.startsWith("-"))
|
|
1124
1312
|
positionals.push(a);
|
|
1125
1313
|
}
|
|
1126
|
-
return { positionals, site, token, json, quiet };
|
|
1314
|
+
return { positionals, site, token, json, quiet, help };
|
|
1127
1315
|
}
|
|
1128
1316
|
async function runSubcommand(name, argv) {
|
|
1129
1317
|
const io = {
|
|
@@ -1134,23 +1322,36 @@ async function runSubcommand(name, argv) {
|
|
|
1134
1322
|
};
|
|
1135
1323
|
switch (name) {
|
|
1136
1324
|
case "update": {
|
|
1137
|
-
const { positionals, site, token, json, quiet } = parseSub(argv);
|
|
1138
|
-
return update({ path: positionals[0], site, token, json, quiet }, io);
|
|
1325
|
+
const { positionals, site, token, json, quiet, help } = parseSub(argv);
|
|
1326
|
+
return update({ path: positionals[0], site, token, json, quiet, help }, io);
|
|
1139
1327
|
}
|
|
1140
1328
|
case "versions": {
|
|
1141
|
-
const { site, token, json } = parseSub(argv);
|
|
1142
|
-
return versions({ site, token, json }, io);
|
|
1329
|
+
const { site, token, json, help } = parseSub(argv);
|
|
1330
|
+
return versions({ site, token, json, help }, io);
|
|
1143
1331
|
}
|
|
1144
1332
|
case "rollback": {
|
|
1145
|
-
const { positionals, site, token, json } = parseSub(argv);
|
|
1146
|
-
return rollback({ version: positionals[0], site, token, json }, io);
|
|
1333
|
+
const { positionals, site, token, json, help } = parseSub(argv);
|
|
1334
|
+
return rollback({ version: positionals[0], site, token, json, help }, io);
|
|
1147
1335
|
}
|
|
1148
1336
|
case "forget": {
|
|
1149
|
-
const { site } = parseSub(argv);
|
|
1150
|
-
return forget({ site }, io);
|
|
1337
|
+
const { site, help } = parseSub(argv);
|
|
1338
|
+
return forget({ site, help }, io);
|
|
1339
|
+
}
|
|
1340
|
+
case "login": {
|
|
1341
|
+
let key;
|
|
1342
|
+
let help = false;
|
|
1343
|
+
for (let i = 0;i < argv.length; i++) {
|
|
1344
|
+
if (argv[i] === "--key" && i + 1 < argv.length) {
|
|
1345
|
+
key = argv[i + 1];
|
|
1346
|
+
i++;
|
|
1347
|
+
} else if (argv[i]?.startsWith("--key=")) {
|
|
1348
|
+
key = argv[i]?.slice("--key=".length);
|
|
1349
|
+
} else if (argv[i] === "-h" || argv[i] === "--help") {
|
|
1350
|
+
help = true;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return login({ key, help }, io);
|
|
1151
1354
|
}
|
|
1152
|
-
case "login":
|
|
1153
|
-
return login({}, io);
|
|
1154
1355
|
case "logout":
|
|
1155
1356
|
return logout({}, io);
|
|
1156
1357
|
case "list":
|
|
@@ -1282,11 +1483,16 @@ Targeting (update / versions / rollback):
|
|
|
1282
1483
|
machine that doesn't remember it. Owned sites use your login.
|
|
1283
1484
|
|
|
1284
1485
|
Account (optional — lets deploys live forever and be listed/owned):
|
|
1285
|
-
flypod login
|
|
1486
|
+
flypod login Link this CLI to your flypod account (opens
|
|
1487
|
+
your browser to confirm). Anonymous deploys
|
|
1488
|
+
keep working; logging in just makes future
|
|
1489
|
+
deploys land in your dashboard.
|
|
1490
|
+
flypod login --key fk_... Save an API key directly (skip the browser).
|
|
1491
|
+
Or set FLYPOD_API_KEY for agents/CI.
|
|
1286
1492
|
flypod logout Forget the saved API key.
|
|
1287
|
-
flypod list List sites you own.
|
|
1288
|
-
flypod claim <id> <token> Attach an
|
|
1289
|
-
flypod keys create Mint a new API key
|
|
1493
|
+
flypod list List sites you own (JSON on stdout).
|
|
1494
|
+
flypod claim <id> <token> Attach an anonymous deploy to your account.
|
|
1495
|
+
flypod keys create Mint a new API key for agents / CI (JSON on stdout).
|
|
1290
1496
|
flypod forget [--site <id>] Drop this folder's remembered site link.
|
|
1291
1497
|
|
|
1292
1498
|
Agents:
|
|
@@ -1310,7 +1516,6 @@ When no path is given, flypod looks for a build folder in the current directory:
|
|
|
1310
1516
|
(each must contain an index.html)
|
|
1311
1517
|
|
|
1312
1518
|
Docs: https://flypod.dev
|
|
1313
|
-
Source: https://github.com/sdserranog/flypod
|
|
1314
1519
|
`;
|
|
1315
1520
|
process.stdout.write(usage);
|
|
1316
1521
|
}
|
|
@@ -1345,6 +1550,11 @@ async function main() {
|
|
|
1345
1550
|
${style.bold(style.accent("flypod"))} ${style.dim(`v${version}`)}
|
|
1346
1551
|
|
|
1347
1552
|
`);
|
|
1553
|
+
if (!apiKey) {
|
|
1554
|
+
process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · ")}${style.bold("flypod login")}${style.dim(" to attribute deploys to your account")}
|
|
1555
|
+
|
|
1556
|
+
`);
|
|
1557
|
+
}
|
|
1348
1558
|
}
|
|
1349
1559
|
let dir;
|
|
1350
1560
|
try {
|
|
@@ -1463,7 +1673,7 @@ async function main() {
|
|
|
1463
1673
|
process.stderr.write(` ${rule}
|
|
1464
1674
|
|
|
1465
1675
|
`);
|
|
1466
|
-
const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days .
|
|
1676
|
+
const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days . anonymous deploy (run \`flypod login\` to attribute)` : result.owner_account_id ? "never . attributed to your account" : "never (claimed)";
|
|
1467
1677
|
process.stderr.write(` ${style.muted("expires")} ${style.dim(expiry)}
|
|
1468
1678
|
|
|
1469
1679
|
`);
|