@civicactions/cmsds-open-data-components

中文文档
4.7.1发布于 2026/11/07GPL-3.0TypeScriptES Module近 30 天下载 1952

Components for the open data catalog frontend using CMS Design System

原始使用文档
文档目录16 节
  1. Local Development
  2. Storybook
  3. Running Storybook
  4. Building Storybook
  5. Writing Stories
  6. Storybook Limitations
  7. Component Inventory
  8. Generating the Inventory
  9. Component Usage Report
  10. Running in Dependent Projects
  11. Generating Sample Report (Library Development)
  12. Publishing new versions
  13. Clear out caches and previous build
  14. Create a new release
  15. Create an alpha/testing release
  16. Testing

cmsds-open-data-components

This repo acts as an upstream common react library for CMS Open Data sites. This library is powered by Parcel.

Local Development

For local development, we recommend using npm workspaces. Once you have a workspace directory, install this library inside your workspace along any Open Data downstream sites you wish to work on.

In the root folder for this project, run npm run watch to build local code. Ensure the upstream is using the same version number located in package.json of this repo. Start the upstream site locally as well, and it should load local code from this repo as the dependency. Parcel also provides hot rebuilding while watch is running.

Storybook

This project includes Storybook for component development and documentation.

Running Storybook

To start Storybook in development mode:

npm run storybook

This will start the Storybook development server, typically on http://localhost:6006.

Building Storybook

To build a static version of Storybook for deployment:

npm run build-storybook

The built Storybook will be output to the storybook-static directory.

Writing Stories

Stories should be placed alongside components using the naming convention:

  • ComponentName.stories.jsx or ComponentName.stories.tsx

Stories use the CSF3 (Component Story Format 3) format. See existing stories in the src/components/ directory for examples.

Storybook Limitations

Storybook integration is ongoing for this project. Some components and page templates may not yet have stories, and certain icons or styles from the CMS.gov design system might not display as intended in Storybook.

Component Inventory

This project includes an automated script that generates a comprehensive inventory of all components, templates, services, hooks, contexts, utilities, and types.

Generating the Inventory

To generate the inventory report:

npm run generate:inventory

This creates COMPONENTS_INVENTORY.md in the root directory with:

  • Complete list of all library items
  • Public export status
  • Storybook story coverage
  • Unit test coverage
  • Quality metrics and statistics

The inventory is automatically updated on every commit via a pre-commit hook.

For more details, see the Scripts Documentation.

Component Usage Report

This project includes a script that can be run in projects that use cmsds-open-data-components as a dependency to analyze component usage.

Running in Dependent Projects

From a project that has @civicactions/cmsds-open-data-components as a dependency:

npx generate-usage-report

This generates COMPONENT_USAGE_REPORT.md showing:

  • Which components from the library are being used
  • Where each component is imported in the project
  • Summary statistics and category breakdown
  • GitHub links to component source code

Generating Sample Report (Library Development)

To generate a sample report using Storybook files in this repository:

npm run generate:usage-report

This creates SAMPLE_COMPONENT_USAGE_REPORT.md demonstrating the report format.

For more details, see the Scripts Documentation.

Publishing new versions

Clear out caches and previous build

Before running a build, it is recommended to clear out the old build and cache files to avoid publishing a stale build.

Run rm -rf dist/ to delete the previous build
Run rm -rf .parcel-cache/ to clear out the parcel build caches

Create a new release

Run npm run build to create a production version of the library before publishing to npm.
Run npm publish to publish to npm

Create an alpha/testing release

When creating an alpha release or any other release intended for testing purposes, add a tag to the publish command. This will prevent the testing release from showing up as the latest release in NPM.

After running npm run build,
Run npm publish --tag <tag name> example (npm publish --tag "alpha")

Testing

Jest tests can be run using: npm run test

版本与发布记录

@civicactions/cmsds-open-data-components 共发布 601 个版本,首次发布于 2020/12/16;过去 12 个月发布了 160 个版本。

版本发布日期距今
4.7.1latest2026/11/072 天前
4.7.1-alpha.12026/11/063 天前
4.7.02026/10/2713 天前
4.7.0-alpha.12026/10/1525 天前
4.6.02026/10/1426 天前
4.6.0-alpha.92026/10/1327 天前

其他发布通道:head-foot → 0.11.2-alpha.4,table-updates → 0.11.2-table.8,swagger → 0.11.2-swagger.2,date → 0.14.0-date.3,noncsv-dataset → 0.14.0-noncsv-dataset.7,filtered-update → 0.14.0-filtered-update.6。

关于 @civicactions/cmsds-open-data-components 的常见问题

@civicactions/cmsds-open-data-components 是什么?

Components for the open data catalog frontend using CMS Design System

如何安装 @civicactions/cmsds-open-data-components?

在项目目录运行 npm install @civicactions/cmsds-open-data-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.2.7)、react-dom(^19.2.7)、@cmsgov/design-system(^18.0.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 generate-usage-report,可以用 npx generate-usage-report 直接运行。

@civicactions/cmsds-open-data-components 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@civicactions/cmsds-open-data-components 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@civicactions/cmsds-open-data-components 可以商用吗?

@civicactions/cmsds-open-data-components 使用 GPL-3.0 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@civicactions/cmsds-open-data-components 的下载量有多少?

根据 npm 官方下载统计,@civicactions/cmsds-open-data-components 在 2026/10/10 – 2026/11/08 这 30 天内被下载 1,952 次,日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@civicactions/cmsds-open-data-components 还在维护吗?

最新版本 4.7.1 发布于 2026/11/07(2 天前);至今共发布 601 个版本,其中过去 12 个月发布了 160 个;首次发布于 2020/12/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。