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 | 1x 8x 2x 5x 5x 1x 2x 2x 12x | import { KIND_LABELS, type WorkflowMap } from "./filing.ts";
import { CAPABILITY_LABEL_PREFIX } from "./snapshot.ts";
interface SetupPlan {
/** Null when the milestone already exists. */
milestone: string | null;
labels: string[];
}
/** Every label filing this project's switched-on, unsettled blocks will put on a ticket. */
const labelsFor = (map: WorkflowMap): string[] => {
const blocks = map.blocks.filter((block) => map.isOn(block) && !map.settled.has(block.id));
return [
...new Set([
...(map.area ? [map.area] : []),
...blocks.map(({ kind }) => KIND_LABELS[kind]),
...blocks.map(({ id }) => `${CAPABILITY_LABEL_PREFIX}${id}`),
]),
];
};
/** What has to exist on GitHub before `sync` can read the project and `file` can label its tickets. */
export const setupPlan = (
map: WorkflowMap,
existing: { milestone: boolean; labels: string[] },
): SetupPlan => {
const have = new Set(existing.labels);
return {
milestone: existing.milestone ? null : map.milestone,
labels: labelsFor(map).filter((label) => !have.has(label)),
};
};
|