Skip to content

Adding token analyzer logic and tests #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 76 commits into
base: main
Choose a base branch
from

Conversation

brandonthomas
Copy link
Contributor

@brandonthomas brandonthomas commented May 8, 2025

In this change I'm adding all of the logic and tests for the token-analyzer package. This package includes the ability to build a mapping of token usage in style files to their component state, which properties are impacted, etc. This tool is a static analysis tool and it specifically targets Griffel based styles so it won't work with other libraries for now. I've included a pretty detailed description in the README so check that for more information.

Other notes:

  • It can be run both in CLI and programmatically.
  • I copied over the button styles file and made some changes and added complexities for the sake of testing. It's not used anywhere else.
  • I've included some additional features or nice to haves but none of them are required for this to work.
  • Beyond the button styles file, I also ran the tool on this repo itself and verified with a manual audit that all styles were found.
  • Since some of this recursive logic can be hard to follow or mentally map I built a data flow for the import analyzer. I am thinking about doing it for the whole tool as well just to make it easier to learn about. Let me know if this would be helpful.

@brandonthomas brandonthomas reopened this May 23, 2025
@brandonthomas brandonthomas marked this pull request as ready for review May 23, 2025 19:41
@brandonthomas brandonthomas requested review from a team as code owners May 23, 2025 19:41
…file system roots

update default path to just run at the directory it's called from
@Mitch-At-Work
Copy link

One test failing for me due to windows path seperator not being escaped:
image

"yargs": "^17.7.2"
},
"scripts": {
"analyze-tokens": "(cd ../.. && nx build token-analyzer) && node ../../dist/packages/token-analyzer/lib-commonjs/index.js",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build error in windows due to 'cd ../..' being held onto for second command

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.

3 participants