@moku-labs/worker 0.3.1 → 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/dist/cli.d.cts CHANGED
@@ -1,11 +1,126 @@
1
1
  import { PluginCtx, PluginInstance } from "@moku-labs/core";
2
2
 
3
- //#region src/plugins/cli/types.d.ts
3
+ //#region src/plugins/deploy/types.d.ts
4
4
  /**
5
- * @file cli plugin type definitions (Config, Api).
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
+ * ```
6
16
  */
7
- /** Resolved configuration for the cli plugin. Flat; complete defaults so omission never yields undefined. */
17
+ type WebBuild = () => Promise<void> | Promise<{
18
+ files?: number;
19
+ }>;
20
+ /** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
8
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 = {
9
124
  /**
10
125
  * Default local dev port forwarded to deploy.dev when dev() gets no port.
11
126
  * Passed through to `wrangler dev --port <n>`.
@@ -20,29 +135,32 @@ type Api = {
20
135
  * Run the Worker locally via Wrangler (delegates to deploy.dev).
21
136
  * Defaults port to the configured value (8787) when called with no opts.
22
137
  *
23
- * @param opts - Optional port override.
138
+ * @param opts - Optional port override and web build hook.
24
139
  * @param opts.port - Local dev port to bind.
140
+ * @param opts.webBuild - Rebuild the web site on change (e.g. `() => webApp.cli.build()`).
25
141
  * @returns Resolves when the dev session ends.
26
142
  * @example
27
143
  * ```ts
28
- * await app.cli.dev(); // port 8787
29
- * await app.cli.dev({ port: 3000 }); // port 3000
144
+ * await app.cli.dev(); // port 8787, worker only
145
+ * await app.cli.dev({ webBuild: () => web.cli.build() }); // wire the web build in
30
146
  * ```
31
147
  */
32
148
  dev(opts?: {
33
149
  port?: number;
150
+ webBuild?: WebBuild;
34
151
  }): Promise<void>;
35
152
  /**
36
153
  * One-command guided Cloudflare deploy (delegates to deploy.run).
37
154
  * Forwards opts verbatim — passes undefined when called with no opts.
38
155
  *
39
- * @param opts - Optional guided/yes flags.
156
+ * @param opts - Optional guided/yes flags and a web build hook.
40
157
  * @param opts.guided - Walk through each step interactively.
41
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.
42
160
  * @returns Resolves once the deploy completes.
43
161
  * @example
44
162
  * ```ts
45
- * await app.cli.deploy({ guided: true });
163
+ * await app.cli.deploy({ guided: true, webBuild: () => web.cli.build() });
46
164
  * await app.cli.deploy({ yes: true }); // CI
47
165
  * await app.cli.deploy(); // no opts → undefined forwarded
48
166
  * ```
@@ -50,7 +168,54 @@ type Api = {
50
168
  deploy(opts?: {
51
169
  guided?: boolean;
52
170
  yes?: boolean;
171
+ webBuild?: WebBuild;
53
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>;
54
219
  };
55
220
  //#endregion
56
221
  //#region src/plugins/cli/index.d.ts
@@ -66,51 +231,7 @@ type Api = {
66
231
  *
67
232
  * @see README.md
68
233
  */
69
- declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config$1, Record<string, never>, Api, {}> & Record<never, never>;
70
- //#endregion
71
- //#region src/plugins/deploy/types.d.ts
72
- /** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
73
- type Config = {
74
- /**
75
- * Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
76
- * Also the file parsed in the universal/non-moku path.
77
- */
78
- configFile: string;
79
- /**
80
- * CI mode. When true (or when stdout is non-TTY), the guided flow NEVER prompts.
81
- * CF credentials are read from the Node env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID).
82
- * Default false.
83
- */
84
- ci: boolean;
85
- };
86
- /** Discriminated union of resource descriptors returned by each plugin's deployManifest(). */
87
- type ResourceManifest = {
88
- kind: "r2";
89
- bucket: string;
90
- upload?: string;
91
- } | {
92
- kind: "kv";
93
- binding: string;
94
- } | {
95
- kind: "d1";
96
- binding: string;
97
- migrations?: string;
98
- } | {
99
- kind: "queue";
100
- producers: string[];
101
- } | {
102
- kind: "do";
103
- bindings: Record<string, string>;
104
- };
105
- /**
106
- * The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
107
- * universal path).
108
- */
109
- type ExternalManifest = {
110
- /** Worker name. */name: string; /** Cloudflare compatibility date. */
111
- compatibilityDate: string; /** Resource descriptors to provision. */
112
- resources: ResourceManifest[];
113
- };
234
+ declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config, Record<string, never>, Api, {}> & Record<never, never>;
114
235
  //#endregion
115
236
  //#region src/plugins/deploy/index.d.ts
116
237
  /**
@@ -125,18 +246,26 @@ type ExternalManifest = {
125
246
  *
126
247
  * @see README.md
127
248
  */
128
- declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config, Record<string, never>, {
249
+ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config$1, Record<string, never>, {
129
250
  run(opts?: {
130
251
  guided?: boolean;
131
252
  yes?: boolean;
253
+ webBuild?: WebBuild;
132
254
  manifest?: ExternalManifest;
133
255
  }): Promise<void>;
134
256
  dev: (opts?: {
135
257
  port?: number;
258
+ webBuild?: WebBuild;
136
259
  }) => Promise<void>;
137
260
  init: (opts?: {
138
261
  ci?: boolean;
139
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>;
140
269
  }, {}> & Record<never, never>;
141
270
  //#endregion
142
271
  export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
package/dist/cli.d.mts CHANGED
@@ -1,11 +1,126 @@
1
1
  import { PluginCtx, PluginInstance } from "@moku-labs/core";
2
2
 
3
- //#region src/plugins/cli/types.d.ts
3
+ //#region src/plugins/deploy/types.d.ts
4
4
  /**
5
- * @file cli plugin type definitions (Config, Api).
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
+ * ```
6
16
  */
7
- /** Resolved configuration for the cli plugin. Flat; complete defaults so omission never yields undefined. */
17
+ type WebBuild = () => Promise<void> | Promise<{
18
+ files?: number;
19
+ }>;
20
+ /** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
8
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 = {
9
124
  /**
10
125
  * Default local dev port forwarded to deploy.dev when dev() gets no port.
11
126
  * Passed through to `wrangler dev --port <n>`.
@@ -20,29 +135,32 @@ type Api = {
20
135
  * Run the Worker locally via Wrangler (delegates to deploy.dev).
21
136
  * Defaults port to the configured value (8787) when called with no opts.
22
137
  *
23
- * @param opts - Optional port override.
138
+ * @param opts - Optional port override and web build hook.
24
139
  * @param opts.port - Local dev port to bind.
140
+ * @param opts.webBuild - Rebuild the web site on change (e.g. `() => webApp.cli.build()`).
25
141
  * @returns Resolves when the dev session ends.
26
142
  * @example
27
143
  * ```ts
28
- * await app.cli.dev(); // port 8787
29
- * await app.cli.dev({ port: 3000 }); // port 3000
144
+ * await app.cli.dev(); // port 8787, worker only
145
+ * await app.cli.dev({ webBuild: () => web.cli.build() }); // wire the web build in
30
146
  * ```
31
147
  */
32
148
  dev(opts?: {
33
149
  port?: number;
150
+ webBuild?: WebBuild;
34
151
  }): Promise<void>;
35
152
  /**
36
153
  * One-command guided Cloudflare deploy (delegates to deploy.run).
37
154
  * Forwards opts verbatim — passes undefined when called with no opts.
38
155
  *
39
- * @param opts - Optional guided/yes flags.
156
+ * @param opts - Optional guided/yes flags and a web build hook.
40
157
  * @param opts.guided - Walk through each step interactively.
41
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.
42
160
  * @returns Resolves once the deploy completes.
43
161
  * @example
44
162
  * ```ts
45
- * await app.cli.deploy({ guided: true });
163
+ * await app.cli.deploy({ guided: true, webBuild: () => web.cli.build() });
46
164
  * await app.cli.deploy({ yes: true }); // CI
47
165
  * await app.cli.deploy(); // no opts → undefined forwarded
48
166
  * ```
@@ -50,7 +168,54 @@ type Api = {
50
168
  deploy(opts?: {
51
169
  guided?: boolean;
52
170
  yes?: boolean;
171
+ webBuild?: WebBuild;
53
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>;
54
219
  };
55
220
  //#endregion
56
221
  //#region src/plugins/cli/index.d.ts
@@ -66,51 +231,7 @@ type Api = {
66
231
  *
67
232
  * @see README.md
68
233
  */
69
- declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config$1, Record<string, never>, Api, {}> & Record<never, never>;
70
- //#endregion
71
- //#region src/plugins/deploy/types.d.ts
72
- /** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
73
- type Config = {
74
- /**
75
- * Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
76
- * Also the file parsed in the universal/non-moku path.
77
- */
78
- configFile: string;
79
- /**
80
- * CI mode. When true (or when stdout is non-TTY), the guided flow NEVER prompts.
81
- * CF credentials are read from the Node env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID).
82
- * Default false.
83
- */
84
- ci: boolean;
85
- };
86
- /** Discriminated union of resource descriptors returned by each plugin's deployManifest(). */
87
- type ResourceManifest = {
88
- kind: "r2";
89
- bucket: string;
90
- upload?: string;
91
- } | {
92
- kind: "kv";
93
- binding: string;
94
- } | {
95
- kind: "d1";
96
- binding: string;
97
- migrations?: string;
98
- } | {
99
- kind: "queue";
100
- producers: string[];
101
- } | {
102
- kind: "do";
103
- bindings: Record<string, string>;
104
- };
105
- /**
106
- * The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
107
- * universal path).
108
- */
109
- type ExternalManifest = {
110
- /** Worker name. */name: string; /** Cloudflare compatibility date. */
111
- compatibilityDate: string; /** Resource descriptors to provision. */
112
- resources: ResourceManifest[];
113
- };
234
+ declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config, Record<string, never>, Api, {}> & Record<never, never>;
114
235
  //#endregion
115
236
  //#region src/plugins/deploy/index.d.ts
116
237
  /**
@@ -125,18 +246,26 @@ type ExternalManifest = {
125
246
  *
126
247
  * @see README.md
127
248
  */
128
- declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config, Record<string, never>, {
249
+ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config$1, Record<string, never>, {
129
250
  run(opts?: {
130
251
  guided?: boolean;
131
252
  yes?: boolean;
253
+ webBuild?: WebBuild;
132
254
  manifest?: ExternalManifest;
133
255
  }): Promise<void>;
134
256
  dev: (opts?: {
135
257
  port?: number;
258
+ webBuild?: WebBuild;
136
259
  }) => Promise<void>;
137
260
  init: (opts?: {
138
261
  ci?: boolean;
139
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>;
140
269
  }, {}> & Record<never, never>;
141
270
  //#endregion
142
271
  export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };