@kaynooo/cli-forgejo 0.21.0 → 0.22.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.
Files changed (2) hide show
  1. package/dist/cli.js +39 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -336,13 +336,13 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
336
336
  // ../kit/src/theme.ts
337
337
  var DEFAULT = {
338
338
  colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
339
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
339
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
340
340
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
341
341
  bins: {}
342
342
  };
343
343
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
344
344
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
345
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
345
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
346
346
  var PRESETS = {
347
347
  default: {},
348
348
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -549,11 +549,38 @@ function badge(word, stream, env = process6.env) {
549
549
  const { theme } = activeTheme();
550
550
  return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
551
551
  }
552
+ function header(bin, context, stream, env = process6.env) {
553
+ if (!takesControlCodes(stream, env))
554
+ return "";
555
+ const colors = paint(stream, env);
556
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
557
+ const { theme } = activeTheme();
558
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
559
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
560
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
561
+ }
552
562
  function link(text, url, stream, env = process6.env) {
553
563
  if (takesControlCodes(stream, env))
554
564
  return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
555
565
  return text === url ? text : `${text} (${url})`;
556
566
  }
567
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
568
+ const line = header(bin, context, stream, env);
569
+ if (line !== "")
570
+ console.log(line);
571
+ }
572
+ function section(title, count, stream = process6.stdout, env = process6.env) {
573
+ const label = count === undefined ? title : `${title} (${count})`;
574
+ if (!takesControlCodes(stream, env))
575
+ return label;
576
+ const { glyphs } = activeTheme().theme;
577
+ const head = `${glyphs.corner}${glyphs.rule} ${label} `;
578
+ const width = Math.min(stream.columns ?? 60, 100);
579
+ return paint(stream, env).dim(head + glyphs.rule.repeat(Math.max(3, width - Bun.stringWidth(head))));
580
+ }
581
+ function hyperlink(text, url, stream, env = process6.env) {
582
+ return takesControlCodes(stream, env) ? link(text, url, stream, env) : text;
583
+ }
557
584
 
558
585
  // ../kit/src/format.ts
559
586
  var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
@@ -2423,7 +2450,7 @@ function dimmed(text) {
2423
2450
  }
2424
2451
  function issueNumber2(issue) {
2425
2452
  const number = role("id", process.stdout)(`#${issue.number}`);
2426
- return takesControlCodes(process.stdout) ? link(number, issue.html_url, process.stdout) : number;
2453
+ return hyperlink(number, issue.html_url, process.stdout);
2427
2454
  }
2428
2455
  function boxesLeft(issue) {
2429
2456
  const list = boxes(issue.body);
@@ -2536,6 +2563,7 @@ async function board(args) {
2536
2563
  printJson(boardJson(rows.slice(0, limit)));
2537
2564
  return 0;
2538
2565
  }
2566
+ printHeader("ft", "board");
2539
2567
  console.log(rows.length === 0 && (query !== undefined || state !== undefined) ? "no open issue matches" : renderBoard(rows, Date.now(), limit));
2540
2568
  return 0;
2541
2569
  }
@@ -3081,8 +3109,8 @@ function renderDigest(digest, now = Date.now()) {
3081
3109
  { heading: "unpushed commits", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
3082
3110
  { heading: "dirty files", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${file.path}`)) },
3083
3111
  { heading: "stale TODO comments", count: digest.stale.length, lines: capped2(digest.stale.map((todo) => `${todo.issue} closed: ${todo.comments.map((each) => `${each.path}:${each.line}`).join(", ")}`)) }
3084
- ].filter((section) => section.count > 0);
3085
- return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, count, lines }) => `${heading} (${count})
3112
+ ].filter((each) => each.count > 0);
3113
+ return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, count, lines }) => `${section(heading, count)}
3086
3114
  ${lines.join(`
3087
3115
  `).replace(LINE_START2, " ")}`).join(`
3088
3116
 
@@ -3111,10 +3139,12 @@ async function digest(args) {
3111
3139
  const rows = issues.map((issue) => ({ issue, claim: latestClaim(comments.get(issue.number) ?? [], author) }));
3112
3140
  const [unpushed, dirty, stale] = await Promise.all([quietly(unpushedCommits), quietly(dirtyTree), staleTodos()]);
3113
3141
  const summary = { ...claims(rows, sessions, me), ci: unsettled(runs, branch), unpushed, dirty, stale };
3114
- if (values.json === true)
3142
+ if (values.json === true) {
3115
3143
  printJson(summary);
3116
- else
3144
+ } else {
3145
+ printHeader("ft", "digest");
3117
3146
  console.log(renderDigest(summary));
3147
+ }
3118
3148
  return 0;
3119
3149
  }
3120
3150
 
@@ -4588,13 +4618,14 @@ async function runs(args) {
4588
4618
  printJson(list.map((run) => ({ id: run.id, number: run.index_in_repo, status: run.status, workflow: run.workflow_id, ref: run.prettyref, event: run.event, sha: run.commit_sha, seconds: runSeconds(run), started: run.started, title: run.title, url: run.html_url })));
4589
4619
  return 0;
4590
4620
  }
4621
+ printHeader("ft", "runs");
4591
4622
  if (list.length === 0) {
4592
4623
  console.log("no run");
4593
4624
  return 0;
4594
4625
  }
4595
4626
  console.log(table([
4596
4627
  ["ID", "STATUS", "WORKFLOW", "REF", "EVENT", "TOOK", "STARTED", "TITLE"],
4597
- ...list.map((run) => [String(run.id), badge(run.status, process.stdout), run.workflow_id, run.prettyref, run.event, run.duration > 0 ? formatSeconds(runSeconds(run)) : "-", startedAge(run), truncate(upTo(run.title, `
4628
+ ...list.map((run) => [hyperlink(String(run.id), run.html_url, process.stdout), badge(run.status, process.stdout), run.workflow_id, run.prettyref, run.event, run.duration > 0 ? formatSeconds(runSeconds(run)) : "-", startedAge(run), truncate(upTo(run.title, `
4598
4629
  `), TITLE_WIDTH4)])
4599
4630
  ], { header: true }));
4600
4631
  if (more > 0)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.21.0",
4
+ "version": "0.22.0",
5
5
  "description": "ft: Forgejo CI runs, logs, releases and issue checklists from the terminal, through tea.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",