Skip to content

fix(diff): include components in token diff and remove dead import - #51

Merged
davideast merged 1 commit into
google-labs-code:mainfrom
Saatvik-GT:fix/diff-add-components
May 2, 2026
Merged

fix(diff): include components in token diff and remove dead import#51
davideast merged 1 commit into
google-labs-code:mainfrom
Saatvik-GT:fix/diff-add-components

Conversation

@Saatvik-GT

Copy link
Copy Markdown
Contributor

Fixes #50

The diff command compared colors, typography, rounded, and spacing tokens
between two DESIGN.md files, but silently skipped components entirely. Any
change to a component — added, removed, or modified properties like
backgroundColor or padding — produced no output in the diff. There was
also a dead serializeDesignSystem import that was never called.

Root Cause

In commands/diff.ts, the tokens object is built by passing each
DesignSystemState map through diffMaps. The components map was simply
never included. ComponentDef stores its properties in a nested Map, which
JSON.stringify serializes as {}, so it could not be passed to diffMaps
directly without first being flattened.

Fix

Added a serializeComponents helper that converts Map<string, ComponentDef>
into Map<string, Record<string, unknown>> by flattening each component's
properties via Object.fromEntries. The result is passed to the existing
diffMaps utility, consistent with how all other token groups are diffed.
Also removed the unused serializeDesignSystem import.

Tests

Added diff.test.ts (previously did not exist) with 4 cases:

  • Identical files produce no component changes
  • Added component is reported under added
  • Removed component is reported under removed
  • Modified component property is reported under modified

All 207 tests pass.

The diff command compared colors, typography, rounded, and spacing but
silently skipped components — changes to button styles, added/removed
component tokens, etc. were invisible in the output.

- Add `components` field to the tokens diff using a local serializer
  that flattens ComponentDef.properties Maps into plain objects before
  passing them to the existing diffMaps utility
- Remove the unused `serializeDesignSystem` import
- Add diff.test.ts with 4 cases: no-change, added, removed, modified
@davideast
davideast merged commit 654f4c1 into google-labs-code:main May 2, 2026
3 checks passed
@davideast

Copy link
Copy Markdown
Collaborator

Thank you so much @Saatvik-GT!

@Saatvik-GT

Copy link
Copy Markdown
Contributor Author

Thank you so much @Saatvik-GT!

Glad it landed! Happy to contribute more :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: diff command silently omits components from token comparison

2 participants