@kaynooo/cli-forgejo 0.30.6 → 0.30.8

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 +35 -16
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -734,11 +734,20 @@ function wholeNumber(value, name, fallback, min = 1) {
734
734
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
735
735
  return number;
736
736
  }
737
+ function durationMs(text, unit) {
738
+ if (BARE_DURATION.test(text))
739
+ return Number(text) * UNIT_MS[unit];
740
+ if (!DURATION.test(text))
741
+ return 0;
742
+ let ms = 0;
743
+ for (const [, amount, part] of text.matchAll(DURATION_PART))
744
+ ms += Number(amount) * UNIT_MS[part];
745
+ return ms;
746
+ }
737
747
  function duration(value, name, fallback, unit = "s") {
738
748
  if (value === undefined)
739
749
  return fallback;
740
- const match = DURATION.exec(value.trim());
741
- const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
750
+ const ms = durationMs(value.trim(), unit);
742
751
  if (ms < 1)
743
752
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
744
753
  return ms;
@@ -754,12 +763,14 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
754
763
  fail(`no file ${path}`);
755
764
  return file.text();
756
765
  }
757
- var WHOLE, DURATION, UNIT_MS;
766
+ var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
758
767
  var init_input = __esm(() => {
759
768
  init_args();
760
769
  WHOLE = /^\d+$/;
761
- DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
762
- UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
770
+ BARE_DURATION = /^\d+(?:\.\d+)?$/;
771
+ DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
772
+ DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
773
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
763
774
  });
764
775
 
765
776
  // ../kit/src/args.ts
@@ -3691,10 +3702,11 @@ A claim shows its boxes left, and one no live session holds also the latest comm
3691
3702
  A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs.`;
3692
3703
  var boardExits = [[0, "it listed them"], [1, "the issues cannot be read"], [2, "a usage error"]];
3693
3704
  var BOARD_LIMIT = 30;
3705
+ var INLINE_IGNORE_CASE = /^\(\?i\)/;
3694
3706
  var boardOptions = {
3695
3707
  labels: { type: "string", short: "L", description: "only issues with these labels, comma separated" },
3696
3708
  milestone: { type: "string", short: "m", description: "only issues of this milestone, a title or an id" },
3697
- query: { type: "string", description: "only issues whose title matches this, a case-insensitive regex such as dom|eager" },
3709
+ query: { type: "string", short: "q", description: "only issues whose title matches this, a case-insensitive regex such as dom|eager" },
3698
3710
  state: { type: "string", choices: ["available", "taken", "away"], description: "only issues in this state (away: claimed, no live session here)" },
3699
3711
  ...limitOptions(BOARD_LIMIT),
3700
3712
  json: jsonOption("number, title, labels, state, holder, since, session, boxesTotal, boxesLeft and note (author, at, body of the latest comment that is not a claim)"),
@@ -3710,7 +3722,7 @@ async function board(args) {
3710
3722
  const limit = limitOf(values, BOARD_LIMIT);
3711
3723
  let query;
3712
3724
  try {
3713
- query = values.query === undefined ? undefined : new RegExp(values.query, "i");
3725
+ query = values.query === undefined ? undefined : new RegExp(values.query.replace(INLINE_IGNORE_CASE, ""), "i");
3714
3726
  } catch (error) {
3715
3727
  fail(`--query: ${error instanceof Error ? error.message : String(error)}`);
3716
3728
  }
@@ -4024,16 +4036,25 @@ function overall(runs) {
4024
4036
  return pending.status;
4025
4037
  return statuses.has("success") ? "success" : "skipped";
4026
4038
  }
4039
+ async function repoRunners(repo) {
4040
+ try {
4041
+ return await repoApi("actions/runners", repo);
4042
+ } catch {
4043
+ return;
4044
+ }
4045
+ }
4027
4046
  async function stallReason(runs, repo) {
4028
4047
  const queued = runs.filter((run) => QUEUED.has(run.status));
4029
4048
  if (queued.length === 0)
4030
4049
  return;
4031
- let runners;
4050
+ let instance;
4032
4051
  try {
4033
- runners = await api("admin/actions/runners");
4052
+ instance = await api("admin/actions/runners");
4034
4053
  } catch {
4035
4054
  return;
4036
4055
  }
4056
+ const own = await repoRunners(repo);
4057
+ const runners = [...instance, ...own ?? []];
4037
4058
  const online = runners.filter((runner) => runner.status !== "offline");
4038
4059
  if (online.length === 0)
4039
4060
  return { reason: runners.length === 0 ? "no runner is registered" : `every runner is offline (${runners.map((runner) => runner.name).join(", ")})`, certain: false };
@@ -4041,7 +4062,7 @@ async function stallReason(runs, repo) {
4041
4062
  for (const job of await jobsOf(run.id, repo)) {
4042
4063
  const labels = job.runs_on ?? [];
4043
4064
  if (QUEUED.has(job.status) && !online.some((runner) => labels.every((label) => (runner.labels ?? []).includes(label))))
4044
- return { reason: `job ${job.name} of ${run.workflow_id} runs on ${labels.join(", ")}, which no online runner carries (${online.map((runner) => `${runner.name}: ${(runner.labels ?? []).join(", ")}`).join("; ")})`, certain: true };
4065
+ return { reason: `job ${job.name} of ${run.workflow_id} runs on ${labels.join(", ")}, which no online runner carries (${online.map((runner) => `${runner.name}: ${(runner.labels ?? []).join(", ")}`).join("; ")})`, certain: own !== undefined };
4045
4066
  }
4046
4067
  }
4047
4068
  return online.some((runner) => runner.status === "active") ? undefined : { reason: "no runner is working on anything: is it up?", certain: false };
@@ -5176,11 +5197,11 @@ ${open.map((issue) => ` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)}
5176
5197
  console.log(good(`closed milestone ${found.title}`));
5177
5198
  return 0;
5178
5199
  }
5179
- var showUsage = `ft milestone <title|id>
5200
+ var showUsage = `ft milestone [<title|id>]
5180
5201
  ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
5181
5202
  ft milestone close <title|id> [--force]
5182
5203
 
5183
- Shows a milestone with its open issues as \`ft board\` does: available, taken by a session running here, or claimed by one gone, each with its boxes left, at most 30 of each kind (--full for all).
5204
+ Shows a milestone with its open issues as \`ft board\` does: available, taken by a session running here, or claimed by one gone, each with its boxes left, at most 30 of each kind (--full for all); with no title or id it lists the milestones as \`ft milestones\` does.
5184
5205
  \`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id.`;
5185
5206
  var showExits = [[0, "it showed the milestone"], [1, "it cannot be read"], [2, "a usage error or an unknown milestone"]];
5186
5207
  var showOptions = {
@@ -5193,9 +5214,7 @@ async function show(args) {
5193
5214
  const { values, positionals } = parsed;
5194
5215
  const reference = positionals.join(" ").trim();
5195
5216
  if (reference === "")
5196
- fail(`name the milestone, or see them all with \`ft milestones\`
5197
-
5198
- ${showUsage}`);
5217
+ return milestones(args);
5199
5218
  const found = await findMilestone(reference, values.repo);
5200
5219
  const [issues, sessions] = await Promise.all([openIssues(undefined, values.repo, found.id), liveSessions()]);
5201
5220
  const rows = await boardRows(issues, sessions, values.repo);
@@ -5896,5 +5915,5 @@ process35.exitCode = await runCli({
5896
5915
  milestone: { run: milestone, summary: "show a milestone's issues like the board, `new` creates one, `close` closes it", group: "Repo" },
5897
5916
  remote: { run: remote, summary: "check or fix an origin using an ssh alias tea cannot match", group: "Repo" }
5898
5917
  },
5899
- aliases: { show: "issue", view: "issue" }
5918
+ aliases: { show: "issue", view: "issue", issues: "board" }
5900
5919
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.30.6",
4
+ "version": "0.30.8",
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",
@@ -31,6 +31,6 @@
31
31
  "@kaynooo/utils": "3.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@kaynooo/cli-kit": "0.46.0"
34
+ "@kaynooo/cli-kit": "0.46.2"
35
35
  }
36
36
  }