Socket
Socket
Sign inDemoInstall

bookcase-builder

Package Overview
Dependencies
13
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bookcase-builder

![logo](./assets/cover.png)


Version published
Weekly downloads
33
increased by37.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

logo

"Put all the books in the bookcase."
Compose storybooks for an overview.

English | 简体中文

📢 CLI bookcase-builder as bb.

Background

In the monorepo project, usually we will have a storybook for each package, and use CI to deploy them to the server.

packages
    |--- packages-1
            |--- .storybook
            |--- public
    |--- packages-2
            |--- .storybook
            |--- public
    |--- packages-3
            |--- .storybook
            |--- public
    |--- ...

But each project deployment link is independent.

https://localhost:3000/packages-1
https://localhost:3000/packages-2
https://localhost:3000/packages-3

Storybook provides ref attribute, which allows us to compose them together, and access them via an address.

https://localhost:3000/overview
    |- https://localhost:3000/packages-1
    |- https://localhost:3000/packages-2
    |- https://localhost:3000/packages-3

But it's not easy to compose them together. We need to modify a lot of packaging configurations, and create a package for this, and these configurations only need to be used when building overview. It's too complicated, so that's where this tool comes in, and it can do it all in one command.

The chromatic tool was officially recommended, and it made it easy for us to do this, but we couldn't use it to complete the build and privatize the deployment.

Installation

npm i bookcase-builder -D

Configurations

// package.json

{
  "bookcase-builder": {
    /*
    * [ 📌 Required ]
    * Where to find Packages.
    */
    "workspaces": [
      "packages/*"
    ],
    /*
    * [ 📌 Required ]
    * Directory where to store built files.
    */
    "output": "./public",
    /*
    * Rename the current package name, default to package directory name.
    * e.g.
    * [root]/packages/packageA => http://localhost:3000/packageA
    * Set basename to "packageB", it will be http://localhost:3000/packageB
    */
    "basename": "packageB",
    /*
    * Basename of URL.
    * e.g.
    * [root]/packages/packageA => http://localhost:3000/packageA
    * Set publicURL to "/PREFIX_URL/", it will be http://localhost:3000/PREFIX_URL/packageA
    */
    "publicURL": "/PREFIX_URL/",
    /*
    * [ 📌 Required ]
    * Which package manager is used.
    * 'yarn' | 'npm' | 'pnpm'
    */
    "packageManager": "yarn",
    "storybook": {
      // Storybook directory, default to ".storybook"
      "configDir": "./.otherStorybookDir"
    }
  }
}

Usage

  1. Config
// package.json of package root directory.

{
  "bookcase-builder": {
    "workspaces": [
      // Tell BB where to find the packages to be built
      "packages/*"
    ],
    // Let BB where to store the built files
    "output": "./public",
    // What package manager is used.
    "packageManager": "pnpm"
  }
}
// package.json in the workspace directory.
// Here you can configure the project to be built. For example specify the storybook configuration directory.
// If you want to use the default configuration, you can set it to "{}". And if haven't configured it, BB will't build it.
{
  "bookcase-builder": {
    // Rename the current package name, default to package directory name.
    "basename": "other name",
    "storybook": {
      // Storybook configuration directory, default to ".storybook"
      "configDir": "./.otherStorybookDir"
    }
  }
}
// .storybook/main.[js/ts] of the project to be built in the workspace.
import { withOverview } from 'bookcase-builder';

// Let BB know where to find the project to be built, And send original config to the withOverview function.
export default withOverview(__dirname)({
  // Original config.
  ...,
});
  1. Build
$ bookcase-builder or bb

Tips

$ bb --help

Sponsors

License

MIT License © 2022 Dohooo

FAQs

Last updated on 29 Jul 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