@wervt/cli 0.2.3 → 0.2.4

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/index.mjs CHANGED
@@ -493,6 +493,61 @@ const tokens = defineCommand({
493
493
  }
494
494
  }
495
495
  });
496
+ const tasks = defineCommand({
497
+ meta: {
498
+ name: "tasks",
499
+ description: "List an app's tasks and schedules, or run one now"
500
+ },
501
+ args: {
502
+ app: {
503
+ type: "positional",
504
+ required: true,
505
+ description: "App name"
506
+ },
507
+ run: {
508
+ type: "string",
509
+ description: "Run this task now and wait for it"
510
+ },
511
+ payload: {
512
+ type: "string",
513
+ description: "JSON payload for --run"
514
+ },
515
+ json: {
516
+ type: "boolean",
517
+ description: "Print JSON"
518
+ },
519
+ ...connection
520
+ },
521
+ async run({ args }) {
522
+ if (args.run) {
523
+ const payload = args.payload ? JSON.parse(args.payload) : {};
524
+ const result = await (await api(`/v1/apps/${args.app}/tasks/${encodeURIComponent(args.run)}/run`, args, {
525
+ method: "POST",
526
+ headers: { "content-type": "application/json" },
527
+ body: JSON.stringify({ payload })
528
+ })).json();
529
+ if (args.json) console.log(JSON.stringify(result));
530
+ else {
531
+ const color = result.status === "ok" ? "green" : result.status === "error" ? "red" : "yellow";
532
+ const took = result.durationMs === void 0 ? "" : ` in ${result.durationMs} ms`;
533
+ console.log(`${styleText(color, result.status)}${took}${result.error ? `: ${result.error}` : ""}`);
534
+ if (result.result !== void 0 && result.result !== null) console.log(JSON.stringify(result.result, null, 2));
535
+ }
536
+ if (result.status !== "ok") process.exitCode = 1;
537
+ return;
538
+ }
539
+ const list = await (await api(`/v1/apps/${args.app}/tasks`, args)).json();
540
+ if (args.json) return console.log(JSON.stringify(list));
541
+ if (!list.tasks.length) return console.log(`${args.app} has no tasks.`);
542
+ console.log(styleText("dim", `Schedules in ${list.timezone}`));
543
+ for (const task of list.tasks) {
544
+ const schedules = task.schedules.length ? task.schedules.map((s) => `${s.cron}${s.next ? styleText("dim", ` (next ${s.next})`) : ""}`).join(", ") : styleText("dim", "manual only");
545
+ console.log(`${styleText("bold", task.name)}${task.running ? styleText("cyan", " running") : ""} ${schedules}`);
546
+ if (task.description) console.log(` ${styleText("dim", task.description)}`);
547
+ }
548
+ console.log(styleText("dim", `\nRecent runs: wervt logs ${args.app} 'type:=Task' --since 1d`));
549
+ }
550
+ });
496
551
  const remove = defineCommand({
497
552
  meta: {
498
553
  name: "delete",
@@ -762,6 +817,7 @@ runMain(defineCommand({
762
817
  access,
763
818
  env,
764
819
  tokens,
820
+ tasks,
765
821
  delete: remove,
766
822
  login,
767
823
  whoami,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wervt/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Deploy and manage apps on wervt.",
5
5
  "keywords": [
6
6
  "agents",
package/skill/SKILL.md CHANGED
@@ -33,7 +33,8 @@ cd <name>
33
33
  The app comes with `AGENTS.md`, skills in `.claude/skills/` and a deploy workflow. **Read
34
34
  `AGENTS.md` before writing code** and follow it: server routes, valibot validation, Drizzle schema
35
35
  and migrations, live data with shapes, users, logging, and what the isolate runtime can't do
36
- (no filesystem, no child processes, no long-running work, no WebSockets, no cron).
36
+ (no filesystem, no child processes, no long-running work, no WebSockets). Periodic work goes
37
+ into tasks (`defineTask` + `nitro.scheduledTasks`), which wervt runs on schedule.
37
38
 
38
39
  Before picking a name, run `wervt apps` so you don't overwrite an existing app. If the user named an
39
40
  existing app, work in its repository instead.
@@ -90,6 +91,8 @@ release lists the commit.
90
91
  pnpm exec wervt apps # every app, active release, URL
91
92
  pnpm exec wervt releases <name> # newest first, with commit and author
92
93
  pnpm exec wervt logs <name> 'status:>=500' --since 1d --json
94
+ pnpm exec wervt tasks <name> # tasks, schedules, next runs
95
+ pnpm exec wervt tasks <name> --run <task> # run one now
93
96
  pnpm exec wervt rollback <name> # the previous release (migrations stay)
94
97
  ```
95
98