All files / infrastructure/scripts/src/issue/adapters prompts.ts

100% Statements 10/10
100% Branches 2/2
100% Functions 4/4
100% Lines 8/8

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      3x   3x       3x       3x   3x 47x   3x 14x          
import type { Label, Project } from "./gh.ts";
 
/** An empty pick, which `createIssue` turns into an omitted flag rather than an empty one. */
const NONE = "";
 
export const NONE_OPTION = { value: NONE, label: "— none —" };
 
/** An empty project list often means the GitHub token lacks the `project` scope. */
export const PROJECT_SCOPE_HINT =
    "No open projects. If you expected some, the `project` scope is missing: gh auth refresh -s project";
 
/** `listIssues` reads `projectItems`, which needs the same scope as the project list itself. */
export const ISSUE_SCOPE_HINT =
    "Couldn't read issues — the `project` scope is likely missing: gh auth refresh -s project";
 
export const projectOptions = (projects: Project[]): { value: string; label: string }[] =>
    projects.map(({ title }) => ({ value: title, label: title }));
 
export const labelOptions = (labels: Label[]): { value: string; label: string; hint?: string }[] =>
    labels.map(({ name, description }) => ({
        value: name,
        label: name,
        hint: description || undefined,
    }));