@hero-design/snowflake-guard
v1.4.11
Published
A hero-design bot detecting snowflake usage
Readme
@hero-design/snowflake-guard
Overview
A GitHub App built with Probot that analyzes PR changes and reports snowflake usage of Hero Design components. The bot detects when components are customized using inline styles, styled-components, sx props, or className attributes that may violate design system guidelines.
Prerequisites
- Node.js >= 10.13.0
- Yarn package manager
- Access to internal-tool-integrations service for storing reports
- GitHub App installation permissions for the repository
Development
Setup
- Copy
.env.exampleto.envand ask Andromeda team for variable details.
cp .env.example .envFor React Native projects, include your repo name in the MOBILE_REPO_NAMES env variable.
- Set up internal-tool-integrations service for the bot to store report.
- Replace
DB_HOSTwith the host of the internal-tool-integrations service. - Use the same
SNOWFLAKE_GUARD_SECRETas the one in the internal-tool-integrations service.
In case you don't want to store snowflake report, comment out the saving report section in src/index.ts.
Install snowflake-guard[Dev] app to a repository that you wish to run the app on.
Start
internal-tool-integrationsservice.Start the bot.
# Install dependencies
yarn install
# Run the bot
yarn start- Open or update a pull request to trigger webhook events.
Scripts
yarn build- Compile TypeScript to JavaScriptyarn start- Build and run the bot with Probotyarn test- Run tests with Jestyarn lint- Run ESLintyarn type-check- Type check without emitting filesyarn deploy- Deploy to Netlifyyarn publish:npm- Publish package to npm
Project Structure
apps/snowflake-guard/
├── src/
│ ├── index.ts # Main entry point, Probot app setup
│ ├── parseSource.ts # Web source code parser
│ ├── parseMobileSource.ts # Mobile source code parser
│ ├── parsers/ # TypeScript and Flow parsers
│ ├── reports/ # Snowflake detection logic
│ │ ├── constants.ts # Report constants and configurations
│ │ ├── mobile/ # Mobile-specific report generators
│ │ └── ... # Web report generators
│ ├── graphql/ # GraphQL queries for report storage
│ └── utils/ # Utility functions
├── netlify/ # Netlify serverless functions
├── lib/ # Compiled JavaScript output
└── package.jsonDeployment
The app is deployed to Netlify as a serverless function. Deployment is automated via GitHub Actions when a new version is published.
To deploy manually:
yarn deployThis requires the NETLIFY_AUTH_TOKEN environment variable to be set.
Contributing
This bot does not support hot-reload yet, please restart the app once you make any changes to the code.
To contribute:
- Make changes to the source code in
src/ - Test locally with
yarn start - Ensure tests pass with
yarn test - Submit a pull request
Note: The bot analyzes PR diffs and comments on potential snowflake usage violations. Approved patterns can be marked with special comments like @snowflake-guard/approved-inline-style or @snowflake-guard/approved-classname.
