@moku-labs/worker 0.5.0 → 0.6.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 +10 -9
- package/dist/cli-Dc0q0hIy.cjs +2988 -0
- package/dist/cli-DgZv5A0G.mjs +2888 -0
- package/dist/cli.cjs +3 -1900
- package/dist/cli.d.cts +1 -270
- package/dist/cli.d.mts +1 -270
- package/dist/cli.mjs +1 -1875
- package/dist/index-VZ99IAMv.d.cts +353 -0
- package/dist/index-VZ99IAMv.d.mts +353 -0
- package/dist/index.cjs +61 -63
- package/dist/index.d.cts +8 -4
- package/dist/index.d.mts +8 -4
- package/dist/index.mjs +49 -53
- package/package.json +1 -1
- package/dist/config-BYPJvEbl.d.cts +0 -88
- package/dist/config-BYPJvEbl.d.mts +0 -88
- package/dist/storage-COo-F38H.mjs +0 -884
- package/dist/storage-CgXl-dUA.cjs +0 -949
package/dist/cli.d.cts
CHANGED
|
@@ -1,271 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/plugins/deploy/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A web-site build hook wired in from the consumer's deploy/dev script — e.g.
|
|
6
|
-
* `() => webApp.cli.build()`. This is the seam that lets one small app-side script compose a
|
|
7
|
-
* Moku Web app with this Worker framework: `dev` / `deploy` invoke it to (re)build the site
|
|
8
|
-
* before serving or deploying. May resolve a `{ files }` count (surfaced in `dev:rebuilt`) or
|
|
9
|
-
* nothing.
|
|
10
|
-
*
|
|
11
|
-
* @returns Resolves when the web build completes; optionally a rebuilt-file count.
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* await server.cli.dev({ webBuild: () => web.cli.build() });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
type WebBuild = () => Promise<void> | Promise<{
|
|
18
|
-
files?: number;
|
|
19
|
-
}>;
|
|
20
|
-
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
21
|
-
type Config$1 = {
|
|
22
|
-
/**
|
|
23
|
-
* Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
|
|
24
|
-
* Also the file parsed in the universal/non-moku path.
|
|
25
|
-
*/
|
|
26
|
-
configFile: string;
|
|
27
|
-
/**
|
|
28
|
-
* CI mode. When true (or when stdout is non-TTY), the guided flow NEVER prompts.
|
|
29
|
-
* CF credentials are read from the Node env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID).
|
|
30
|
-
* Default false.
|
|
31
|
-
*/
|
|
32
|
-
ci: boolean; /** Globs watched by `dev()` to trigger a Moku-site rebuild. */
|
|
33
|
-
watch: string[];
|
|
34
|
-
/**
|
|
35
|
-
* Standing default web-site build hook (e.g. `() => webApp.cli.build()`). Usually passed
|
|
36
|
-
* call-time to `dev` / `deploy` via `opts.webBuild` (the script-driven path); set here only for
|
|
37
|
-
* a persistent default. When absent, dev() falls back to `buildCommand`, then auto-detects
|
|
38
|
-
* `scripts/build.ts`.
|
|
39
|
-
*/
|
|
40
|
-
webBuild?: WebBuild; /** Shell rebuild fallback (e.g. "bun run scripts/build.ts"); empty → auto-detect scripts/build.ts. */
|
|
41
|
-
buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
|
|
42
|
-
migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
|
|
43
|
-
debounceMs: number;
|
|
44
|
-
};
|
|
45
|
-
/** Discriminated union of resource descriptors returned by each plugin's deployManifest(). */
|
|
46
|
-
type ResourceManifest = {
|
|
47
|
-
kind: "r2";
|
|
48
|
-
bucket: string;
|
|
49
|
-
upload?: string;
|
|
50
|
-
} | {
|
|
51
|
-
kind: "kv";
|
|
52
|
-
binding: string;
|
|
53
|
-
} | {
|
|
54
|
-
kind: "d1";
|
|
55
|
-
binding: string;
|
|
56
|
-
migrations?: string;
|
|
57
|
-
} | {
|
|
58
|
-
kind: "queue";
|
|
59
|
-
producers: string[];
|
|
60
|
-
} | {
|
|
61
|
-
kind: "do";
|
|
62
|
-
bindings: Record<string, string>;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
|
|
66
|
-
* universal path).
|
|
67
|
-
*/
|
|
68
|
-
type ExternalManifest = {
|
|
69
|
-
/** Worker name. */name: string; /** Cloudflare compatibility date. */
|
|
70
|
-
compatibilityDate: string; /** Resource descriptors to provision. */
|
|
71
|
-
resources: ResourceManifest[];
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* A resource that already exists in the account (the infra preflight discovered it), with its
|
|
75
|
-
* captured Cloudflare id when the kind has one (kv namespace id, d1 database id).
|
|
76
|
-
*/
|
|
77
|
-
type ProvisionedRef = {
|
|
78
|
-
/** The resource descriptor from the manifest. */resource: ResourceManifest; /** The existing resource's Cloudflare id (kv/d1 only). */
|
|
79
|
-
id?: string;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Read-only infra preflight result: which declared resources already exist in the Cloudflare
|
|
83
|
-
* account versus which are still missing and must be created. Produced by `checkInfra()`.
|
|
84
|
-
*/
|
|
85
|
-
type InfraPlan = {
|
|
86
|
-
/** Resolved account display name (or id when the name is unknown). */account: string; /** Resolved Cloudflare account id used for the existence checks. */
|
|
87
|
-
accountId: string; /** Declared resources that already exist (with their captured ids where applicable). */
|
|
88
|
-
exists: ProvisionedRef[]; /** Declared resources that do not yet exist and must be created. */
|
|
89
|
-
missing: ResourceManifest[];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Outcome of acting on an {@link InfraPlan}: the resources just created, those skipped because
|
|
93
|
-
* they already existed, and the merged id map (binding → Cloudflare id) for the config writer.
|
|
94
|
-
*/
|
|
95
|
-
type ProvisionResult = {
|
|
96
|
-
/** Resources created during this run. */created: ProvisionedRef[]; /** Resources skipped because they already existed. */
|
|
97
|
-
skipped: ProvisionedRef[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
|
|
98
|
-
ids: Record<string, string>;
|
|
99
|
-
};
|
|
100
|
-
/** Result of verifying the `.env` Cloudflare API token and resolving its account. */
|
|
101
|
-
type AuthStatus = {
|
|
102
|
-
/** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
|
|
103
|
-
account: string; /** Resolved Cloudflare account id. */
|
|
104
|
-
accountId: string; /** Token scopes, when discoverable (empty otherwise). */
|
|
105
|
-
scopes: string[];
|
|
106
|
-
};
|
|
107
|
-
/** One Cloudflare API-token permission group the app's manifest requires. */
|
|
108
|
-
type PermissionGroup = {
|
|
109
|
-
/** Human-readable group label, e.g. "Account · D1". */group: string; /** Permission scope. */
|
|
110
|
-
scope: "Edit" | "Read"; /** Why it is required, e.g. "d1", "queue", "deploy", "account". */
|
|
111
|
-
reason: string; /** Whether Cloudflare's stock "Edit Cloudflare Workers" template already includes it. */
|
|
112
|
-
inBaseTemplate: boolean;
|
|
113
|
-
};
|
|
114
|
-
/** The Cloudflare API token this app requires, derived from its manifest. */
|
|
115
|
-
type TokenRequirement = {
|
|
116
|
-
/** The recommended starting template. */base: "Edit Cloudflare Workers"; /** The full set of permission groups required. */
|
|
117
|
-
required: PermissionGroup[]; /** Groups NOT in the base template that the user must add (e.g. D1, Queues). */
|
|
118
|
-
toAdd: PermissionGroup[];
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/plugins/cli/types.d.ts
|
|
122
|
-
/** Resolved configuration for the cli plugin. Flat; complete defaults so omission never yields undefined. */
|
|
123
|
-
type Config = {
|
|
124
|
-
/**
|
|
125
|
-
* Default local dev port forwarded to deploy.dev when dev() gets no port.
|
|
126
|
-
* Passed through to `wrangler dev --port <n>`.
|
|
127
|
-
*
|
|
128
|
-
* @default 8787
|
|
129
|
-
*/
|
|
130
|
-
readonly port: number;
|
|
131
|
-
};
|
|
132
|
-
/** Public api surface of the cli plugin, mounted at app.cli.*. */
|
|
133
|
-
type Api = {
|
|
134
|
-
/**
|
|
135
|
-
* Run the Worker locally via Wrangler (delegates to deploy.dev).
|
|
136
|
-
* Defaults port to the configured value (8787) when called with no opts.
|
|
137
|
-
*
|
|
138
|
-
* @param opts - Optional port override and web build hook.
|
|
139
|
-
* @param opts.port - Local dev port to bind.
|
|
140
|
-
* @param opts.webBuild - Rebuild the web site on change (e.g. `() => webApp.cli.build()`).
|
|
141
|
-
* @returns Resolves when the dev session ends.
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* await app.cli.dev(); // port 8787, worker only
|
|
145
|
-
* await app.cli.dev({ webBuild: () => web.cli.build() }); // wire the web build in
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
dev(opts?: {
|
|
149
|
-
port?: number;
|
|
150
|
-
webBuild?: WebBuild;
|
|
151
|
-
}): Promise<void>;
|
|
152
|
-
/**
|
|
153
|
-
* One-command guided Cloudflare deploy (delegates to deploy.run).
|
|
154
|
-
* Forwards opts verbatim — passes undefined when called with no opts.
|
|
155
|
-
*
|
|
156
|
-
* @param opts - Optional guided/yes flags and a web build hook.
|
|
157
|
-
* @param opts.guided - Walk through each step interactively.
|
|
158
|
-
* @param opts.yes - Skip confirmation prompts (non-interactive).
|
|
159
|
-
* @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
|
|
160
|
-
* @returns Resolves once the deploy completes.
|
|
161
|
-
* @example
|
|
162
|
-
* ```ts
|
|
163
|
-
* await app.cli.deploy({ guided: true, webBuild: () => web.cli.build() });
|
|
164
|
-
* await app.cli.deploy({ yes: true }); // CI
|
|
165
|
-
* await app.cli.deploy(); // no opts → undefined forwarded
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
deploy(opts?: {
|
|
169
|
-
guided?: boolean;
|
|
170
|
-
yes?: boolean;
|
|
171
|
-
webBuild?: WebBuild;
|
|
172
|
-
}): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Verify the `.env` Cloudflare token (no sub), or print the config-derived token-creation
|
|
175
|
-
* guidance (`"setup"`). Delegates to deploy.verifyAuth() / deploy.tokenInstructions().
|
|
176
|
-
*
|
|
177
|
-
* @param sub - Pass "setup" to print token guidance; omit to verify the current token.
|
|
178
|
-
* @returns Resolves once the auth check or guidance render completes.
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* await app.cli.auth(); // verify the current token
|
|
182
|
-
* await app.cli.auth("setup"); // print what token to create
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
auth(sub?: "setup"): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* One-shot preflight report: token + account (verifyAuth) and infra drift (checkInfra),
|
|
188
|
-
* each rendered as a branded check line.
|
|
189
|
-
*
|
|
190
|
-
* @returns Resolves once the report is printed.
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* await app.cli.doctor();
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
doctor(): Promise<void>;
|
|
197
|
-
/**
|
|
198
|
-
* Print the resolved Cloudflare account for the current `.env` token (delegates to verifyAuth).
|
|
199
|
-
*
|
|
200
|
-
* @returns Resolves once the account summary is printed.
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* await app.cli.whoami();
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
whoami(): Promise<void>;
|
|
207
|
-
/**
|
|
208
|
-
* Run an arbitrary `wrangler` command through the branded CLI — the escape hatch for subcommands
|
|
209
|
-
* Moku does not wrap (kv / d1 / r2 / queues / secret / tail / …). Streams wrangler's output.
|
|
210
|
-
*
|
|
211
|
-
* @param args - The wrangler arguments (e.g. ["kv", "namespace", "list"]).
|
|
212
|
-
* @returns Resolves once wrangler exits.
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* await app.cli.wrangler(["kv", "namespace", "list"]);
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
wrangler(args: string[]): Promise<void>;
|
|
219
|
-
};
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/plugins/cli/index.d.ts
|
|
222
|
-
/**
|
|
223
|
-
* Standard tier (node-only) — developer-facing CLI surface.
|
|
224
|
-
*
|
|
225
|
-
* Mounts `app.cli.dev()` and `app.cli.deploy()` as thin passthroughs to deployPlugin.
|
|
226
|
-
* Hooks subscribe to the global deploy:phase / provision:resource / deploy:complete events
|
|
227
|
-
* and print a live progress TUI via the injected ctx.log core API.
|
|
228
|
-
*
|
|
229
|
-
* Inline lambdas on `api`/`hooks` preserve event-name inference so the hook map keys
|
|
230
|
-
* are constrained to `WorkerEvents` keys (spec/15 §5).
|
|
231
|
-
*
|
|
232
|
-
* @see README.md
|
|
233
|
-
*/
|
|
234
|
-
declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config, Record<string, never>, Api, {}> & Record<never, never>;
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/plugins/deploy/index.d.ts
|
|
237
|
-
/**
|
|
238
|
-
* Complex tier (node-only) — build-time deploy orchestrator over the five resource plugins.
|
|
239
|
-
*
|
|
240
|
-
* Assembles each resource plugin's deployManifest() via ctx.require, provisions resources,
|
|
241
|
-
* generates/updates wrangler config, uploads the R2 upload dir, and runs wrangler deploy.
|
|
242
|
-
* Also supports a universal path: run({ manifest }) uses a caller-supplied manifest verbatim.
|
|
243
|
-
*
|
|
244
|
-
* Emits only the global events `deploy:phase`, `deploy:complete`, and `provision:resource`
|
|
245
|
-
* (declared in WorkerEvents — no per-plugin events block).
|
|
246
|
-
*
|
|
247
|
-
* @see README.md
|
|
248
|
-
*/
|
|
249
|
-
declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config$1, Record<string, never>, {
|
|
250
|
-
run(opts?: {
|
|
251
|
-
guided?: boolean;
|
|
252
|
-
yes?: boolean;
|
|
253
|
-
webBuild?: WebBuild;
|
|
254
|
-
manifest?: ExternalManifest;
|
|
255
|
-
}): Promise<void>;
|
|
256
|
-
dev: (opts?: {
|
|
257
|
-
port?: number;
|
|
258
|
-
webBuild?: WebBuild;
|
|
259
|
-
}) => Promise<void>;
|
|
260
|
-
init: (opts?: {
|
|
261
|
-
ci?: boolean;
|
|
262
|
-
}) => Promise<void>;
|
|
263
|
-
checkInfra: () => Promise<InfraPlan>;
|
|
264
|
-
provisionInfra: (plan: InfraPlan) => Promise<ProvisionResult>;
|
|
265
|
-
verifyAuth: () => Promise<AuthStatus>;
|
|
266
|
-
requiredToken: () => TokenRequirement;
|
|
267
|
-
tokenInstructions: () => string;
|
|
268
|
-
wrangler: (args: string[]) => Promise<void>;
|
|
269
|
-
}, {}> & Record<never, never>;
|
|
270
|
-
//#endregion
|
|
1
|
+
import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-VZ99IAMv.cjs";
|
|
271
2
|
export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,271 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/plugins/deploy/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A web-site build hook wired in from the consumer's deploy/dev script — e.g.
|
|
6
|
-
* `() => webApp.cli.build()`. This is the seam that lets one small app-side script compose a
|
|
7
|
-
* Moku Web app with this Worker framework: `dev` / `deploy` invoke it to (re)build the site
|
|
8
|
-
* before serving or deploying. May resolve a `{ files }` count (surfaced in `dev:rebuilt`) or
|
|
9
|
-
* nothing.
|
|
10
|
-
*
|
|
11
|
-
* @returns Resolves when the web build completes; optionally a rebuilt-file count.
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* await server.cli.dev({ webBuild: () => web.cli.build() });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
type WebBuild = () => Promise<void> | Promise<{
|
|
18
|
-
files?: number;
|
|
19
|
-
}>;
|
|
20
|
-
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
21
|
-
type Config$1 = {
|
|
22
|
-
/**
|
|
23
|
-
* Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
|
|
24
|
-
* Also the file parsed in the universal/non-moku path.
|
|
25
|
-
*/
|
|
26
|
-
configFile: string;
|
|
27
|
-
/**
|
|
28
|
-
* CI mode. When true (or when stdout is non-TTY), the guided flow NEVER prompts.
|
|
29
|
-
* CF credentials are read from the Node env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID).
|
|
30
|
-
* Default false.
|
|
31
|
-
*/
|
|
32
|
-
ci: boolean; /** Globs watched by `dev()` to trigger a Moku-site rebuild. */
|
|
33
|
-
watch: string[];
|
|
34
|
-
/**
|
|
35
|
-
* Standing default web-site build hook (e.g. `() => webApp.cli.build()`). Usually passed
|
|
36
|
-
* call-time to `dev` / `deploy` via `opts.webBuild` (the script-driven path); set here only for
|
|
37
|
-
* a persistent default. When absent, dev() falls back to `buildCommand`, then auto-detects
|
|
38
|
-
* `scripts/build.ts`.
|
|
39
|
-
*/
|
|
40
|
-
webBuild?: WebBuild; /** Shell rebuild fallback (e.g. "bun run scripts/build.ts"); empty → auto-detect scripts/build.ts. */
|
|
41
|
-
buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
|
|
42
|
-
migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
|
|
43
|
-
debounceMs: number;
|
|
44
|
-
};
|
|
45
|
-
/** Discriminated union of resource descriptors returned by each plugin's deployManifest(). */
|
|
46
|
-
type ResourceManifest = {
|
|
47
|
-
kind: "r2";
|
|
48
|
-
bucket: string;
|
|
49
|
-
upload?: string;
|
|
50
|
-
} | {
|
|
51
|
-
kind: "kv";
|
|
52
|
-
binding: string;
|
|
53
|
-
} | {
|
|
54
|
-
kind: "d1";
|
|
55
|
-
binding: string;
|
|
56
|
-
migrations?: string;
|
|
57
|
-
} | {
|
|
58
|
-
kind: "queue";
|
|
59
|
-
producers: string[];
|
|
60
|
-
} | {
|
|
61
|
-
kind: "do";
|
|
62
|
-
bindings: Record<string, string>;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
|
|
66
|
-
* universal path).
|
|
67
|
-
*/
|
|
68
|
-
type ExternalManifest = {
|
|
69
|
-
/** Worker name. */name: string; /** Cloudflare compatibility date. */
|
|
70
|
-
compatibilityDate: string; /** Resource descriptors to provision. */
|
|
71
|
-
resources: ResourceManifest[];
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* A resource that already exists in the account (the infra preflight discovered it), with its
|
|
75
|
-
* captured Cloudflare id when the kind has one (kv namespace id, d1 database id).
|
|
76
|
-
*/
|
|
77
|
-
type ProvisionedRef = {
|
|
78
|
-
/** The resource descriptor from the manifest. */resource: ResourceManifest; /** The existing resource's Cloudflare id (kv/d1 only). */
|
|
79
|
-
id?: string;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Read-only infra preflight result: which declared resources already exist in the Cloudflare
|
|
83
|
-
* account versus which are still missing and must be created. Produced by `checkInfra()`.
|
|
84
|
-
*/
|
|
85
|
-
type InfraPlan = {
|
|
86
|
-
/** Resolved account display name (or id when the name is unknown). */account: string; /** Resolved Cloudflare account id used for the existence checks. */
|
|
87
|
-
accountId: string; /** Declared resources that already exist (with their captured ids where applicable). */
|
|
88
|
-
exists: ProvisionedRef[]; /** Declared resources that do not yet exist and must be created. */
|
|
89
|
-
missing: ResourceManifest[];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Outcome of acting on an {@link InfraPlan}: the resources just created, those skipped because
|
|
93
|
-
* they already existed, and the merged id map (binding → Cloudflare id) for the config writer.
|
|
94
|
-
*/
|
|
95
|
-
type ProvisionResult = {
|
|
96
|
-
/** Resources created during this run. */created: ProvisionedRef[]; /** Resources skipped because they already existed. */
|
|
97
|
-
skipped: ProvisionedRef[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
|
|
98
|
-
ids: Record<string, string>;
|
|
99
|
-
};
|
|
100
|
-
/** Result of verifying the `.env` Cloudflare API token and resolving its account. */
|
|
101
|
-
type AuthStatus = {
|
|
102
|
-
/** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
|
|
103
|
-
account: string; /** Resolved Cloudflare account id. */
|
|
104
|
-
accountId: string; /** Token scopes, when discoverable (empty otherwise). */
|
|
105
|
-
scopes: string[];
|
|
106
|
-
};
|
|
107
|
-
/** One Cloudflare API-token permission group the app's manifest requires. */
|
|
108
|
-
type PermissionGroup = {
|
|
109
|
-
/** Human-readable group label, e.g. "Account · D1". */group: string; /** Permission scope. */
|
|
110
|
-
scope: "Edit" | "Read"; /** Why it is required, e.g. "d1", "queue", "deploy", "account". */
|
|
111
|
-
reason: string; /** Whether Cloudflare's stock "Edit Cloudflare Workers" template already includes it. */
|
|
112
|
-
inBaseTemplate: boolean;
|
|
113
|
-
};
|
|
114
|
-
/** The Cloudflare API token this app requires, derived from its manifest. */
|
|
115
|
-
type TokenRequirement = {
|
|
116
|
-
/** The recommended starting template. */base: "Edit Cloudflare Workers"; /** The full set of permission groups required. */
|
|
117
|
-
required: PermissionGroup[]; /** Groups NOT in the base template that the user must add (e.g. D1, Queues). */
|
|
118
|
-
toAdd: PermissionGroup[];
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/plugins/cli/types.d.ts
|
|
122
|
-
/** Resolved configuration for the cli plugin. Flat; complete defaults so omission never yields undefined. */
|
|
123
|
-
type Config = {
|
|
124
|
-
/**
|
|
125
|
-
* Default local dev port forwarded to deploy.dev when dev() gets no port.
|
|
126
|
-
* Passed through to `wrangler dev --port <n>`.
|
|
127
|
-
*
|
|
128
|
-
* @default 8787
|
|
129
|
-
*/
|
|
130
|
-
readonly port: number;
|
|
131
|
-
};
|
|
132
|
-
/** Public api surface of the cli plugin, mounted at app.cli.*. */
|
|
133
|
-
type Api = {
|
|
134
|
-
/**
|
|
135
|
-
* Run the Worker locally via Wrangler (delegates to deploy.dev).
|
|
136
|
-
* Defaults port to the configured value (8787) when called with no opts.
|
|
137
|
-
*
|
|
138
|
-
* @param opts - Optional port override and web build hook.
|
|
139
|
-
* @param opts.port - Local dev port to bind.
|
|
140
|
-
* @param opts.webBuild - Rebuild the web site on change (e.g. `() => webApp.cli.build()`).
|
|
141
|
-
* @returns Resolves when the dev session ends.
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* await app.cli.dev(); // port 8787, worker only
|
|
145
|
-
* await app.cli.dev({ webBuild: () => web.cli.build() }); // wire the web build in
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
dev(opts?: {
|
|
149
|
-
port?: number;
|
|
150
|
-
webBuild?: WebBuild;
|
|
151
|
-
}): Promise<void>;
|
|
152
|
-
/**
|
|
153
|
-
* One-command guided Cloudflare deploy (delegates to deploy.run).
|
|
154
|
-
* Forwards opts verbatim — passes undefined when called with no opts.
|
|
155
|
-
*
|
|
156
|
-
* @param opts - Optional guided/yes flags and a web build hook.
|
|
157
|
-
* @param opts.guided - Walk through each step interactively.
|
|
158
|
-
* @param opts.yes - Skip confirmation prompts (non-interactive).
|
|
159
|
-
* @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
|
|
160
|
-
* @returns Resolves once the deploy completes.
|
|
161
|
-
* @example
|
|
162
|
-
* ```ts
|
|
163
|
-
* await app.cli.deploy({ guided: true, webBuild: () => web.cli.build() });
|
|
164
|
-
* await app.cli.deploy({ yes: true }); // CI
|
|
165
|
-
* await app.cli.deploy(); // no opts → undefined forwarded
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
deploy(opts?: {
|
|
169
|
-
guided?: boolean;
|
|
170
|
-
yes?: boolean;
|
|
171
|
-
webBuild?: WebBuild;
|
|
172
|
-
}): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Verify the `.env` Cloudflare token (no sub), or print the config-derived token-creation
|
|
175
|
-
* guidance (`"setup"`). Delegates to deploy.verifyAuth() / deploy.tokenInstructions().
|
|
176
|
-
*
|
|
177
|
-
* @param sub - Pass "setup" to print token guidance; omit to verify the current token.
|
|
178
|
-
* @returns Resolves once the auth check or guidance render completes.
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* await app.cli.auth(); // verify the current token
|
|
182
|
-
* await app.cli.auth("setup"); // print what token to create
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
auth(sub?: "setup"): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* One-shot preflight report: token + account (verifyAuth) and infra drift (checkInfra),
|
|
188
|
-
* each rendered as a branded check line.
|
|
189
|
-
*
|
|
190
|
-
* @returns Resolves once the report is printed.
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* await app.cli.doctor();
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
doctor(): Promise<void>;
|
|
197
|
-
/**
|
|
198
|
-
* Print the resolved Cloudflare account for the current `.env` token (delegates to verifyAuth).
|
|
199
|
-
*
|
|
200
|
-
* @returns Resolves once the account summary is printed.
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* await app.cli.whoami();
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
whoami(): Promise<void>;
|
|
207
|
-
/**
|
|
208
|
-
* Run an arbitrary `wrangler` command through the branded CLI — the escape hatch for subcommands
|
|
209
|
-
* Moku does not wrap (kv / d1 / r2 / queues / secret / tail / …). Streams wrangler's output.
|
|
210
|
-
*
|
|
211
|
-
* @param args - The wrangler arguments (e.g. ["kv", "namespace", "list"]).
|
|
212
|
-
* @returns Resolves once wrangler exits.
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* await app.cli.wrangler(["kv", "namespace", "list"]);
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
wrangler(args: string[]): Promise<void>;
|
|
219
|
-
};
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/plugins/cli/index.d.ts
|
|
222
|
-
/**
|
|
223
|
-
* Standard tier (node-only) — developer-facing CLI surface.
|
|
224
|
-
*
|
|
225
|
-
* Mounts `app.cli.dev()` and `app.cli.deploy()` as thin passthroughs to deployPlugin.
|
|
226
|
-
* Hooks subscribe to the global deploy:phase / provision:resource / deploy:complete events
|
|
227
|
-
* and print a live progress TUI via the injected ctx.log core API.
|
|
228
|
-
*
|
|
229
|
-
* Inline lambdas on `api`/`hooks` preserve event-name inference so the hook map keys
|
|
230
|
-
* are constrained to `WorkerEvents` keys (spec/15 §5).
|
|
231
|
-
*
|
|
232
|
-
* @see README.md
|
|
233
|
-
*/
|
|
234
|
-
declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config, Record<string, never>, Api, {}> & Record<never, never>;
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/plugins/deploy/index.d.ts
|
|
237
|
-
/**
|
|
238
|
-
* Complex tier (node-only) — build-time deploy orchestrator over the five resource plugins.
|
|
239
|
-
*
|
|
240
|
-
* Assembles each resource plugin's deployManifest() via ctx.require, provisions resources,
|
|
241
|
-
* generates/updates wrangler config, uploads the R2 upload dir, and runs wrangler deploy.
|
|
242
|
-
* Also supports a universal path: run({ manifest }) uses a caller-supplied manifest verbatim.
|
|
243
|
-
*
|
|
244
|
-
* Emits only the global events `deploy:phase`, `deploy:complete`, and `provision:resource`
|
|
245
|
-
* (declared in WorkerEvents — no per-plugin events block).
|
|
246
|
-
*
|
|
247
|
-
* @see README.md
|
|
248
|
-
*/
|
|
249
|
-
declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config$1, Record<string, never>, {
|
|
250
|
-
run(opts?: {
|
|
251
|
-
guided?: boolean;
|
|
252
|
-
yes?: boolean;
|
|
253
|
-
webBuild?: WebBuild;
|
|
254
|
-
manifest?: ExternalManifest;
|
|
255
|
-
}): Promise<void>;
|
|
256
|
-
dev: (opts?: {
|
|
257
|
-
port?: number;
|
|
258
|
-
webBuild?: WebBuild;
|
|
259
|
-
}) => Promise<void>;
|
|
260
|
-
init: (opts?: {
|
|
261
|
-
ci?: boolean;
|
|
262
|
-
}) => Promise<void>;
|
|
263
|
-
checkInfra: () => Promise<InfraPlan>;
|
|
264
|
-
provisionInfra: (plan: InfraPlan) => Promise<ProvisionResult>;
|
|
265
|
-
verifyAuth: () => Promise<AuthStatus>;
|
|
266
|
-
requiredToken: () => TokenRequirement;
|
|
267
|
-
tokenInstructions: () => string;
|
|
268
|
-
wrangler: (args: string[]) => Promise<void>;
|
|
269
|
-
}, {}> & Record<never, never>;
|
|
270
|
-
//#endregion
|
|
1
|
+
import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-VZ99IAMv.mjs";
|
|
271
2
|
export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
|