Skip to content

Conversation

@didoo
Copy link
Contributor

@didoo didoo commented Dec 2, 2025

📌 Summary

Small PR that adds some basic validation to the design tokens build script, to make sure the $modes entry have the expected format and values.

🛠️ Detailed description

In this PR I have:

  • added chalk as devDependency (used to highlight some text in the console messages)
  • added two validations to the replace-value-for-mode-${mode} preprocessing function:
    • a "soft" validation that logs a warning in the console (but doesn't block the execution) for when the $modes.default value is different from the standard $value
      • this happens a lot, when copy&pasting blocks of JSON code from a token to another
    • a "hard" validation that throws an error and stops the execution when one of the expected $modes keys is missing

Note: later we may decide to make also the first validation a blocker, for now we want to test how this "soft" check works for the developers adding tokens for the migration of the HDS components to Carbon

🔗 External links

Jira ticket: https://hashicorp.atlassian.net/browse/HDS-5668


👀 Component checklist

💬 Please consider using conventional comments when reviewing this PR.

📋 PCI review checklist
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've worked with GRC to document the impact of any changes to security controls.
    Examples of changes to controls include access controls, encryption, logging, etc.
  • If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
    Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.

@didoo didoo requested a review from a team as a code owner December 2, 2025 19:52
@vercel
Copy link

vercel bot commented Dec 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
hds-showcase Ready Ready Preview Dec 5, 2025 10:34am
hds-website Ready Ready Preview Dec 5, 2025 10:34am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances validation for design token $modes entries in the build script to catch configuration errors early. It adds two levels of validation: a warning for mismatched default mode values and an error that halts execution when expected mode keys are missing.

Key changes:

  • Added chalk dependency for improved console output formatting
  • Implemented soft validation warning when $modes.default differs from $value
  • Converted TODO comment into hard validation that throws an error for missing mode keys

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
packages/tokens/scripts/build.ts Added validation logic for $modes with chalk-formatted console messages
packages/tokens/package.json Added chalk dependency for colored console output
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link
Contributor

@KristinLBradley KristinLBradley left a comment

Choose a reason for hiding this comment

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

Looks good other than the duplicated warning messages I was seeing when I tested.

@didoo
Copy link
Contributor Author

didoo commented Dec 3, 2025

Looks good other than the duplicated warning messages I was seeing when I tested.

@KristinLBradley I have now pushed another commit, to improve the log messages. Now you can see that there are two warnings, because it's invoked twice, for two build paths (the CSS files generation and the JSON doc file generation)

modified

@KristinLBradley
Copy link
Contributor

Can approve after failing check passes

@didoo didoo changed the title [07-C] [Project Solar / Phase 1 / Engineering Follow-ups] Improve validation for $modes [Project Solar / Phase 1 / Engineering Follow-ups] Improve validation for $modes Dec 3, 2025
@didoo didoo force-pushed the project-solar/phase-1/HDS-5202-5203-5204/dry-run-foundations branch 2 times, most recently from cb62d03 to 59aacb2 Compare December 3, 2025 22:07
@didoo didoo force-pushed the project-solar/phase-1/HDS-5668/07c_modes-validation branch from af84387 to 2ecdfb2 Compare December 3, 2025 22:07
Base automatically changed from project-solar/phase-1/HDS-5202-5203-5204/dry-run-foundations to project-solar/phase-1-main-feature-branch December 5, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants