Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(cli): remove dead 'doctor' entry from UPDATE_HINT_COMMANDS (#2541)

Joeyb01c480d024d
diff --git a/packages/cli/src/index.mjs b/packages/cli/src/index.mjs
index 7e4ba7be0b..a8359a051f 100644
--- a/packages/cli/src/index.mjs
+++ b/packages/cli/src/index.mjs
@@ -192,7 +192,7 @@ program.hook('postAction', (thisCommand, actionCommand) => {
* Only fires for commands that produce output agents read (component, docs, etc.).
* Suppressed when --json is active to avoid contaminating stdout.
*/
-const UPDATE_HINT_COMMANDS = new Set(['component', 'docs', 'doctor']);
+const UPDATE_HINT_COMMANDS = new Set(['component', 'docs']);
program.hook('postAction', (thisCommand, actionCommand) => {
if (program.opts().json) return;
try {
diff --git a/packages/cli/src/update-hint-commands.test.mjs b/packages/cli/src/update-hint-commands.test.mjs
new file mode 100644
index 0000000000..c5a5b4679b
--- /dev/null
+++ b/packages/cli/src/update-hint-commands.test.mjs
@@ -0,0 +1,41 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file Guards the update-hint command allowlist.
+ *
+ * The post-action update hint only fires for a small set of commands
+ * (see UPDATE_HINT_COMMANDS in index.mjs). Every name in that set must
+ * map to a real, registered command — otherwise the entry is dead and
+ * the hint can never fire for it. This test imports the assembled
+ * program and verifies the invariant so a stale reference (like the
+ * removed 'doctor' entry) can't creep back in.
+ */
+
+import {describe, it, expect} from 'vitest';
+import {program} from './index.mjs';
+
+/** Commands the update hint is expected to fire for. */
+const HINTED_COMMANDS = ['component', 'docs'];
+
+/** Commands that have never existed and must not be referenced. */
+const NONEXISTENT_COMMANDS = ['doctor'];
+
+function registeredCommandNames() {
+ return program.commands.map((c) => c.name());
+}
+
+describe('update hint commands', () => {
+ it('fires only for real, registered commands', () => {
+ const registered = new Set(registeredCommandNames());
+ for (const name of HINTED_COMMANDS) {
+ expect(registered.has(name)).toBe(true);
+ }
+ });
+
+ it('does not register a "doctor" command (dead update-hint reference)', () => {
+ const registered = new Set(registeredCommandNames());
+ for (const name of NONEXISTENT_COMMANDS) {
+ expect(registered.has(name)).toBe(false);
+ }
+ });
+});