@storybook/postinstall
TypeScript icon, indicating that this package has built-in type declarations

7.6.17 • Public • Published

Storybook Postinstall Utilities

A minimal utility library for addons to update project configurations after the addon is installed via the Storybook CLI, e.g. sb add docs.

Each postinstall is written as a jscodeshift codemod, with the naming convention addon-name/postinstall/<file>.js where file is one of { config, addons, presets }.

If these files are present in the addon, the CLI will run them on the existing file in the user's project (or create a new empty file if one doesn't exist). This library exists to make it really easy to make common modifications without having to muck with jscodeshift internals.

Adding a preset

To add a preset to presets.js, simply create a file postinstall/presets.js in your addon:

import { presetsAddPreset } = require('@storybook/postinstall');
export default function transformer(file, api) {
  const root = api.jscodeshift(file.source);
  presetsAddPreset(`@storybook/addon-docs/preset`, { some: 'options' }, { root, api });
  return root.toSource();
};

Readme

Keywords

Package Sidebar

Install

npm i @storybook/postinstall

Weekly Downloads

4,030,788

Version

7.6.17

License

MIT

Unpacked Size

7.21 kB

Total Files

6

Last publish

Collaborators

  • yannbf
  • kasperpeulen
  • valentinpalkovic
  • jreinhold
  • shilman
  • ndelangen
  • hypnosphi
  • tmeasday
  • igor-dv