@kaynooo/cli-forgejo 0.22.0 → 0.24.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 +17 -17
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -569,14 +569,15 @@ function printHeader(bin, context, stream = process6.stdout, env = process6.env)
569
569
  if (line !== "")
570
570
  console.log(line);
571
571
  }
572
- function section(title, count, stream = process6.stdout, env = process6.env) {
572
+ function section(title, count, stream = process6.stdout, env = process6.env, tone) {
573
573
  const label = count === undefined ? title : `${title} (${count})`;
574
574
  if (!takesControlCodes(stream, env))
575
575
  return label;
576
576
  const { glyphs } = activeTheme().theme;
577
577
  const head = `${glyphs.corner}${glyphs.rule} ${label} `;
578
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))));
579
+ const rule = head + glyphs.rule.repeat(Math.max(3, width - Bun.stringWidth(head)));
580
+ return tone === undefined ? paint(stream, env).dim(rule) : tinted(paint(stream, env), activeTheme().theme.colors[tone], env)(rule);
580
581
  }
581
582
  function hyperlink(text, url, stream, env = process6.env) {
582
583
  return takesControlCodes(stream, env) ? link(text, url, stream, env) : text;
@@ -2478,11 +2479,11 @@ function renderBoard(rows, now = Date.now(), limit = Number.POSITIVE_INFINITY) {
2478
2479
  const taken = claimed("taken");
2479
2480
  const away = claimed("away");
2480
2481
  const sections = [
2481
- { heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [issueNumber2(issue), truncate(issue.title, TITLE_WIDTH), dimmed(issue.labels.map((label) => label.name).join(", "))]) },
2482
- { heading: "taken", count: taken.length, ...within(taken, limit, ({ issue, row }) => claimRow(issue, row, now)) },
2483
- { heading: "claimed, no live session here", count: away.length, ...within(away, limit, ({ issue, row }) => claimRow(issue, row, now), (line, index) => [line, ...noteLine(away[index]?.comments ?? [], now)]) }
2482
+ { heading: "available", tone: "ok", count: available.length, ...within(available, limit, ({ issue }) => [issueNumber2(issue), truncate(issue.title, TITLE_WIDTH), dimmed(issue.labels.map((label) => label.name).join(", "))]) },
2483
+ { heading: "taken", tone: "running", count: taken.length, ...within(taken, limit, ({ issue, row }) => claimRow(issue, row, now)) },
2484
+ { heading: "claimed, no live session here", tone: "warn", count: away.length, ...within(away, limit, ({ issue, row }) => claimRow(issue, row, now), (line, index) => [line, ...noteLine(away[index]?.comments ?? [], now)]) }
2484
2485
  ].filter((section) => section.count > 0);
2485
- return sections.length === 0 ? "no open issue" : sections.map(({ heading, count, lines }) => `${paint(process.stdout).bold(`${heading} (${count})`)}
2486
+ return sections.length === 0 ? "no open issue" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process.stdout, process.env, tone)}
2486
2487
  ${lines.join(`
2487
2488
  `).replace(LINE_START, " ")}`).join(`
2488
2489
 
@@ -2563,7 +2564,7 @@ async function board(args) {
2563
2564
  printJson(boardJson(rows.slice(0, limit)));
2564
2565
  return 0;
2565
2566
  }
2566
- printHeader("ft", "board");
2567
+ printHeader("ft", `${rows.length} open ${rows.length === 1 ? "issue" : "issues"}`);
2567
2568
  console.log(rows.length === 0 && (query !== undefined || state !== undefined) ? "no open issue matches" : renderBoard(rows, Date.now(), limit));
2568
2569
  return 0;
2569
2570
  }
@@ -3093,24 +3094,25 @@ async function staleTodos() {
3093
3094
  return [...byIssue.values()];
3094
3095
  }
3095
3096
  function claimLine(row, now) {
3096
- return [`#${row.number}`, row.holder, formatAge(row.since, now), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
3097
+ const id = role("id", process22.stdout);
3098
+ return [id(`#${row.number}`), row.holder, paint(process22.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
3097
3099
  }
3098
3100
  function capped2(lines) {
3099
3101
  return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
3100
3102
  }
3101
3103
  function renderDigest(digest, now = Date.now()) {
3102
3104
  const sections = [
3103
- { heading: "held by this session", count: digest.held.length, lines: table(digest.held.map((row) => claimLine(row, now))).split(`
3105
+ { heading: "held by this session", tone: "running", count: digest.held.length, lines: table(digest.held.map((row) => claimLine(row, now))).split(`
3104
3106
  `) },
3105
- { heading: "claimed, no live session here", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
3107
+ { heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
3106
3108
  `) },
3107
- { heading: "CI on the default branch", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${run.status} (run ${run.id}) ${truncate(upTo(run.title, `
3109
+ { heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process22.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
3108
3110
  `), TITLE_WIDTH2)}`) },
3109
- { heading: "unpushed commits", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
3110
- { heading: "dirty files", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${file.path}`)) },
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(", ")}`)) }
3111
+ { heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
3112
+ { heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process22.stdout)(file.path)}`)) },
3113
+ { heading: "stale TODO comments", tone: "skipped", count: digest.stale.length, lines: capped2(digest.stale.map((todo) => `${todo.issue} closed: ${todo.comments.map((each) => `${each.path}:${each.line}`).join(", ")}`)) }
3112
3114
  ].filter((each) => each.count > 0);
3113
- return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, count, lines }) => `${section(heading, count)}
3115
+ return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process22.stdout, process22.env, tone)}
3114
3116
  ${lines.join(`
3115
3117
  `).replace(LINE_START2, " ")}`).join(`
3116
3118
 
@@ -3142,7 +3144,6 @@ async function digest(args) {
3142
3144
  if (values.json === true) {
3143
3145
  printJson(summary);
3144
3146
  } else {
3145
- printHeader("ft", "digest");
3146
3147
  console.log(renderDigest(summary));
3147
3148
  }
3148
3149
  return 0;
@@ -4618,7 +4619,6 @@ async function runs(args) {
4618
4619
  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 })));
4619
4620
  return 0;
4620
4621
  }
4621
- printHeader("ft", "runs");
4622
4622
  if (list.length === 0) {
4623
4623
  console.log("no run");
4624
4624
  return 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.22.0",
4
+ "version": "0.24.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",
@@ -28,6 +28,6 @@
28
28
  "ft": "$npm_execpath src/cli.ts"
29
29
  },
30
30
  "devDependencies": {
31
- "@kaynooo/cli-kit": "0.27.1"
31
+ "@kaynooo/cli-kit": "0.29.0"
32
32
  }
33
33
  }