@kaynooo/cli-forgejo 0.30.7 → 0.30.9

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 +29 -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
@@ -1989,12 +2000,15 @@ import { join as join6 } from "path";
1989
2000
  import process19 from "process";
1990
2001
  var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1991
2002
  var ECHOED = /username|yes\/no/i;
2003
+ var NO_PROMPTS = { GIT_TERMINAL_PROMPT: "0", GIT_ASKPASS: "", SSH_ASKPASS: "", SSH_ASKPASS_REQUIRE: "never" };
1992
2004
  var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1993
2005
  function askpass(pause = () => () => {
1994
2006
  return;
1995
2007
  }) {
1996
2008
  if (process19.stdin.isTTY !== true || process19.stderr.isTTY !== true || process19.argv[1] === undefined)
1997
- return;
2009
+ return { env: { ...NO_PROMPTS }, close: () => {
2010
+ return;
2011
+ } };
1998
2012
  const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1999
2013
  const socketPath = join6(dir, "socket");
2000
2014
  const script = join6(dir, "askpass");
@@ -3691,10 +3705,11 @@ A claim shows its boxes left, and one no live session holds also the latest comm
3691
3705
  A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs.`;
3692
3706
  var boardExits = [[0, "it listed them"], [1, "the issues cannot be read"], [2, "a usage error"]];
3693
3707
  var BOARD_LIMIT = 30;
3708
+ var INLINE_IGNORE_CASE = /^\(\?i\)/;
3694
3709
  var boardOptions = {
3695
3710
  labels: { type: "string", short: "L", description: "only issues with these labels, comma separated" },
3696
3711
  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" },
3712
+ query: { type: "string", short: "q", description: "only issues whose title matches this, a case-insensitive regex such as dom|eager" },
3698
3713
  state: { type: "string", choices: ["available", "taken", "away"], description: "only issues in this state (away: claimed, no live session here)" },
3699
3714
  ...limitOptions(BOARD_LIMIT),
3700
3715
  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 +3725,7 @@ async function board(args) {
3710
3725
  const limit = limitOf(values, BOARD_LIMIT);
3711
3726
  let query;
3712
3727
  try {
3713
- query = values.query === undefined ? undefined : new RegExp(values.query, "i");
3728
+ query = values.query === undefined ? undefined : new RegExp(values.query.replace(INLINE_IGNORE_CASE, ""), "i");
3714
3729
  } catch (error) {
3715
3730
  fail(`--query: ${error instanceof Error ? error.message : String(error)}`);
3716
3731
  }
@@ -5185,11 +5200,11 @@ ${open.map((issue) => ` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)}
5185
5200
  console.log(good(`closed milestone ${found.title}`));
5186
5201
  return 0;
5187
5202
  }
5188
- var showUsage = `ft milestone <title|id>
5203
+ var showUsage = `ft milestone [<title|id>]
5189
5204
  ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
5190
5205
  ft milestone close <title|id> [--force]
5191
5206
 
5192
- 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).
5207
+ 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.
5193
5208
  \`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id.`;
5194
5209
  var showExits = [[0, "it showed the milestone"], [1, "it cannot be read"], [2, "a usage error or an unknown milestone"]];
5195
5210
  var showOptions = {
@@ -5202,9 +5217,7 @@ async function show(args) {
5202
5217
  const { values, positionals } = parsed;
5203
5218
  const reference = positionals.join(" ").trim();
5204
5219
  if (reference === "")
5205
- fail(`name the milestone, or see them all with \`ft milestones\`
5206
-
5207
- ${showUsage}`);
5220
+ return milestones(args);
5208
5221
  const found = await findMilestone(reference, values.repo);
5209
5222
  const [issues, sessions] = await Promise.all([openIssues(undefined, values.repo, found.id), liveSessions()]);
5210
5223
  const rows = await boardRows(issues, sessions, values.repo);
@@ -5351,9 +5364,9 @@ var limits = { pushMs: 5 * 60000 };
5351
5364
  async function pushToOrigin(refspecs, onStart) {
5352
5365
  const prompts = askpass();
5353
5366
  try {
5354
- return await runTool("git push", ["git", "push", ...refspecs], { timeoutMs: limits.pushMs, onStart, env: prompts?.env });
5367
+ return await runTool("git push", ["git", "push", ...refspecs], { timeoutMs: limits.pushMs, onStart, env: prompts.env });
5355
5368
  } finally {
5356
- prompts?.close();
5369
+ prompts.close();
5357
5370
  }
5358
5371
  }
5359
5372
  var NO_RUN2 = 3 * 60000;
@@ -5905,5 +5918,5 @@ process35.exitCode = await runCli({
5905
5918
  milestone: { run: milestone, summary: "show a milestone's issues like the board, `new` creates one, `close` closes it", group: "Repo" },
5906
5919
  remote: { run: remote, summary: "check or fix an origin using an ssh alias tea cannot match", group: "Repo" }
5907
5920
  },
5908
- aliases: { show: "issue", view: "issue" }
5921
+ aliases: { show: "issue", view: "issue", issues: "board" }
5909
5922
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.30.7",
4
+ "version": "0.30.9",
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.1"
34
+ "@kaynooo/cli-kit": "0.46.2"
35
35
  }
36
36
  }