flypod 0.9.0 → 0.10.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 +56 -18
- package/dist/bin/deploy.js +659 -322
- package/dist/{cli-db9gcrd0.js → cli-198a0gkx.js} +1093 -1008
- package/dist/src/cli/commands.d.ts +11 -2
- package/dist/src/cli/errors.d.ts +68 -0
- package/dist/src/cli/receipt.d.ts +7 -0
- package/dist/src/cli.d.ts +16 -0
- package/dist/src/cli.js +3 -1
- package/dist/src/deploy-source.d.ts +17 -0
- package/dist/src/pack.d.ts +25 -0
- package/package.json +3 -4
|
@@ -23,13 +23,20 @@ export interface CommandIO {
|
|
|
23
23
|
}
|
|
24
24
|
export declare function login(args: {
|
|
25
25
|
token?: string;
|
|
26
|
+
deviceCode?: string;
|
|
27
|
+
json?: boolean;
|
|
26
28
|
help?: boolean;
|
|
27
29
|
}, io: CommandIO): Promise<number>;
|
|
28
|
-
export declare function logout(
|
|
29
|
-
|
|
30
|
+
export declare function logout(args: {
|
|
31
|
+
json?: boolean;
|
|
32
|
+
}, io: CommandIO): Promise<number>;
|
|
33
|
+
export declare function list(args: {
|
|
34
|
+
json?: boolean;
|
|
35
|
+
}, io: CommandIO): Promise<number>;
|
|
30
36
|
export declare function claim(args: {
|
|
31
37
|
site_id?: string;
|
|
32
38
|
token?: string;
|
|
39
|
+
json?: boolean;
|
|
33
40
|
}, io: CommandIO): Promise<number>;
|
|
34
41
|
export declare function update(args: {
|
|
35
42
|
path?: string;
|
|
@@ -67,10 +74,12 @@ export declare function rollback(args: {
|
|
|
67
74
|
*/
|
|
68
75
|
export declare function token(args: {
|
|
69
76
|
site?: string;
|
|
77
|
+
json?: boolean;
|
|
70
78
|
help?: boolean;
|
|
71
79
|
}, io: CommandIO): Promise<number>;
|
|
72
80
|
export declare function forget(args: {
|
|
73
81
|
site?: string;
|
|
82
|
+
json?: boolean;
|
|
74
83
|
help?: boolean;
|
|
75
84
|
}, io: CommandIO): Promise<number>;
|
|
76
85
|
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { CommandIO } from "./commands";
|
|
2
|
+
export type ErrorCode = "usage" | "unknown_command" | "unknown_flag" | "no_build_dir" | "no_files" | "no_site" | "no_token" | "not_signed_in" | "unauthorized" | "token_rejected" | "not_found" | "no_such_version" | "site_gone" | "already_claimed" | "invalid_upload" | "too_large" | "blocked" | "challenge_required" | "rate_limited" | "server_error" | "bad_request" | "network" | "interactive_login_required" | "authorization_pending" | "login_denied" | "login_expired" | "login_timeout" | "unexpected";
|
|
3
|
+
export interface CliError {
|
|
4
|
+
code: ErrorCode;
|
|
5
|
+
/** Human-readable reason. Free text; agents branch on `code` instead. */
|
|
6
|
+
error: string;
|
|
7
|
+
/** The literal next step, when there is one. */
|
|
8
|
+
fix?: string;
|
|
9
|
+
/** HTTP status that produced this, when a server was involved. */
|
|
10
|
+
status?: number;
|
|
11
|
+
/** Extra machine-readable fields merged into the JSON envelope. */
|
|
12
|
+
extra?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare function exitCodeFor(code: ErrorCode): number;
|
|
15
|
+
/** The wire shape, exactly as it is written to stdout under `--json`. */
|
|
16
|
+
export declare function errorEnvelope(err: CliError): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Report a failure and return the exit code the caller should propagate.
|
|
19
|
+
*
|
|
20
|
+
* `--json` → one line of JSON on stdout, nothing on stderr. Otherwise the
|
|
21
|
+
* reason goes to stderr with the fix on the next line, prefixed so the user
|
|
22
|
+
* sees which verb failed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function emitError(err: CliError, args: {
|
|
25
|
+
json?: boolean;
|
|
26
|
+
}, io: Pick<CommandIO, "out" | "err">, opts?: {
|
|
27
|
+
prefix?: string;
|
|
28
|
+
}): number;
|
|
29
|
+
/** Shorthand for the common "build the error, emit it, return the code" line. */
|
|
30
|
+
export declare function fail(code: ErrorCode, error: string, args: {
|
|
31
|
+
json?: boolean;
|
|
32
|
+
}, io: Pick<CommandIO, "out" | "err">, opts?: {
|
|
33
|
+
fix?: string;
|
|
34
|
+
prefix?: string;
|
|
35
|
+
status?: number;
|
|
36
|
+
extra?: Record<string, unknown>;
|
|
37
|
+
}): number;
|
|
38
|
+
/**
|
|
39
|
+
* What the server actually said. The control plane answers with
|
|
40
|
+
* `{ error, code }` JSON; older paths and the edge answer with plain text.
|
|
41
|
+
* Either way the caller gets a sentence, never `[object Object]` or an empty
|
|
42
|
+
* string.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readServerMessage(res: Response): Promise<{
|
|
45
|
+
message: string;
|
|
46
|
+
code?: string;
|
|
47
|
+
}>;
|
|
48
|
+
export interface ClassifyContext {
|
|
49
|
+
/** `flypod update`, `flypod comments post`, … — for the human prefix. */
|
|
50
|
+
verb: string;
|
|
51
|
+
/** The site the request was about, for the `fix` wording. */
|
|
52
|
+
siteId?: string;
|
|
53
|
+
/** True when a 404 means "the site is gone" rather than "no such thing". */
|
|
54
|
+
siteScoped?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Turn a non-2xx response into a `CliError` with a stable code and a fix.
|
|
58
|
+
* The server's own `code` wins when it sends one (e.g. `token_rejected`);
|
|
59
|
+
* otherwise the status decides.
|
|
60
|
+
*/
|
|
61
|
+
export declare function classifyResponse(res: Response, ctx: ClassifyContext): Promise<CliError>;
|
|
62
|
+
/** A `fetch` that threw: DNS, refused connection, TLS, timeout. */
|
|
63
|
+
export declare function networkError(e: unknown, baseUrl?: string): CliError;
|
|
64
|
+
/** The canonical "nothing is linked here" failure, shared by every verb that targets a site. */
|
|
65
|
+
export declare const NO_SITE: CliError;
|
|
66
|
+
export declare const NOT_SIGNED_IN: CliError;
|
|
67
|
+
/** Message for `main().catch` and any other last-resort handler. */
|
|
68
|
+
export declare function unexpectedError(e: unknown): CliError;
|
|
@@ -141,6 +141,13 @@ export interface AgentNextOptions {
|
|
|
141
141
|
siteId: string;
|
|
142
142
|
expiresAt: number | null;
|
|
143
143
|
owned: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Whether the folder → site link was written. Defaults to true. When the
|
|
146
|
+
* config dir was not writable, the bare `flypod update` the note recommends
|
|
147
|
+
* would fail with `no_site` and an agent's natural recovery is a second
|
|
148
|
+
* deploy — so every `next` command carries `--site <id>` instead.
|
|
149
|
+
*/
|
|
150
|
+
linkSaved?: boolean;
|
|
144
151
|
now?: number;
|
|
145
152
|
}
|
|
146
153
|
/**
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -70,3 +70,19 @@ export interface DeployOptions {
|
|
|
70
70
|
* session or ambient env vars the caller didn't pass in `opts`.
|
|
71
71
|
*/
|
|
72
72
|
export declare function deploySite(opts: DeployOptions): Promise<DeployResult>;
|
|
73
|
+
/**
|
|
74
|
+
* A deploy the server refused. Carries the status and whatever the server
|
|
75
|
+
* said, so a caller can tell a rate limit (retry later) from a blocked upload
|
|
76
|
+
* (do not retry) — `deploy failed: 429` on its own could not.
|
|
77
|
+
*/
|
|
78
|
+
export declare class DeployError extends Error {
|
|
79
|
+
readonly status: number;
|
|
80
|
+
/** The response body, verbatim (JSON or plain text), for diagnostics. */
|
|
81
|
+
readonly body: string;
|
|
82
|
+
/** The server's stable error code, when its body carried one. */
|
|
83
|
+
readonly code: string | undefined;
|
|
84
|
+
constructor(status: number, body: string, code?: string);
|
|
85
|
+
static fromResponse(res: Response): Promise<DeployError>;
|
|
86
|
+
/** Rebuild a `Response` so the CLI's classifier can treat it like any other failure. */
|
|
87
|
+
toResponse(): Response;
|
|
88
|
+
}
|
package/dist/src/cli.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BUILD_DIR_CANDIDATES,
|
|
3
|
+
DeployError,
|
|
3
4
|
collectDist,
|
|
4
5
|
deploySite,
|
|
5
6
|
resolveDeployDir
|
|
6
|
-
} from "../cli-
|
|
7
|
+
} from "../cli-198a0gkx.js";
|
|
7
8
|
export {
|
|
8
9
|
BUILD_DIR_CANDIDATES,
|
|
10
|
+
DeployError,
|
|
9
11
|
collectDist,
|
|
10
12
|
deploySite,
|
|
11
13
|
resolveDeployDir
|
|
@@ -19,6 +19,23 @@ export declare const DEPLOY_SOURCES: readonly ["cli", "browser", "library", "ski
|
|
|
19
19
|
export type DeploySource = (typeof DEPLOY_SOURCES)[number];
|
|
20
20
|
/** Validate a client-supplied source header; anything unrecognized is `unknown`. */
|
|
21
21
|
export declare function coerceSource(value: string | null | undefined): DeploySource;
|
|
22
|
+
/**
|
|
23
|
+
* What kind of program made the request, as coarsely as is still useful.
|
|
24
|
+
*
|
|
25
|
+
* `source` says which of *our* surfaces deployed. A request that carries no
|
|
26
|
+
* source header reads `unknown`, and that is everyone who calls the HTTP API
|
|
27
|
+
* directly — in the week of 2026-09-28 it was ten of fifteen deploys, and
|
|
28
|
+
* nothing on the event could say whether they were one script or ten people
|
|
29
|
+
* following the `curl` examples in the docs.
|
|
30
|
+
*
|
|
31
|
+
* The user agent itself is never recorded: it carries versions, platforms and
|
|
32
|
+
* sometimes hostnames. It is reduced here to one of nine fixed words, which is
|
|
33
|
+
* the whole of what leaves this function.
|
|
34
|
+
*/
|
|
35
|
+
export declare const CLIENT_FAMILIES: readonly ["curl", "node", "bun", "deno", "python", "go", "browser", "other", "none"];
|
|
36
|
+
export type ClientFamily = (typeof CLIENT_FAMILIES)[number];
|
|
37
|
+
/** Reduce a `User-Agent` header to a `ClientFamily`. Never returns the input. */
|
|
38
|
+
export declare function clientFamily(userAgent: string | null | undefined): ClientFamily;
|
|
22
39
|
/**
|
|
23
40
|
* Validate a client-supplied anon id. PostHog device ids are UUID-shaped, so a
|
|
24
41
|
* conservative charset + length cap is enough to keep anything else (a stray
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pack a files map into the archive we upload.
|
|
3
|
+
*
|
|
4
|
+
* **Stored, not deflated, and that is deliberate.** The API runs on Cloudflare
|
|
5
|
+
* Workers Free, which gives a request 10 ms of CPU. Measured on the deployed
|
|
6
|
+
* Worker with `scripts/worker-cpu.ts`, for the same 20-file, 489 KB `dist/`:
|
|
7
|
+
*
|
|
8
|
+
* | archive | wire | CPU per deploy | over the 10 ms budget |
|
|
9
|
+
* |----------|--------|----------------|-----------------------|
|
|
10
|
+
* | deflated | 313 KB | 27.8 ms | 8 of 21 |
|
|
11
|
+
* | stored | 491 KB | 1.0 ms | 0 of 20 |
|
|
12
|
+
*
|
|
13
|
+
* Inflating in the isolate is the entire deploy budget and then some; reading
|
|
14
|
+
* a stored entry is a subarray onto bytes already in memory. Before this, a
|
|
15
|
+
* sustained 1 deploy/second killed 88% of deploys with `exceededCpu`.
|
|
16
|
+
*
|
|
17
|
+
* The cost is real and lands on the user: about 57% more to upload, which on a
|
|
18
|
+
* slow uplink is a slower deploy. We take it because CPU is the scarce,
|
|
19
|
+
* shared, cliff-edged resource and bandwidth is none of those things. On a
|
|
20
|
+
* paid Workers plan the trade reverses and this should go back to `zipSync`.
|
|
21
|
+
*
|
|
22
|
+
* The server reads both — a deflated archive from any already-published CLI
|
|
23
|
+
* still deploys, it just costs what it always did.
|
|
24
|
+
*/
|
|
25
|
+
export declare function packDeploy(files: Record<string, Uint8Array>): Uint8Array;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flypod",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Zero-auth deploy primitive. Turns any folder into a live URL in one command. For AI agents and humans.",
|
|
5
5
|
"module": "./dist/src/cli.js",
|
|
6
6
|
"types": "./dist/src/cli.d.ts",
|
|
@@ -36,12 +36,11 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "rm -rf dist && bun build src/cli.ts bin/deploy.ts --outdir dist --target node --splitting && tsc -p tsconfig.build.json",
|
|
38
38
|
"prepublishOnly": "bun run build",
|
|
39
|
-
"test": "bun
|
|
40
|
-
"test:unit": "bun test --test-name-pattern='^(?!.*BDD).*' $(find test -name '*.test.ts' ! -path 'test/comments/bdd.test.ts')",
|
|
41
|
-
"test:bdd": "bun test test/comments/bdd.test.ts",
|
|
39
|
+
"test": "bun test",
|
|
42
40
|
"typecheck": "tsc --noEmit",
|
|
43
41
|
"build:account-page": "bun scripts/build-account-page.ts",
|
|
44
42
|
"deploy": "wrangler deploy",
|
|
43
|
+
"loadtest": "bun scripts/load-test.ts",
|
|
45
44
|
"dev": "bun --hot index.ts"
|
|
46
45
|
},
|
|
47
46
|
"dependencies": {
|