Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 3x 17x 4x 13x 13x 3x 4x 23x 3x 6x 3x 14x 3x 13x 3x 13x 3x 14x 14x 1x 1x | import { matchesIssue, matchesLabel, type SearchableIssue } from "./search.ts";
interface ProjectSummary {
title: string;
number: number;
url: string;
}
type ProjectSource = "live" | "cache" | "empty";
type PickIssue = SearchableIssue & {
url: string;
};
interface IssueOption<T> {
value: T | PickIssue;
label: string;
hint?: string;
}
export const projectLoad = (live: ProjectSummary[], online: boolean): ProjectSource => {
if (live.length > 0) return "live";
return online ? "empty" : "cache";
};
/** No `back` means a single board, where going back would only reopen the same list. */
export const issueOptions = <T>(back: T | undefined, issues: PickIssue[]): IssueOption<T>[] => [
...(back === undefined ? [] : [{ value: back, label: "← Back to project list" }]),
...issues.map((issue) => ({
value: issue,
label: `#${issue.number} ${issue.title}`,
hint: [issue.labels.join(", "), issue.url].filter(Boolean).join(" · "),
})),
];
export const issueOptionMatches = <T>(back: T, value: T | PickIssue, search: string): boolean =>
value === back ? !search.trim() : matchesIssue(value as PickIssue, search);
export const optionalSelection = (value: string): string | undefined => value || undefined;
export const labelOptionMatches = (
noneValue: string,
option: { value: string; hint?: string },
search: string,
): boolean =>
option.value === noneValue
? !search.trim()
: matchesLabel({ name: option.value, description: option.hint ?? "" }, search);
export const issueCountMessage = (count: number): string =>
`${count} open issue${count === 1 ? "" : "s"}.`;
interface IssuePromptText {
message: string;
placeholder: string | undefined;
emptyWarning: string | undefined;
}
export const issuePromptText = (count: number): IssuePromptText =>
count === 0
? {
message: "No open issues",
placeholder: undefined,
emptyWarning: "Nothing open on that project. `pnpm issue:add` fixes that.",
}
: {
message: "Issue",
placeholder: "Type a number, a word from the title, or a label",
emptyWarning: undefined,
};
export const selectedProject = (
projects: ProjectSummary[],
title: string,
): ProjectSummary | undefined => projects.find((project) => project.title === title);
/** Why a pick is refused, or null when every blocked-by link is closed; `--force` skips the check. */
export const blockedPickMessage = (
issue: number,
blockers: { number: number; title: string; state: string }[],
): string | null => {
const open = blockers.filter(({ state }) => state === "OPEN");
if (open.length === 0) return null;
const list = open.map(({ number, title }) => `#${number} ${title}`).join(", ");
return `#${issue} is blocked by ${list}. Take one of those first, or pass --force.`;
};
|