Skip to content

Commit 8eebcf3

Browse files
committed
test: cover local prerequisite handling exclusions
1 parent 362e256 commit 8eebcf3

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

src/cli/prerequisites.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ export type CommandPrerequisiteContract = {
5252
readonly rules: readonly CommandPrerequisiteRule[];
5353
};
5454

55+
/**
56+
* A user-facing command that is intentionally handled outside the shared
57+
* prerequisite interception matrix.
58+
*/
59+
export type LocalPrerequisiteHandling = {
60+
readonly command: string;
61+
readonly reason: string;
62+
};
63+
5564
export const PREREQUISITE_CHECKS = [
5665
{
5766
id: "docker_cli",
@@ -619,10 +628,53 @@ export const COMMANDS_THAT_INVOKE_PREREQUISITE_CHECKS = [
619628
),
620629
] as const;
621630

631+
export const COMMANDS_WITH_LOCAL_PREREQUISITE_HANDLING = [
632+
{
633+
command: "x github connect",
634+
reason:
635+
"GitHub connect is already the primary repair/bootstrap path, so it should keep command-local validation instead of redirecting into shared interception.",
636+
},
637+
{
638+
command: "linear setup",
639+
reason:
640+
"Linear setup is a local project wiring command that can run before auth or profile state exists, so it should stay outside the shared interception matrix.",
641+
},
642+
{
643+
command: "x github disconnect",
644+
reason:
645+
"Disconnect only removes stored local auth material and should keep command-local validation.",
646+
},
647+
{
648+
command: "linear disconnect",
649+
reason:
650+
"Disconnect only removes stored local auth material and should keep command-local validation.",
651+
},
652+
{
653+
command: "linear assignee-mappings",
654+
reason:
655+
"Assignee mapping inspection should continue to rely on command-local validation rather than shared prerequisite interception.",
656+
},
657+
{
658+
command: "linear project-unlink",
659+
reason:
660+
"Project unlink is local cleanup state and should not be hidden behind shared setup guidance.",
661+
},
662+
] as const satisfies readonly LocalPrerequisiteHandling[];
663+
622664
export function getCommandPrerequisiteContracts(input: {
623665
readonly command: string;
624666
}): readonly CommandPrerequisiteContract[] {
625667
return COMMAND_PREREQUISITE_CONTRACTS.filter((contract) =>
626668
contract.commands.includes(input.command)
627669
);
628670
}
671+
672+
export function getLocalPrerequisiteHandling(input: {
673+
readonly command: string;
674+
}): LocalPrerequisiteHandling | null {
675+
return (
676+
COMMANDS_WITH_LOCAL_PREREQUISITE_HANDLING.find(
677+
(entry) => entry.command === input.command
678+
) ?? null
679+
);
680+
}

tests/prerequisites-matrix.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { expect, test } from "bun:test";
33
import {
44
COMMAND_PREREQUISITE_CONTRACTS,
55
COMMANDS_THAT_INVOKE_PREREQUISITE_CHECKS,
6+
COMMANDS_WITH_LOCAL_PREREQUISITE_HANDLING,
67
getCommandPrerequisiteContracts,
8+
getLocalPrerequisiteHandling,
79
PREREQUISITE_CHECKS,
810
} from "../src/cli/prerequisites.ts";
911

@@ -150,6 +152,26 @@ test("cleanup and local-config commands stay out of shared prerequisite intercep
150152
).toEqual([]);
151153
});
152154

155+
test("major setup commands can be explicitly excluded from shared interception", () => {
156+
expect(
157+
COMMANDS_WITH_LOCAL_PREREQUISITE_HANDLING.map((entry) => entry.command)
158+
).toEqual([
159+
"x github connect",
160+
"linear setup",
161+
"x github disconnect",
162+
"linear disconnect",
163+
"linear assignee-mappings",
164+
"linear project-unlink",
165+
]);
166+
167+
expect(
168+
getLocalPrerequisiteHandling({ command: "x github connect" })?.reason
169+
).toContain("primary repair/bootstrap path");
170+
expect(
171+
getLocalPrerequisiteHandling({ command: "linear setup" })?.reason
172+
).toContain("local project wiring command");
173+
});
174+
153175
test("broker-backed linear commands guide through Hack auth", () => {
154176
const [connections] = getCommandPrerequisiteContracts({
155177
command: "linear connections",

0 commit comments

Comments
 (0)