Tutorial 2: Package version tracking
Step-by-step tutorial for tracking the usage of package versions.
Last updated
Step-by-step tutorial for tracking the usage of package versions.
Last updated
In this tutorial, we’ll guide you through setting up a custom CLI hook in Omlet to track the version of your design system package used across your components. This will help you analyze which versions are in use throughout your codebase.
Create a file named hook-script.js
in the root of your application repository and copy the following code. Then, make sure to replace @design-system
with your actual design system package name in line 21.
This findDSPackageVersion
function searches for the nearest package.json
file relative to a given component’s file path and retrieves the version of your design system package.
The afterScan
hook processes each component and sets it as DS Version
property. Feel free to update the property to a preferred name.
Once the CLI scan complete, the DS Version
property will be associated with each component.
Navigate to the "Components" page. From the "Custom properties" filter, click DS Version
and select a version from the revealed dropdown. This will list all the components using the selected package version.
You can create a tag based on this filter to easily access it later on and generate charts for your specific needs.
To analyze component usage, open your Analytics dashboard and click "Create new analysis" button on top-right. Under the Analyze section, select "DS Version" from "Custom properties". Total number of component usages for each package version will be listed.
From there, you can break down the chart by "Project it's used in" to understand which projects are using an older version of your design system.
Feel free to customize the script based on your setup—reach us at support@omlet.dev for any questions/feedback.
Use the --hook-script
argument with the analyze
command, specifying the path to your script: