# Check that a *.stories.tsx file's argTypes cover the component's real props.
# Usage: check_controls.sh <Component.tsx> <Component.stories.tsx>
# Heuristic, not a full TS parser: pulls prop names out of the Props interface
# and flags any that never appear in an `argTypes` block in the story file.
if [[ -z "$COMPONENT" || -z "$STORY" || ! -f "$COMPONENT" || ! -f "$STORY" ]]; then
echo "Usage: $0 <Component.tsx> <Component.stories.tsx>" >&2
if ! grep -q 'argTypes' "$STORY"; then
echo "❌ no argTypes block found in $STORY"
echo "✅ argTypes block present"
props=$(awk '/interface .*Props/{flag=1; next} /^}/{flag=0} flag' "$COMPONENT" \
| grep -oE '^\s*[a-zA-Z][a-zA-Z0-9_]*\??:' | sed -E 's/[?:[:space:]]//g')
grep -q "\b${p}\s*:" "$STORY" || missing+=("$p")
if [[ ${#missing[@]} -gt 0 ]]; then
echo "❌ props with no matching argTypes entry: ${missing[*]}"
echo "✅ every declared prop has an argTypes entry (or file has no exported Props interface to check)"