npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zeplin/cli-connect-storybook-plugin

v2.0.0

Published

Zeplin CLI Connected Components - Storybook Plugin

Downloads

9,715

Readme

Zeplin CLI Storybook Plugin

Zeplin CLI plugin to generate Storybook links for Zeplin components, inspired by chromatic-cli.

Contents

Installation

Install the plugin using npm.

npm install -g @zeplin/cli-connect-storybook-plugin

Usage

Since Zeplin CLI Storybook Plugin requires a running Storybook instance to collect information about stories, configure the plugin in your components configuration file (.zeplin/components.json) to point to an instance.

Remote Storybook instance

Provide the URL of a remote Storybook instance.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "<protocol>://<hostname>:<port>", // Defaults to http://localhost:6006
        }
    }],
    ...
}

Local Storybook instance

Zeplin CLI Storybook Plugin can also start a local Storybook instance to collect information about stories. You can either provide an npm script or a custom command to start a Storybook instance.

npm script

Provide the name of the npm script to start a Storybook instance.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "http://localhost:<port>", // Defaults to http://localhost:6006
            "startScript": "<name of the npm script>"
        }
    }],
    ...
}

Custom command

Provide a custom command to run to start a Storybook instance.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "http://localhost:<port>", // Defaults to http://localhost:6006
            "command": "<the command to start storybook server>"
        }
    }],
    ...
}

☝️ For all alternatives, the generated hyperlinks in Zeplin will be based on the url property you define.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "http://localhost:<port>", // Defaults to http://localhost:6006
            "startScript": "<the command to start storybook server>",
            "targetUrl": "<protocol>://<hostname>:<port>"
        }
    }],
    ...
}

☝️ You can use optional targetUrl parameter to generate the hyperlinks to a remote Storybook

Once the Storybook instance is configured, run CLI connect command.

zeplin connect

Matching components with stories

Zeplin CLI Storybook Plugin automatically attempts to match components with stories following these rules:

  • For React, resolve component stories by matching the file path in the components configuration file.
  • If component property of stories are set (either using CSF or storiesOf API), resolve component stories by matching component property of the stories with component file names, e.g. Avatar.jsx and Avatar.
  • Resolve stories by matching story display names (e.g. Design System/Avatar and Avatar) with component file names (e.g. Avatar.jsx and Avatar).

It's also possible to match components with stories manually. Set the storybook property components (within the configuration file, .zeplin/components.json) for each component you want to manually match and provide the story kind and name(s).

{
    ...
    "components": [
        {
            "path": "Avatar.jsx",
            "zeplinNames": [
                "avatar loaded",
                "avatar loading"
            ],
            "storybook": {
                "kind": "Design System/Avatar",
                "stories": [
                    "large",
                    "medium",
                    "small"
                ]
            }
        }
    ]
    ...
}

URL format for manual matching

Manually defined component stories will generate hyperlinks using new hyperlinks (for Storybook v5+). In order to generate old style hyperlinks (for Storybook v4) use the following configuration. Next major release will remove to support of old style hyperlinks.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "http://localhost:6006",
            "startScript": "storybook",
            "format": "old"
        }
    }],
    ...
}

Use manual matching without connecting a working Storybook

Use fetchStories flag to disable connecting and fetching stories from the given URL, so that you can utilize manual configuration to create Storybook hyperlinks. It is recommended to set it false if the plugin cannot match components using the rules mentioned above.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "https://storybook.example.com",
            "fetchStories": false,
            "format": "new"
        }
    }],
    ...
}

Fast fail on Storybook errors

Set failFastOnErrors parameter to true to abort on any internal errors happened in Storybook. By default, the plugin will try to fetch whatever story it can retrieve from Storybook even if it reports any errors.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "http://localhost:6006",
            "startScript": "storybook",
            "failFastOnErrors": true
        }
    }],
    ...
}

Generate DocsPage hyperlinks

You can use useDocsPage parameter to generate DocsPage hyperlinks if you use @storybook/addon-docs in your Storybook instance.

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "http://localhost:6006",
            "startScript": "storybook",
            "useDocsPage": true
        }
    }],
    ...
}

Ignore SSL certificate errors

In case you would need to ignore SSL certificate errors:

{
    ...
    "plugins" : [{
        "name": "@zeplin/cli-connect-storybook-plugin",
        "config": {
            "url": "https://storybook.example.com",
            "ignoreSSLErrors": true
        }
    }],
    ...
}

About Connected Components

Connected Components in Zeplin lets you access components in your codebase directly on designs in Zeplin, with links to Storybook, GitHub and any other source of documentation based on your workflow. 🧩

Zeplin CLI uses plugins like this one to analyze component source code and publishes a high-level overview to be displayed in Zeplin.