Collect usage statistics for any npm package exposing React UI components, across a GitHub organization. Inspired by Twilio.com blogpost.
The aim is to provide better understanding of Design System or other shared UI libraries usage across the organization. This tool will facilitate things such as: deprecation of unused components and props, detection of misuse, set-up of alerts.
Create a config.json file based on config.example.
A GitHub personal access token with scope repo is required, to access the org private repositories through GitHub APIs.
Usage for pkgName will be analyzed across org, excluding repositories that did not receive any commit in the last daysUntilStale days.
Be patient, this will take some time.
The list of repositories having pkgName as dependency is collected through the package-adoption npm module.
Omit components to report all components.
Warning
The script will clone all the eligible repositories locally and use them as source for react-scanner. If a repository already exists locally, it will update it with a git pull.
# Install dependencies using npm
$ > npm i
# Start
$ > npm startThe script outputs:
-
a
pkgAdoption.jsonfile with the list of repositories that includepkgNameas a dependency. -
two
reports_by_repofolders with onescanner-report_[repo_name_subdir].jsonfile for each repository. Each file is a report with the usage of React components exposed by thepkgNamelibrary. react-scanner is used to produce two kind of reports: one with the count-components-and-props processor and one with the raw-report processor, reporting all the props values.
npm install @jimdo/components-statsimport { scanOrg } from '@jimdo/components-stats';
const config = {
org: 'github_org_name',
pkgName: '@org/package',
ghAuthToken: 'github_auth_token',
daysUntilStale: '730',
components: { Accordion: true, Button: true },
};
await scanOrg(config);