Socket
Socket
Sign inDemoInstall

@storybook/csf-tools

Package Overview
Dependencies
14
Maintainers
29
Versions
833
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/csf-tools

An experimental library to read, analyze, transform, and write CSF programmatically.


Version published
Maintainers
29
Weekly downloads
5,860,132
decreased by-7.4%

Weekly downloads

Package description

What is @storybook/csf-tools?

The @storybook/csf-tools package is a set of utilities for working with Component Story Format (CSF) files in Storybook. CSF is a format for writing stories in plain JavaScript and TypeScript. The tools provided by this package help with tasks such as transforming, analyzing, and generating CSF files programmatically.

What are @storybook/csf-tools's main functionalities?

Transform CSF files

This feature allows you to transform CSF files by parsing and modifying their content. The code sample demonstrates how to parse a CSF file into an abstract syntax tree (AST) that can be manipulated.

import { transformCsf } from '@storybook/csf-tools';

const code = `export default { title: 'Button' };
export const Primary = () => <button>Click me</button>`;
const result = transformCsf(code).parse();

Analyze CSF files

This feature provides the ability to analyze CSF files to extract information such as story names and properties. The code sample shows how to perform an analysis on a CSF file.

import { analyzeCsf } from '@storybook/csf-tools';

const code = `export default { title: 'Button' };
export const Primary = () => <button>Click me</button>`;
const analysis = analyzeCsf(code);

Generate CSF files

This feature enables the generation of CSF files from a template or data structure. The code sample illustrates how to generate a CSF file with a given title and an array of stories.

import { generateCsf } from '@storybook/csf-tools';

const stories = [{ name: 'Primary', code: '<button>Click me</button>' }];
const csf = generateCsf({ title: 'Button' }, stories);

Other packages similar to @storybook/csf-tools

Readme

Source

Storybook CSF Tools

An experimental library to read, analyze, transform, and write CSF programmatically.

  • Read - Parse a CSF file with Babel
  • Analyze - Extract its metadata & stories based on the Babel AST
  • Write - Write the AST back to a file

It can can parse MDX into CSF.

Coming soon:

  • Transform - Update the AST to add/remove/modify stories & metadata (TODO)

Keywords

FAQs

Last updated on 17 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc