@moku-labs/worker 0.8.0 → 0.9.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-DkoPBbJC.cjs → cli-CfgYgnzW.cjs} +356 -62
- package/dist/{cli-By06KF-9.mjs → cli-Cs3R3Jhr.mjs} +356 -62
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{index-BuY9o1u0.d.cts → index-Cb3vzZte.d.cts} +99 -13
- package/dist/{index-BuY9o1u0.d.mts → index-Cb3vzZte.d.mts} +99 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -102,6 +102,42 @@ type WorkerPluginCtx<Config, State, Events extends Record<string, unknown> = Rec
|
|
|
102
102
|
* ```
|
|
103
103
|
*/
|
|
104
104
|
type WebBuild = () => Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* A per-change INCREMENTAL rebuild hook wired in from the consumer's dev script — e.g.
|
|
107
|
+
* `(changes) => webApp.cli.update(changes)`. The fast counterpart to {@link WebBuild}: `dev`
|
|
108
|
+
* calls {@link WebBuild} ONCE for the cold build, then (when this hook is wired) calls `onChange`
|
|
109
|
+
* with the set of paths changed in the debounce window so the web build can rebuild only what
|
|
110
|
+
* changed instead of doing a full `webBuild()` every keystroke. Omit it and `dev` keeps doing a
|
|
111
|
+
* full `webBuild()` per change (the prior behavior). Like {@link WebBuild} it may resolve ANYTHING
|
|
112
|
+
* (the web build's own summary); the value is read opportunistically for a `files` count.
|
|
113
|
+
*
|
|
114
|
+
* @param changes - The paths changed since the last rebuild (the watcher's debounced set).
|
|
115
|
+
* @returns Resolves when the incremental rebuild completes.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* await server.cli.dev({ webBuild: () => web.cli.build(), onChange: changes => web.cli.update(changes) });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type OnChange = (changes: readonly string[]) => Promise<unknown>;
|
|
122
|
+
/**
|
|
123
|
+
* The remote seed wired into `deploy({ seed: true })`: which SQL file to load into the REMOTE D1
|
|
124
|
+
* AFTER a successful deploy (+ migration), and which cached KV keys to clear afterwards so the app
|
|
125
|
+
* rebuilds them from the freshly-seeded rows. Declarative — the deploy plugin runs no app code, so
|
|
126
|
+
* the app-specific seed lives in `pluginConfigs.deploy.seed` (config) rather than a deploy hook.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* deploy: { seed: { file: "db/seed.sql", resetKv: [{ binding: "BOARDS_KV", key: "boards:index" }] } }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
type SeedConfig = {
|
|
134
|
+
/** SQL file executed against the remote D1 (e.g. "db/seed.sql"). */file: string; /** The d1 binding to target when more than one database is configured (e.g. "DB"); the sole one otherwise. */
|
|
135
|
+
binding?: string; /** Cached KV keys to delete after seeding so reads rebuild from the freshly-seeded DB. */
|
|
136
|
+
resetKv?: {
|
|
137
|
+
binding: string;
|
|
138
|
+
key: string;
|
|
139
|
+
}[];
|
|
140
|
+
};
|
|
105
141
|
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
106
142
|
type Config$1 = {
|
|
107
143
|
/**
|
|
@@ -152,6 +188,12 @@ type Config$1 = {
|
|
|
152
188
|
buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
|
|
153
189
|
migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
|
|
154
190
|
debounceMs: number;
|
|
191
|
+
/**
|
|
192
|
+
* The remote seed `deploy({ seed: true })` loads AFTER a successful deploy (+ migration): the SQL
|
|
193
|
+
* file and the cached KV keys to reset. Omit it and `deploy({ seed: true })` reports a clear
|
|
194
|
+
* "no seed configured" error instead of silently doing nothing.
|
|
195
|
+
*/
|
|
196
|
+
seed?: SeedConfig;
|
|
155
197
|
};
|
|
156
198
|
/**
|
|
157
199
|
* Discriminated union of per-INSTANCE resource descriptors. Each resource plugin's `deployManifest()`
|
|
@@ -232,6 +274,32 @@ type ProvisionResult = {
|
|
|
232
274
|
failed: ProvisionFailure[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
|
|
233
275
|
ids: Record<string, string>;
|
|
234
276
|
};
|
|
277
|
+
/**
|
|
278
|
+
* Structured outcome of a deploy run (the value `run()` / `cli.deploy()` now resolve to, replacing
|
|
279
|
+
* the old `void`) so a script can branch on the result instead of guessing from a thrown error. It
|
|
280
|
+
* is also WHY the post-deploy migration + seed live inside `run()`: the report's `status` is the
|
|
281
|
+
* single source of truth for whether the worker actually went live, so those remote-DB steps run
|
|
282
|
+
* only on a successful deploy and never on an aborted one.
|
|
283
|
+
*
|
|
284
|
+
* `ok` is true only when the worker is live AND every requested post-step (migration, seed) also
|
|
285
|
+
* succeeded. `status` is the coarse outcome: `"deployed"` (live, all post-steps ok), `"aborted"`
|
|
286
|
+
* (a gate was declined or auth was never set up — nothing shipped), `"failed"` (a step errored).
|
|
287
|
+
*/
|
|
288
|
+
type DeployReport = {
|
|
289
|
+
/** True only when the worker is live and every requested post-step (migration, seed) succeeded. */ok: boolean; /** Coarse outcome: "deployed" (live + post-steps ok), "aborted" (a gate declined / auth not set up), "failed" (a step errored). */
|
|
290
|
+
status: "deployed" | "aborted" | "failed"; /** The resolved deploy stage (resource-name suffix; "production" is bare). */
|
|
291
|
+
stage: string; /** The live worker URL once `wrangler deploy` succeeded — set even if a later migration/seed failed. */
|
|
292
|
+
url?: string; /** Provisioning tally: resources created, already-existing, and failed to create. */
|
|
293
|
+
resources?: {
|
|
294
|
+
created: number;
|
|
295
|
+
exists: number;
|
|
296
|
+
failed: number;
|
|
297
|
+
}; /** Remote D1 migration outcome — "skipped" (not requested), "applied", or "failed". */
|
|
298
|
+
migration: "skipped" | "applied" | "failed"; /** Remote seed outcome — "skipped" (not requested), "applied", or "failed". */
|
|
299
|
+
seed: "skipped" | "applied" | "failed"; /** Wall-clock duration of the whole run (ms). */
|
|
300
|
+
elapsedMs: number; /** Branded failure message(s) — empty when `ok`; one per failed step otherwise. */
|
|
301
|
+
errors: string[];
|
|
302
|
+
};
|
|
235
303
|
/** Result of verifying the `.env` Cloudflare API token and resolving its account. */
|
|
236
304
|
type AuthStatus = {
|
|
237
305
|
/** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
|
|
@@ -268,46 +336,60 @@ type Api = {
|
|
|
268
336
|
* when omitted. A failure renders a branded `✗` line and sets a non-zero exit code rather than
|
|
269
337
|
* throwing a raw stack trace.
|
|
270
338
|
*
|
|
271
|
-
* @param opts - Optional port, stage, and
|
|
339
|
+
* @param opts - Optional port, stage, cold-build hook, and incremental change hook.
|
|
272
340
|
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
273
341
|
* @param opts.stage - Stage for the generated wrangler config's resource names. Falls back to the
|
|
274
342
|
* `--stage` CLI flag, then the app's configured stage. Pass it explicitly from a script for a
|
|
275
343
|
* self-documenting `dev({ stage })` instead of relying on the hidden flag.
|
|
276
|
-
* @param opts.webBuild -
|
|
344
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
345
|
+
* per-change rebuild when `onChange` is omitted.
|
|
346
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
347
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
|
|
348
|
+
* @param opts.seed - Load the configured seed (`pluginConfigs.deploy.seed`) into the LOCAL D1 and
|
|
349
|
+
* reset its cached KV keys before serving — the local analogue of `deploy({ seed: true })`.
|
|
277
350
|
* @returns Resolves when the dev session ends.
|
|
278
351
|
* @example
|
|
279
352
|
* ```ts
|
|
280
|
-
* await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build() });
|
|
353
|
+
* await app.cli.dev({ stage: "dev", port: 7878, seed: true, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
281
354
|
* ```
|
|
282
355
|
*/
|
|
283
356
|
dev(opts?: {
|
|
284
357
|
port?: number;
|
|
285
358
|
stage?: string;
|
|
286
359
|
webBuild?: WebBuild;
|
|
360
|
+
onChange?: OnChange;
|
|
361
|
+
seed?: boolean;
|
|
287
362
|
}): Promise<void>;
|
|
288
363
|
/**
|
|
289
|
-
* One-command Cloudflare deploy (delegates to deploy.run)
|
|
290
|
-
*
|
|
291
|
-
*
|
|
364
|
+
* One-command Cloudflare deploy (delegates to deploy.run), then — only on a successful deploy —
|
|
365
|
+
* the requested post-deploy remote steps (migration, seed). Guided/interactive by default; pass
|
|
366
|
+
* `{ ci: true }` for the automated/non-interactive path (CI). Unlike the other verbs this RETURNS
|
|
367
|
+
* the structured {@link DeployReport} (so a script can branch on the outcome) AND, on a failure,
|
|
368
|
+
* renders a branded `✗` line + sets a non-zero exit code rather than throwing a raw stack trace.
|
|
292
369
|
*
|
|
293
|
-
* @param opts - Optional ci flag, stage,
|
|
370
|
+
* @param opts - Optional ci flag, stage, a web build hook, and the post-deploy migration/seed flags.
|
|
294
371
|
* @param opts.ci - Automated mode: never prompts, auto-confirms. Omit/false → guided on a TTY.
|
|
295
372
|
* @param opts.stage - Stage for the generated wrangler config's resource names (e.g. "production",
|
|
296
373
|
* "staging"). Falls back to the `--stage` CLI flag, then the app's configured stage. Pass it
|
|
297
374
|
* explicitly from a script for a self-documenting `deploy({ stage })` instead of the hidden flag.
|
|
298
375
|
* @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
|
|
299
|
-
* @
|
|
376
|
+
* @param opts.migration - Apply pending remote D1 migrations after a successful deploy (skipped on abort).
|
|
377
|
+
* @param opts.seed - Load the configured remote seed (`pluginConfigs.deploy.seed`) after a
|
|
378
|
+
* successful deploy (+ migration); skipped on an aborted deploy.
|
|
379
|
+
* @returns The deploy report (status, url, resource tally, migration/seed outcome, errors).
|
|
300
380
|
* @example
|
|
301
381
|
* ```ts
|
|
302
|
-
* await app.cli.deploy({
|
|
303
|
-
*
|
|
382
|
+
* const report = await app.cli.deploy({ webBuild: () => web.cli.build(), migration: true, seed: true });
|
|
383
|
+
* if (report.status === "aborted") return; // creds not set up yet — nothing shipped
|
|
304
384
|
* ```
|
|
305
385
|
*/
|
|
306
386
|
deploy(opts?: {
|
|
307
387
|
ci?: boolean;
|
|
308
388
|
stage?: string;
|
|
309
389
|
webBuild?: WebBuild;
|
|
310
|
-
|
|
390
|
+
migration?: boolean;
|
|
391
|
+
seed?: boolean;
|
|
392
|
+
}): Promise<DeployReport>;
|
|
311
393
|
/**
|
|
312
394
|
* Seed a configured D1 database from a SQL file (delegates to deploy.seed). Local by default
|
|
313
395
|
* (applies the database's migrations first so its tables exist, then executes the file);
|
|
@@ -410,11 +492,15 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
|
|
|
410
492
|
stage?: string;
|
|
411
493
|
webBuild?: WebBuild;
|
|
412
494
|
manifest?: ExternalManifest;
|
|
413
|
-
|
|
495
|
+
migration?: boolean;
|
|
496
|
+
seed?: boolean;
|
|
497
|
+
}): Promise<DeployReport>;
|
|
414
498
|
dev(opts?: {
|
|
415
499
|
port?: number;
|
|
416
500
|
stage?: string;
|
|
417
501
|
webBuild?: WebBuild;
|
|
502
|
+
onChange?: OnChange;
|
|
503
|
+
seed?: boolean;
|
|
418
504
|
}): Promise<void>;
|
|
419
505
|
seed(sqlFile: string, opts?: {
|
|
420
506
|
stage?: string;
|
|
@@ -433,4 +519,4 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
|
|
|
433
519
|
wrangler: (args: string[]) => Promise<void>;
|
|
434
520
|
}, {}> & Record<never, never>;
|
|
435
521
|
//#endregion
|
|
436
|
-
export {
|
|
522
|
+
export { ResourceManifest as a, WorkerEnv as c, ExternalManifest as i, WorkerEvents as l, cliPlugin as n, SeedConfig as o, DeployReport as r, WorkerConfig as s, deployPlugin as t, WorkerPluginCtx as u };
|
|
@@ -102,6 +102,42 @@ type WorkerPluginCtx<Config, State, Events extends Record<string, unknown> = Rec
|
|
|
102
102
|
* ```
|
|
103
103
|
*/
|
|
104
104
|
type WebBuild = () => Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* A per-change INCREMENTAL rebuild hook wired in from the consumer's dev script — e.g.
|
|
107
|
+
* `(changes) => webApp.cli.update(changes)`. The fast counterpart to {@link WebBuild}: `dev`
|
|
108
|
+
* calls {@link WebBuild} ONCE for the cold build, then (when this hook is wired) calls `onChange`
|
|
109
|
+
* with the set of paths changed in the debounce window so the web build can rebuild only what
|
|
110
|
+
* changed instead of doing a full `webBuild()` every keystroke. Omit it and `dev` keeps doing a
|
|
111
|
+
* full `webBuild()` per change (the prior behavior). Like {@link WebBuild} it may resolve ANYTHING
|
|
112
|
+
* (the web build's own summary); the value is read opportunistically for a `files` count.
|
|
113
|
+
*
|
|
114
|
+
* @param changes - The paths changed since the last rebuild (the watcher's debounced set).
|
|
115
|
+
* @returns Resolves when the incremental rebuild completes.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* await server.cli.dev({ webBuild: () => web.cli.build(), onChange: changes => web.cli.update(changes) });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type OnChange = (changes: readonly string[]) => Promise<unknown>;
|
|
122
|
+
/**
|
|
123
|
+
* The remote seed wired into `deploy({ seed: true })`: which SQL file to load into the REMOTE D1
|
|
124
|
+
* AFTER a successful deploy (+ migration), and which cached KV keys to clear afterwards so the app
|
|
125
|
+
* rebuilds them from the freshly-seeded rows. Declarative — the deploy plugin runs no app code, so
|
|
126
|
+
* the app-specific seed lives in `pluginConfigs.deploy.seed` (config) rather than a deploy hook.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* deploy: { seed: { file: "db/seed.sql", resetKv: [{ binding: "BOARDS_KV", key: "boards:index" }] } }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
type SeedConfig = {
|
|
134
|
+
/** SQL file executed against the remote D1 (e.g. "db/seed.sql"). */file: string; /** The d1 binding to target when more than one database is configured (e.g. "DB"); the sole one otherwise. */
|
|
135
|
+
binding?: string; /** Cached KV keys to delete after seeding so reads rebuild from the freshly-seeded DB. */
|
|
136
|
+
resetKv?: {
|
|
137
|
+
binding: string;
|
|
138
|
+
key: string;
|
|
139
|
+
}[];
|
|
140
|
+
};
|
|
105
141
|
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
106
142
|
type Config$1 = {
|
|
107
143
|
/**
|
|
@@ -152,6 +188,12 @@ type Config$1 = {
|
|
|
152
188
|
buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
|
|
153
189
|
migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
|
|
154
190
|
debounceMs: number;
|
|
191
|
+
/**
|
|
192
|
+
* The remote seed `deploy({ seed: true })` loads AFTER a successful deploy (+ migration): the SQL
|
|
193
|
+
* file and the cached KV keys to reset. Omit it and `deploy({ seed: true })` reports a clear
|
|
194
|
+
* "no seed configured" error instead of silently doing nothing.
|
|
195
|
+
*/
|
|
196
|
+
seed?: SeedConfig;
|
|
155
197
|
};
|
|
156
198
|
/**
|
|
157
199
|
* Discriminated union of per-INSTANCE resource descriptors. Each resource plugin's `deployManifest()`
|
|
@@ -232,6 +274,32 @@ type ProvisionResult = {
|
|
|
232
274
|
failed: ProvisionFailure[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
|
|
233
275
|
ids: Record<string, string>;
|
|
234
276
|
};
|
|
277
|
+
/**
|
|
278
|
+
* Structured outcome of a deploy run (the value `run()` / `cli.deploy()` now resolve to, replacing
|
|
279
|
+
* the old `void`) so a script can branch on the result instead of guessing from a thrown error. It
|
|
280
|
+
* is also WHY the post-deploy migration + seed live inside `run()`: the report's `status` is the
|
|
281
|
+
* single source of truth for whether the worker actually went live, so those remote-DB steps run
|
|
282
|
+
* only on a successful deploy and never on an aborted one.
|
|
283
|
+
*
|
|
284
|
+
* `ok` is true only when the worker is live AND every requested post-step (migration, seed) also
|
|
285
|
+
* succeeded. `status` is the coarse outcome: `"deployed"` (live, all post-steps ok), `"aborted"`
|
|
286
|
+
* (a gate was declined or auth was never set up — nothing shipped), `"failed"` (a step errored).
|
|
287
|
+
*/
|
|
288
|
+
type DeployReport = {
|
|
289
|
+
/** True only when the worker is live and every requested post-step (migration, seed) succeeded. */ok: boolean; /** Coarse outcome: "deployed" (live + post-steps ok), "aborted" (a gate declined / auth not set up), "failed" (a step errored). */
|
|
290
|
+
status: "deployed" | "aborted" | "failed"; /** The resolved deploy stage (resource-name suffix; "production" is bare). */
|
|
291
|
+
stage: string; /** The live worker URL once `wrangler deploy` succeeded — set even if a later migration/seed failed. */
|
|
292
|
+
url?: string; /** Provisioning tally: resources created, already-existing, and failed to create. */
|
|
293
|
+
resources?: {
|
|
294
|
+
created: number;
|
|
295
|
+
exists: number;
|
|
296
|
+
failed: number;
|
|
297
|
+
}; /** Remote D1 migration outcome — "skipped" (not requested), "applied", or "failed". */
|
|
298
|
+
migration: "skipped" | "applied" | "failed"; /** Remote seed outcome — "skipped" (not requested), "applied", or "failed". */
|
|
299
|
+
seed: "skipped" | "applied" | "failed"; /** Wall-clock duration of the whole run (ms). */
|
|
300
|
+
elapsedMs: number; /** Branded failure message(s) — empty when `ok`; one per failed step otherwise. */
|
|
301
|
+
errors: string[];
|
|
302
|
+
};
|
|
235
303
|
/** Result of verifying the `.env` Cloudflare API token and resolving its account. */
|
|
236
304
|
type AuthStatus = {
|
|
237
305
|
/** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
|
|
@@ -268,46 +336,60 @@ type Api = {
|
|
|
268
336
|
* when omitted. A failure renders a branded `✗` line and sets a non-zero exit code rather than
|
|
269
337
|
* throwing a raw stack trace.
|
|
270
338
|
*
|
|
271
|
-
* @param opts - Optional port, stage, and
|
|
339
|
+
* @param opts - Optional port, stage, cold-build hook, and incremental change hook.
|
|
272
340
|
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
273
341
|
* @param opts.stage - Stage for the generated wrangler config's resource names. Falls back to the
|
|
274
342
|
* `--stage` CLI flag, then the app's configured stage. Pass it explicitly from a script for a
|
|
275
343
|
* self-documenting `dev({ stage })` instead of relying on the hidden flag.
|
|
276
|
-
* @param opts.webBuild -
|
|
344
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
345
|
+
* per-change rebuild when `onChange` is omitted.
|
|
346
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
347
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
|
|
348
|
+
* @param opts.seed - Load the configured seed (`pluginConfigs.deploy.seed`) into the LOCAL D1 and
|
|
349
|
+
* reset its cached KV keys before serving — the local analogue of `deploy({ seed: true })`.
|
|
277
350
|
* @returns Resolves when the dev session ends.
|
|
278
351
|
* @example
|
|
279
352
|
* ```ts
|
|
280
|
-
* await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build() });
|
|
353
|
+
* await app.cli.dev({ stage: "dev", port: 7878, seed: true, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
281
354
|
* ```
|
|
282
355
|
*/
|
|
283
356
|
dev(opts?: {
|
|
284
357
|
port?: number;
|
|
285
358
|
stage?: string;
|
|
286
359
|
webBuild?: WebBuild;
|
|
360
|
+
onChange?: OnChange;
|
|
361
|
+
seed?: boolean;
|
|
287
362
|
}): Promise<void>;
|
|
288
363
|
/**
|
|
289
|
-
* One-command Cloudflare deploy (delegates to deploy.run)
|
|
290
|
-
*
|
|
291
|
-
*
|
|
364
|
+
* One-command Cloudflare deploy (delegates to deploy.run), then — only on a successful deploy —
|
|
365
|
+
* the requested post-deploy remote steps (migration, seed). Guided/interactive by default; pass
|
|
366
|
+
* `{ ci: true }` for the automated/non-interactive path (CI). Unlike the other verbs this RETURNS
|
|
367
|
+
* the structured {@link DeployReport} (so a script can branch on the outcome) AND, on a failure,
|
|
368
|
+
* renders a branded `✗` line + sets a non-zero exit code rather than throwing a raw stack trace.
|
|
292
369
|
*
|
|
293
|
-
* @param opts - Optional ci flag, stage,
|
|
370
|
+
* @param opts - Optional ci flag, stage, a web build hook, and the post-deploy migration/seed flags.
|
|
294
371
|
* @param opts.ci - Automated mode: never prompts, auto-confirms. Omit/false → guided on a TTY.
|
|
295
372
|
* @param opts.stage - Stage for the generated wrangler config's resource names (e.g. "production",
|
|
296
373
|
* "staging"). Falls back to the `--stage` CLI flag, then the app's configured stage. Pass it
|
|
297
374
|
* explicitly from a script for a self-documenting `deploy({ stage })` instead of the hidden flag.
|
|
298
375
|
* @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
|
|
299
|
-
* @
|
|
376
|
+
* @param opts.migration - Apply pending remote D1 migrations after a successful deploy (skipped on abort).
|
|
377
|
+
* @param opts.seed - Load the configured remote seed (`pluginConfigs.deploy.seed`) after a
|
|
378
|
+
* successful deploy (+ migration); skipped on an aborted deploy.
|
|
379
|
+
* @returns The deploy report (status, url, resource tally, migration/seed outcome, errors).
|
|
300
380
|
* @example
|
|
301
381
|
* ```ts
|
|
302
|
-
* await app.cli.deploy({
|
|
303
|
-
*
|
|
382
|
+
* const report = await app.cli.deploy({ webBuild: () => web.cli.build(), migration: true, seed: true });
|
|
383
|
+
* if (report.status === "aborted") return; // creds not set up yet — nothing shipped
|
|
304
384
|
* ```
|
|
305
385
|
*/
|
|
306
386
|
deploy(opts?: {
|
|
307
387
|
ci?: boolean;
|
|
308
388
|
stage?: string;
|
|
309
389
|
webBuild?: WebBuild;
|
|
310
|
-
|
|
390
|
+
migration?: boolean;
|
|
391
|
+
seed?: boolean;
|
|
392
|
+
}): Promise<DeployReport>;
|
|
311
393
|
/**
|
|
312
394
|
* Seed a configured D1 database from a SQL file (delegates to deploy.seed). Local by default
|
|
313
395
|
* (applies the database's migrations first so its tables exist, then executes the file);
|
|
@@ -410,11 +492,15 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
|
|
|
410
492
|
stage?: string;
|
|
411
493
|
webBuild?: WebBuild;
|
|
412
494
|
manifest?: ExternalManifest;
|
|
413
|
-
|
|
495
|
+
migration?: boolean;
|
|
496
|
+
seed?: boolean;
|
|
497
|
+
}): Promise<DeployReport>;
|
|
414
498
|
dev(opts?: {
|
|
415
499
|
port?: number;
|
|
416
500
|
stage?: string;
|
|
417
501
|
webBuild?: WebBuild;
|
|
502
|
+
onChange?: OnChange;
|
|
503
|
+
seed?: boolean;
|
|
418
504
|
}): Promise<void>;
|
|
419
505
|
seed(sqlFile: string, opts?: {
|
|
420
506
|
stage?: string;
|
|
@@ -433,4 +519,4 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
|
|
|
433
519
|
wrangler: (args: string[]) => Promise<void>;
|
|
434
520
|
}, {}> & Record<never, never>;
|
|
435
521
|
//#endregion
|
|
436
|
-
export {
|
|
522
|
+
export { ResourceManifest as a, WorkerEnv as c, ExternalManifest as i, WorkerEvents as l, cliPlugin as n, SeedConfig as o, DeployReport as r, WorkerConfig as s, deployPlugin as t, WorkerPluginCtx as u };
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cli = require("./cli-
|
|
2
|
+
const require_cli = require("./cli-CfgYgnzW.cjs");
|
|
3
3
|
let _moku_labs_common = require("@moku-labs/common");
|
|
4
4
|
//#region src/env-provider.ts
|
|
5
5
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as ResourceManifest, c as WorkerEnv, i as ExternalManifest, l as WorkerEvents, n as cliPlugin, o as SeedConfig, r as DeployReport, s as WorkerConfig, t as deployPlugin, u as WorkerPluginCtx } from "./index-Cb3vzZte.cjs";
|
|
2
2
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
3
|
import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
|
|
4
4
|
|
|
@@ -1237,4 +1237,4 @@ declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku
|
|
|
1237
1237
|
*/
|
|
1238
1238
|
declare const createApp: typeof boundCreateApp;
|
|
1239
1239
|
//#endregion
|
|
1240
|
-
export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
|
|
1240
|
+
export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type DeployReport, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type SeedConfig, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as ResourceManifest, c as WorkerEnv, i as ExternalManifest, l as WorkerEvents, n as cliPlugin, o as SeedConfig, r as DeployReport, s as WorkerConfig, t as deployPlugin, u as WorkerPluginCtx } from "./index-Cb3vzZte.mjs";
|
|
2
2
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
3
|
import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
|
|
4
4
|
|
|
@@ -1237,4 +1237,4 @@ declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku
|
|
|
1237
1237
|
*/
|
|
1238
1238
|
declare const createApp: typeof boundCreateApp;
|
|
1239
1239
|
//#endregion
|
|
1240
|
-
export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
|
|
1240
|
+
export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type DeployReport, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type SeedConfig, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as kvPlugin, c as d1Plugin, d as createCore, f as createPlugin$1, i as queuesPlugin, l as bindingsPlugin, n as deployPlugin, o as durableObjectsPlugin, p as stagePlugin, r as storagePlugin, s as defineDurableObject, t as cliPlugin, u as coreConfig } from "./cli-
|
|
1
|
+
import { a as kvPlugin, c as d1Plugin, d as createCore, f as createPlugin$1, i as queuesPlugin, l as bindingsPlugin, n as deployPlugin, o as durableObjectsPlugin, p as stagePlugin, r as storagePlugin, s as defineDurableObject, t as cliPlugin, u as coreConfig } from "./cli-Cs3R3Jhr.mjs";
|
|
2
2
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
3
|
//#region src/env-provider.ts
|
|
4
4
|
/**
|
package/package.json
CHANGED