@moku-labs/worker 0.2.1 → 0.3.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.cjs +23 -17
- package/dist/cli.mjs +23 -17
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
24
|
const require_storage = require("./storage-CgXl-dUA.cjs");
|
|
25
|
+
let _moku_labs_common_cli = require("@moku-labs/common/cli");
|
|
25
26
|
let node_child_process = require("node:child_process");
|
|
26
27
|
let node_fs_promises = require("node:fs/promises");
|
|
27
28
|
let node_path = require("node:path");
|
|
@@ -691,58 +692,59 @@ const createCliApi = (ctx) => ({
|
|
|
691
692
|
//#endregion
|
|
692
693
|
//#region src/plugins/cli/handlers.ts
|
|
693
694
|
/**
|
|
694
|
-
* Builds the hook handlers that turn global deploy events into a live progress TUI
|
|
695
|
-
*
|
|
696
|
-
* the
|
|
695
|
+
* Builds the hook handlers that turn global deploy events into a live progress TUI.
|
|
696
|
+
* Each logs a clean, prefix-free message via `ctx.log`; the branded log sink (installed
|
|
697
|
+
* by the cli plugin's onInit from `@moku-labs/common/cli`) adds the `›` marker, brand
|
|
698
|
+
* color, and stderr routing. Pure observers — print and return; never mutate state,
|
|
699
|
+
* never block the deploy pipeline (fire-and-forget, spec/07 §3,§4).
|
|
697
700
|
*
|
|
698
701
|
* @param ctx - CLI plugin context with injected log core API.
|
|
699
702
|
* @returns Hook map for the three global deploy events.
|
|
700
703
|
* @example
|
|
701
704
|
* ```ts
|
|
702
705
|
* const hooks = createCliHooks(ctx);
|
|
703
|
-
* hooks["deploy:phase"]({ phase: "detect" }); // logs "
|
|
704
|
-
* hooks["provision:resource"]({ kind: "kv", name: "KV" }); // logs "
|
|
705
|
-
* hooks["deploy:complete"]({ url: "https://x.workers.dev" }); //
|
|
706
|
+
* hooks["deploy:phase"]({ phase: "detect" }); // logs "detect" → renders " › detect"
|
|
707
|
+
* hooks["provision:resource"]({ kind: "kv", name: "KV" }); // logs "kv KV" → " › kv KV"
|
|
708
|
+
* hooks["deploy:complete"]({ url: "https://x.workers.dev" }); // "deployed → https://x.workers.dev"
|
|
706
709
|
* ```
|
|
707
710
|
*/
|
|
708
711
|
const createCliHooks = (ctx) => ({
|
|
709
712
|
/**
|
|
710
|
-
*
|
|
713
|
+
* Log one clean line per pipeline phase: "phase" or "phase · detail".
|
|
711
714
|
*
|
|
712
715
|
* @param p - The deploy:phase event payload.
|
|
713
716
|
* @example
|
|
714
717
|
* ```ts
|
|
715
|
-
* handler({ phase: "detect" }); // "
|
|
716
|
-
* handler({ phase: "upload", detail: "3 files" }); // "
|
|
718
|
+
* handler({ phase: "detect" }); // "detect"
|
|
719
|
+
* handler({ phase: "upload", detail: "3 files" }); // "upload · 3 files"
|
|
717
720
|
* ```
|
|
718
721
|
*/
|
|
719
722
|
"deploy:phase"(p) {
|
|
720
|
-
|
|
721
|
-
ctx.log.info(`> ${p.phase}${detail}`);
|
|
723
|
+
ctx.log.info(p.detail ? `${p.phase} · ${p.detail}` : p.phase);
|
|
722
724
|
},
|
|
723
725
|
/**
|
|
724
|
-
*
|
|
726
|
+
* Log one clean line per provisioned resource: "kind name".
|
|
725
727
|
*
|
|
726
728
|
* @param p - The provision:resource event payload.
|
|
727
729
|
* @example
|
|
728
730
|
* ```ts
|
|
729
|
-
* handler({ kind: "kv", name: "KV" }); // "
|
|
731
|
+
* handler({ kind: "kv", name: "KV" }); // "kv KV"
|
|
730
732
|
* ```
|
|
731
733
|
*/
|
|
732
734
|
"provision:resource"(p) {
|
|
733
|
-
ctx.log.info(
|
|
735
|
+
ctx.log.info(`${p.kind} ${p.name}`);
|
|
734
736
|
},
|
|
735
737
|
/**
|
|
736
|
-
*
|
|
738
|
+
* Log the terminal success line with the deployed URL.
|
|
737
739
|
*
|
|
738
740
|
* @param p - The deploy:complete event payload.
|
|
739
741
|
* @example
|
|
740
742
|
* ```ts
|
|
741
|
-
* handler({ url: "https://my-worker.workers.dev" }); // "
|
|
743
|
+
* handler({ url: "https://my-worker.workers.dev" }); // "deployed → https://my-worker.workers.dev"
|
|
742
744
|
* ```
|
|
743
745
|
*/
|
|
744
746
|
"deploy:complete"(p) {
|
|
745
|
-
ctx.log.info(`
|
|
747
|
+
ctx.log.info(`deployed → ${p.url}`);
|
|
746
748
|
}
|
|
747
749
|
});
|
|
748
750
|
/**
|
|
@@ -760,6 +762,10 @@ const createCliHooks = (ctx) => ({
|
|
|
760
762
|
const cliPlugin = require_storage.createPlugin("cli", {
|
|
761
763
|
depends: [deployPlugin],
|
|
762
764
|
config: { port: 8787 },
|
|
765
|
+
onInit: (ctx) => {
|
|
766
|
+
ctx.log.clearSinks();
|
|
767
|
+
ctx.log.addSink((0, _moku_labs_common_cli.brandedSink)("info"));
|
|
768
|
+
},
|
|
763
769
|
api: (ctx) => createCliApi(ctx),
|
|
764
770
|
hooks: (ctx) => createCliHooks(ctx)
|
|
765
771
|
});
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { i as durableObjectsPlugin, n as queuesPlugin, o as d1Plugin, r as kvPlugin, t as storagePlugin, u as createPlugin } from "./storage-COo-F38H.mjs";
|
|
2
|
+
import { brandedSink } from "@moku-labs/common/cli";
|
|
2
3
|
import { spawn } from "node:child_process";
|
|
3
4
|
import { readdir, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
@@ -667,58 +668,59 @@ const createCliApi = (ctx) => ({
|
|
|
667
668
|
//#endregion
|
|
668
669
|
//#region src/plugins/cli/handlers.ts
|
|
669
670
|
/**
|
|
670
|
-
* Builds the hook handlers that turn global deploy events into a live progress TUI
|
|
671
|
-
*
|
|
672
|
-
* the
|
|
671
|
+
* Builds the hook handlers that turn global deploy events into a live progress TUI.
|
|
672
|
+
* Each logs a clean, prefix-free message via `ctx.log`; the branded log sink (installed
|
|
673
|
+
* by the cli plugin's onInit from `@moku-labs/common/cli`) adds the `›` marker, brand
|
|
674
|
+
* color, and stderr routing. Pure observers — print and return; never mutate state,
|
|
675
|
+
* never block the deploy pipeline (fire-and-forget, spec/07 §3,§4).
|
|
673
676
|
*
|
|
674
677
|
* @param ctx - CLI plugin context with injected log core API.
|
|
675
678
|
* @returns Hook map for the three global deploy events.
|
|
676
679
|
* @example
|
|
677
680
|
* ```ts
|
|
678
681
|
* const hooks = createCliHooks(ctx);
|
|
679
|
-
* hooks["deploy:phase"]({ phase: "detect" }); // logs "
|
|
680
|
-
* hooks["provision:resource"]({ kind: "kv", name: "KV" }); // logs "
|
|
681
|
-
* hooks["deploy:complete"]({ url: "https://x.workers.dev" }); //
|
|
682
|
+
* hooks["deploy:phase"]({ phase: "detect" }); // logs "detect" → renders " › detect"
|
|
683
|
+
* hooks["provision:resource"]({ kind: "kv", name: "KV" }); // logs "kv KV" → " › kv KV"
|
|
684
|
+
* hooks["deploy:complete"]({ url: "https://x.workers.dev" }); // "deployed → https://x.workers.dev"
|
|
682
685
|
* ```
|
|
683
686
|
*/
|
|
684
687
|
const createCliHooks = (ctx) => ({
|
|
685
688
|
/**
|
|
686
|
-
*
|
|
689
|
+
* Log one clean line per pipeline phase: "phase" or "phase · detail".
|
|
687
690
|
*
|
|
688
691
|
* @param p - The deploy:phase event payload.
|
|
689
692
|
* @example
|
|
690
693
|
* ```ts
|
|
691
|
-
* handler({ phase: "detect" }); // "
|
|
692
|
-
* handler({ phase: "upload", detail: "3 files" }); // "
|
|
694
|
+
* handler({ phase: "detect" }); // "detect"
|
|
695
|
+
* handler({ phase: "upload", detail: "3 files" }); // "upload · 3 files"
|
|
693
696
|
* ```
|
|
694
697
|
*/
|
|
695
698
|
"deploy:phase"(p) {
|
|
696
|
-
|
|
697
|
-
ctx.log.info(`> ${p.phase}${detail}`);
|
|
699
|
+
ctx.log.info(p.detail ? `${p.phase} · ${p.detail}` : p.phase);
|
|
698
700
|
},
|
|
699
701
|
/**
|
|
700
|
-
*
|
|
702
|
+
* Log one clean line per provisioned resource: "kind name".
|
|
701
703
|
*
|
|
702
704
|
* @param p - The provision:resource event payload.
|
|
703
705
|
* @example
|
|
704
706
|
* ```ts
|
|
705
|
-
* handler({ kind: "kv", name: "KV" }); // "
|
|
707
|
+
* handler({ kind: "kv", name: "KV" }); // "kv KV"
|
|
706
708
|
* ```
|
|
707
709
|
*/
|
|
708
710
|
"provision:resource"(p) {
|
|
709
|
-
ctx.log.info(
|
|
711
|
+
ctx.log.info(`${p.kind} ${p.name}`);
|
|
710
712
|
},
|
|
711
713
|
/**
|
|
712
|
-
*
|
|
714
|
+
* Log the terminal success line with the deployed URL.
|
|
713
715
|
*
|
|
714
716
|
* @param p - The deploy:complete event payload.
|
|
715
717
|
* @example
|
|
716
718
|
* ```ts
|
|
717
|
-
* handler({ url: "https://my-worker.workers.dev" }); // "
|
|
719
|
+
* handler({ url: "https://my-worker.workers.dev" }); // "deployed → https://my-worker.workers.dev"
|
|
718
720
|
* ```
|
|
719
721
|
*/
|
|
720
722
|
"deploy:complete"(p) {
|
|
721
|
-
ctx.log.info(`
|
|
723
|
+
ctx.log.info(`deployed → ${p.url}`);
|
|
722
724
|
}
|
|
723
725
|
});
|
|
724
726
|
/**
|
|
@@ -736,6 +738,10 @@ const createCliHooks = (ctx) => ({
|
|
|
736
738
|
const cliPlugin = createPlugin("cli", {
|
|
737
739
|
depends: [deployPlugin],
|
|
738
740
|
config: { port: 8787 },
|
|
741
|
+
onInit: (ctx) => {
|
|
742
|
+
ctx.log.clearSinks();
|
|
743
|
+
ctx.log.addSink(brandedSink("info"));
|
|
744
|
+
},
|
|
739
745
|
api: (ctx) => createCliApi(ctx),
|
|
740
746
|
hooks: (ctx) => createCliHooks(ctx)
|
|
741
747
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moku-labs/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Cloudflare Worker framework for Moku — Durable Objects, Queues, R2, D1, and KV plugins that compose with Moku Web.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"test:coverage": "vitest run --project unit --project integration --coverage"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@moku-labs/common": "0.
|
|
65
|
+
"@moku-labs/common": "0.2.0",
|
|
66
66
|
"@moku-labs/core": "0.1.4"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|