@kaynooo/cli-forgejo 0.17.0 → 0.18.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/dist/cli.js +22 -9
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -549,6 +549,11 @@ 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 link(text, url, stream, env = process6.env) {
|
|
553
|
+
if (takesControlCodes(stream, env))
|
|
554
|
+
return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
|
|
555
|
+
return text === url ? text : `${text} (${url})`;
|
|
556
|
+
}
|
|
552
557
|
|
|
553
558
|
// ../kit/src/format.ts
|
|
554
559
|
var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
@@ -1110,25 +1115,28 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
1110
1115
|
} };
|
|
1111
1116
|
const write = stream.write.bind(stream);
|
|
1112
1117
|
let frame = 0;
|
|
1113
|
-
let drawn =
|
|
1118
|
+
let drawn = [];
|
|
1119
|
+
const columns = () => stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns;
|
|
1120
|
+
const rowsDrawn = () => drawn.reduce((sum, width) => sum + Math.max(1, Math.ceil(width / columns())), 0);
|
|
1114
1121
|
const clear = () => {
|
|
1115
|
-
if (drawn > 0)
|
|
1116
|
-
write(`${CLEAR_LINE}${LINE_UP.repeat(
|
|
1117
|
-
drawn =
|
|
1122
|
+
if (drawn.length > 0)
|
|
1123
|
+
write(`${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}`);
|
|
1124
|
+
drawn = [];
|
|
1118
1125
|
};
|
|
1119
1126
|
const draw = () => {
|
|
1120
|
-
const width = (
|
|
1127
|
+
const width = columns() - 1;
|
|
1121
1128
|
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1122
1129
|
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
1123
1130
|
if (lines.length === 0) {
|
|
1124
1131
|
clear();
|
|
1125
1132
|
return;
|
|
1126
1133
|
}
|
|
1127
|
-
write(`${drawn > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(
|
|
1134
|
+
write(`${drawn.length > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}` : CLEAR_LINE}${lines.join(`
|
|
1128
1135
|
`)}`);
|
|
1129
|
-
drawn = lines.
|
|
1136
|
+
drawn = lines.map((line) => Bun.stringWidth(line));
|
|
1130
1137
|
};
|
|
1131
1138
|
const timer = setInterval(draw, FRAME_MS);
|
|
1139
|
+
stream.on?.("resize", draw);
|
|
1132
1140
|
const restore = interceptOutput(clear);
|
|
1133
1141
|
const release = swallowInput();
|
|
1134
1142
|
const onExit = () => {
|
|
@@ -1138,6 +1146,7 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
1138
1146
|
const signals = holdSignals(stop);
|
|
1139
1147
|
function stop() {
|
|
1140
1148
|
clearInterval(timer);
|
|
1149
|
+
stream.off?.("resize", draw);
|
|
1141
1150
|
clear();
|
|
1142
1151
|
restore();
|
|
1143
1152
|
release();
|
|
@@ -2323,6 +2332,10 @@ var STATES = new Set(["available", "taken", "away"]);
|
|
|
2323
2332
|
function dimmed(text) {
|
|
2324
2333
|
return text === "" ? "" : paint(process.stdout).dim(text);
|
|
2325
2334
|
}
|
|
2335
|
+
function issueNumber2(issue) {
|
|
2336
|
+
const number = role("id", process.stdout)(`#${issue.number}`);
|
|
2337
|
+
return takesControlCodes(process.stdout) ? link(number, issue.html_url, process.stdout) : number;
|
|
2338
|
+
}
|
|
2326
2339
|
function boxesLeft(issue) {
|
|
2327
2340
|
const list = boxes(issue.body);
|
|
2328
2341
|
return list.length === 0 ? "" : `${list.filter((box) => !box.done).length}/${list.length} left`;
|
|
@@ -2330,7 +2343,7 @@ function boxesLeft(issue) {
|
|
|
2330
2343
|
function claimRow(issue, row, now) {
|
|
2331
2344
|
const holder = row.state === "taken" && row.session.name !== row.claim.holder ? `${row.claim.holder} via ${row.session.name}` : row.claim.holder;
|
|
2332
2345
|
const status = row.state === "taken" ? ` (${row.session.status})` : "";
|
|
2333
|
-
return [
|
|
2346
|
+
return [issueNumber2(issue), `${holder}${status}`, paint(process.stdout).dim(formatAge(row.claim.at, now)), boxesLeft(issue), truncate(issue.title, TITLE_WIDTH)];
|
|
2334
2347
|
}
|
|
2335
2348
|
function noteLine(comments, now) {
|
|
2336
2349
|
const note = latestNote(comments);
|
|
@@ -2349,7 +2362,7 @@ function renderBoard(rows, now = Date.now(), limit = Number.POSITIVE_INFINITY) {
|
|
|
2349
2362
|
const taken = claimed("taken");
|
|
2350
2363
|
const away = claimed("away");
|
|
2351
2364
|
const sections = [
|
|
2352
|
-
{ heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [
|
|
2365
|
+
{ heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [issueNumber2(issue), truncate(issue.title, TITLE_WIDTH), dimmed(issue.labels.map((label) => label.name).join(", "))]) },
|
|
2353
2366
|
{ heading: "taken", count: taken.length, ...within(taken, limit, ({ issue, row }) => claimRow(issue, row, now)) },
|
|
2354
2367
|
{ 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)]) }
|
|
2355
2368
|
].filter((section) => section.count > 0);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-forgejo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.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.
|
|
31
|
+
"@kaynooo/cli-kit": "0.23.0"
|
|
32
32
|
}
|
|
33
33
|
}
|