Repository navigation
fix(diff): include motion tokens in the token diff - #197
Draft
dajiaohuang wants to merge 1 commit into
Draft
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
`diff` builds `tokens` from colors, typography, rounded, spacing, and components. The `motion` category added in google-labs-code#182 was never wired in, so a motion token that changed, was added, or was removed between two files produced no output at all. The fix passes both motion maps through the existing `diffMaps` helper, next to the other primitive categories. `motion` is optional on `DesignSystemState`, so an absent map is compared as empty. Tests cover a modified token, added and removed tokens, and the identical case through `diffCommand.run`; all three fail on the previous `diff.ts`. The README `diff` output example gains the `motion` key so the documented shape matches the emitted one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
design.md diffreportstokens.colors,tokens.typography,tokens.rounded,tokens.spacing, andtokens.components. It never reportedmotion. Themotiontoken category was added to the spec, the parser, and the model in #182, and the linter resolves it (state.motionis aMap<string, ResolvedMotion>), but thediffcommand was not updated with it. A motion token that changed, was added, or was removed between two files produced no output at all, andregressioncould not react to a motion-only change.This is the same shape as #50 / #51, where
componentswas missing from the same object.Evidence
Two files that differ only under
motion(state-changegoes from100ms/ease-outto400ms/linear, andsurface-exitis added):Before the change,
tokenshad nomotionkey at all and exit code was0:{ "tokens": { "colors": { "added": [], "removed": [], "modified": [] }, "typography": { "added": [], "removed": [], "modified": [] }, "rounded": { "added": [], "removed": [], "modified": [] }, "spacing": { "added": [], "removed": [], "modified": [] }, "components": { "added": [], "removed": [], "modified": [] } }, "regression": false }After the change:
Contract violated
docs/spec.mdlistsmotionas a top-level token category of the document schema, alongsidecolors,typography,rounded,spacingandcomponents. Thediffcommand's job is to report token-level changes between two DESIGN.md files; leaving a schema category out of that report means a real change to a project's tokens is invisible to the tool and to any CI gate built on it.Fix
packages/cli/src/commands/diff.tsnow passes both motion maps through the samediffMapshelper as the other primitive categories.motionis optional onDesignSystemState, so an absent map is compared as an empty one rather than being skipped. No new helper and no new branch in the linter or model.Tests
Added three cases to the existing
packages/cli/src/commands/diff.test.ts, driving the real command entry point (diffCommand.run), which is the pattern already used incommands/spec.test.ts:modifiedaddedandremovedAll three fail against the previous
diff.ts(output.tokens.motionisundefined) and pass with the change.Checks run
bun run lint(tsc --noEmit): exit 0bun test src/commands/diff.test.ts: 7 pass, 0 failbun test(packages/cli): 403 pass, 1 skip, 5 fail. The same 5 tests fail on the untouched base commit with the change stashed, so they are pre-existing on this machine and unrelated to this diff. Details:cli-errors.test.ts/export-exit-code.test.tsspawn the CLI viaBun.spawnSync(['bun', ...]), and the child process reports'bun' is not recognized as an internal or external commandon this Windows host. Running the same CLI commands directly in a shell gives the expected exit codes (2for a missing file,1with theINVALID_FORMATenvelope for a bad--format).linter/tailwind/handler.test.tsfails withCannot find package 'postcss' from ... tailwindcss/lib/index.js.Docs
The
diffoutput example inREADME.mdgains themotionkey so the documented shape matches what the command emits.Related: #50, #51 (the same omission for
components), #182 (which added the motion category).