@openworkflow/cli 0.4.2 → 0.4.3
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.js +1 -0
- package/dist/commands.d.ts +26 -2
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +37 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,6 +35,7 @@ workerCmd
|
|
|
35
35
|
program
|
|
36
36
|
.command("dashboard")
|
|
37
37
|
.description("start the dashboard to view workflow runs")
|
|
38
|
+
.option("-p, --port <number>", "custom port for the dashboard server", Number.parseInt)
|
|
38
39
|
.option("--config <path>", "path to OpenWorkflow config file")
|
|
39
40
|
.action(withErrorHandling(dashboard));
|
|
40
41
|
await program.parseAsync(process.argv);
|
package/dist/commands.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { WorkerConfig } from "./config.js";
|
|
|
2
2
|
interface CommandOptions {
|
|
3
3
|
config?: string;
|
|
4
4
|
}
|
|
5
|
+
interface DashboardOptions extends CommandOptions {
|
|
6
|
+
port?: number;
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* openworkflow -V | --version
|
|
7
10
|
* @returns the version string, or "-" if it cannot be determined
|
|
@@ -26,9 +29,30 @@ export declare function workerStart(options?: WorkerStartOptions): Promise<void>
|
|
|
26
29
|
/**
|
|
27
30
|
* openworkflow dashboard
|
|
28
31
|
* Starts the dashboard by delegating to `@openworkflow/dashboard` via npx.
|
|
29
|
-
* @param
|
|
32
|
+
* @param port - Optional dashboard port.
|
|
33
|
+
* @returns Spawn configuration for launching the dashboard process.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getDashboardSpawnOptions(port?: number): {
|
|
36
|
+
command: string;
|
|
37
|
+
args: string[];
|
|
38
|
+
spawnOptions: {
|
|
39
|
+
stdio: "inherit";
|
|
40
|
+
env?: NodeJS.ProcessEnv;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Validate dashboard port option.
|
|
45
|
+
* @param port - Optional dashboard port.
|
|
46
|
+
* @returns Validated dashboard port.
|
|
47
|
+
* @throws {CLIError} If the provided port is not an integer in the 1-65535 range.
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateDashboardPort(port?: number): number | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Start the dashboard process.
|
|
52
|
+
* @param options - Dashboard command options.
|
|
53
|
+
* @returns Resolves when the dashboard process exits.
|
|
30
54
|
*/
|
|
31
|
-
export declare function dashboard(options?:
|
|
55
|
+
export declare function dashboard(options?: DashboardOptions): Promise<void>;
|
|
32
56
|
/**
|
|
33
57
|
* Discover workflow files from directories. Recursively scans directories for
|
|
34
58
|
* workflow files with supported extensions (.ts, .js, .mjs, .cjs).
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAC;AAiC3E,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAoBnC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoItE;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmDxE;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,cAAc,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAuEf;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,OAAO,GAAE,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../commands.ts"],"names":[],"m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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAsBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAKR"}
|
package/dist/commands.js
CHANGED
|
@@ -247,20 +247,52 @@ export async function workerStart(options = {}) {
|
|
|
247
247
|
/**
|
|
248
248
|
* openworkflow dashboard
|
|
249
249
|
* Starts the dashboard by delegating to `@openworkflow/dashboard` via npx.
|
|
250
|
-
* @param
|
|
250
|
+
* @param port - Optional dashboard port.
|
|
251
|
+
* @returns Spawn configuration for launching the dashboard process.
|
|
252
|
+
*/
|
|
253
|
+
export function getDashboardSpawnOptions(port) {
|
|
254
|
+
return {
|
|
255
|
+
command: "npx",
|
|
256
|
+
args: ["@openworkflow/dashboard"],
|
|
257
|
+
spawnOptions: {
|
|
258
|
+
stdio: "inherit",
|
|
259
|
+
env: port === undefined
|
|
260
|
+
? process.env
|
|
261
|
+
: { ...process.env, PORT: String(port) },
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Validate dashboard port option.
|
|
267
|
+
* @param port - Optional dashboard port.
|
|
268
|
+
* @returns Validated dashboard port.
|
|
269
|
+
* @throws {CLIError} If the provided port is not an integer in the 1-65535 range.
|
|
270
|
+
*/
|
|
271
|
+
export function validateDashboardPort(port) {
|
|
272
|
+
if (port === undefined) {
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
if (!Number.isInteger(port) || port < 1 || port > 65_535) {
|
|
276
|
+
throw new CLIError("Invalid dashboard port.", "Use an integer between 1 and 65535, for example `--port 3001`.");
|
|
277
|
+
}
|
|
278
|
+
return port;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Start the dashboard process.
|
|
282
|
+
* @param options - Dashboard command options.
|
|
283
|
+
* @returns Resolves when the dashboard process exits.
|
|
251
284
|
*/
|
|
252
285
|
export async function dashboard(options = {}) {
|
|
253
286
|
const configPath = options.config;
|
|
287
|
+
const port = validateDashboardPort(options.port);
|
|
254
288
|
consola.start("Starting dashboard...");
|
|
255
289
|
const { configFile } = await loadConfigWithEnv(configPath);
|
|
256
290
|
if (!configFile) {
|
|
257
291
|
throw new CLIError("No config file found.", "Run `npx @openworkflow/cli init` to create a config file before starting the dashboard.");
|
|
258
292
|
}
|
|
259
293
|
consola.info(`Using config: ${configFile}`);
|
|
260
|
-
|
|
261
|
-
const child = spawn(
|
|
262
|
-
stdio: "inherit",
|
|
263
|
-
});
|
|
294
|
+
const spawnConfig = getDashboardSpawnOptions(port);
|
|
295
|
+
const child = spawn(spawnConfig.command, spawnConfig.args, spawnConfig.spawnOptions);
|
|
264
296
|
await new Promise((resolve, reject) => {
|
|
265
297
|
/** remove signal handlers after the child exits */
|
|
266
298
|
function cleanupSignalHandlers() {
|