@duckflux/runner 0.6.8 → 0.7.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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@duckflux/runner",
3
- "version": "0.6.8",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "bin": {
6
- "duckflux": "dist/main.js"
6
+ "quack": "dist/main.js"
7
7
  },
8
8
  "exports": {
9
9
  ".": "./dist/index.js",
@@ -17,11 +17,11 @@
17
17
  "build": "bun build src/main.ts --outdir dist --target node --format esm --banner '#!/usr/bin/env node' && tsc --project tsconfig.build.json",
18
18
  "postbuild": "chmod +x dist/main.js",
19
19
  "prepublishOnly": "bun run build",
20
- "compile:linux-x64": "bun build --compile --target=bun-linux-x64 src/main.ts --outfile bin/duckflux-linux-x64",
21
- "compile:linux-arm64": "bun build --compile --target=bun-linux-arm64 src/main.ts --outfile bin/duckflux-linux-arm64",
22
- "compile:darwin-x64": "bun build --compile --target=bun-darwin-x64 src/main.ts --outfile bin/duckflux-darwin-x64",
23
- "compile:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/main.ts --outfile bin/duckflux-darwin-arm64",
24
- "compile:windows-x64": "bun build --compile --target=bun-windows-x64 src/main.ts --outfile bin/duckflux-windows-x64.exe",
20
+ "compile:linux-x64": "bun build --compile --target=bun-linux-x64 src/main.ts --outfile bin/quack-linux-x64",
21
+ "compile:linux-arm64": "bun build --compile --target=bun-linux-arm64 src/main.ts --outfile bin/quack-linux-arm64",
22
+ "compile:darwin-x64": "bun build --compile --target=bun-darwin-x64 src/main.ts --outfile bin/quack-darwin-x64",
23
+ "compile:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/main.ts --outfile bin/quack-darwin-arm64",
24
+ "compile:windows-x64": "bun build --compile --target=bun-windows-x64 src/main.ts --outfile bin/quack-windows-x64.exe",
25
25
  "compile": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64 && bun run compile:windows-x64"
26
26
  },
27
27
  "dependencies": {
package/src/lint.ts CHANGED
@@ -133,7 +133,7 @@ function collectSetKeys(step: unknown): string[] {
133
133
 
134
134
  export default async function lintCommand(filePath?: string): Promise<number> {
135
135
  if (!filePath) {
136
- console.error("Usage: duckflux lint <workflow.yaml>");
136
+ console.error("Usage: quack lint <workflow.yaml>");
137
137
  return 1;
138
138
  }
139
139
 
package/src/main.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  import { readFileSync } from "node:fs";
3
3
  import { parseArgs } from "node:util";
4
4
  import { dirname, resolve } from "node:path";
5
- import runCommand from "./run";
6
5
  import lintCommand from "./lint";
6
+ import runCommand from "./run";
7
+ import serverCommand from "./server";
7
8
  import validateCommand from "./validate";
8
9
 
9
10
  function getVersion(): string {
@@ -30,6 +31,10 @@ if (import.meta.main) {
30
31
  "nats-stream": { type: "string", default: "duckflux-events" },
31
32
  "redis-addr": { type: "string", default: "localhost:6379" },
32
33
  "redis-db": { type: "string", default: "0" },
34
+ "trace-dir": { type: "string" },
35
+ "trace-format": { type: "string", default: "json" },
36
+ "workflow-dir": { type: "string" },
37
+ "port": { type: "string", default: "3000" },
33
38
  },
34
39
  allowPositionals: true,
35
40
  });
@@ -50,9 +55,12 @@ if (import.meta.main) {
50
55
  const file = positionals[1];
51
56
  const exitCode = await validateCommand(file, values);
52
57
  if (typeof exitCode === "number" && exitCode !== 0) process.exit(exitCode);
58
+ } else if (cmd === "server") {
59
+ const exitCode = await serverCommand(values);
60
+ if (typeof exitCode === "number" && exitCode !== 0) process.exit(exitCode);
53
61
  } else {
54
62
  console.error("Unknown command:", cmd);
55
- console.error("Available commands: run, lint, validate, version");
63
+ console.error("Available commands: run, lint, validate, version, server");
56
64
  process.exit(1);
57
65
  }
58
66
  }
package/src/run.ts CHANGED
@@ -73,7 +73,7 @@ function parseInputFlags(arr: string[] | undefined): Record<string, unknown> {
73
73
 
74
74
  export default async function runCommand(filePath?: string, cliValues?: CLIValues): Promise<number> {
75
75
  if (!filePath) {
76
- console.error("Usage: duckflux run <workflow.yaml> [--input k=v] [--input-file file.json] [--cwd dir]");
76
+ console.error("Usage: quack run <workflow.yaml> [--input k=v] [--input-file file.json] [--cwd dir]");
77
77
  return 1;
78
78
  }
79
79
 
@@ -133,6 +133,8 @@ export default async function runCommand(filePath?: string, cliValues?: CLIValue
133
133
  cwd: cliValues?.cwd as string | undefined,
134
134
  verbose: cliValues?.verbose as boolean | undefined,
135
135
  quiet: cliValues?.quiet as boolean | undefined,
136
+ traceDir: cliValues?.["trace-dir"] as string | undefined,
137
+ traceFormat: (cliValues?.["trace-format"] as "json" | "txt" | "sqlite" | undefined) ?? "json",
136
138
  };
137
139
 
138
140
  try {
package/src/server.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { spawn, execSync } from "node:child_process";
4
+ import { createInterface } from "node:readline";
5
+
6
+ async function ensureServerPackage(cwd: string): Promise<boolean> {
7
+ const serverBin = join(cwd, "node_modules", ".bin", "duckflux-server");
8
+ const serverPkg = join(cwd, "node_modules", "@duckflux", "server");
9
+ if (existsSync(serverBin) || existsSync(serverPkg)) return true;
10
+
11
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
12
+ const answer = await new Promise<string>((resolve) => {
13
+ rl.question(
14
+ "\n@duckflux/server is not installed. Install it now? [Y/n] ",
15
+ resolve
16
+ );
17
+ });
18
+ rl.close();
19
+
20
+ if (answer.trim().toLowerCase() === "n") {
21
+ console.error("Cancelled. Run `bun add @duckflux/server -D` to install manually.");
22
+ return false;
23
+ }
24
+
25
+ console.error("Installing @duckflux/server...");
26
+ try {
27
+ execSync("bun add @duckflux/server -D", { cwd, stdio: "inherit" });
28
+ return true;
29
+ } catch {
30
+ try {
31
+ execSync("npm install @duckflux/server --save-dev", { cwd, stdio: "inherit" });
32
+ return true;
33
+ } catch {
34
+ console.error("Failed to install @duckflux/server. Please install it manually.");
35
+ return false;
36
+ }
37
+ }
38
+ }
39
+
40
+ export default async function serverCommand(
41
+ values: Record<string, unknown>
42
+ ): Promise<number> {
43
+ const cwd = (values["cwd"] as string | undefined) ?? process.cwd();
44
+ const installed = await ensureServerPackage(cwd);
45
+ if (!installed) return 1;
46
+
47
+ const args: string[] = [];
48
+ if (values["trace-dir"]) args.push("--trace-dir", values["trace-dir"] as string);
49
+ if (values["workflow-dir"]) args.push("--workflow-dir", values["workflow-dir"] as string);
50
+ if (values["port"]) args.push("--port", values["port"] as string);
51
+
52
+ const child = spawn("bunx", ["@duckflux/server", ...args], {
53
+ cwd,
54
+ stdio: "inherit",
55
+ env: process.env,
56
+ });
57
+
58
+ return new Promise((resolve) => {
59
+ child.on("error", (err) => {
60
+ console.error("Failed to start duckflux server:", err.message);
61
+ resolve(1);
62
+ });
63
+ child.on("exit", (code) => resolve(code ?? 0));
64
+ process.on("SIGINT", () => child.kill("SIGINT"));
65
+ process.on("SIGTERM", () => child.kill("SIGTERM"));
66
+ });
67
+ }
package/src/validate.ts CHANGED
@@ -8,7 +8,7 @@ type CLIValues = Record<string, any> | undefined;
8
8
 
9
9
  export default async function validateCommand(filePath?: string, cliValues?: CLIValues): Promise<number> {
10
10
  if (!filePath) {
11
- console.error("Usage: duckflux validate <workflow.yaml> [--input k=v] [--input-file file.json]");
11
+ console.error("Usage: quack validate <workflow.yaml> [--input k=v] [--input-file file.json]");
12
12
  return 1;
13
13
  }
14
14