Skip to content

[Experimental]: Storybook stories generator

Notifications You must be signed in to change notification settings

AmazeeLabs/ai-stories-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository provides a Node.js CLI application that leverages OpenAI to automatically generate Storybook stories from your component code.

Features

  • Reads your component source code (TypeScript currently supported).
  • Generates comprehensive stories.ts files for Storybook.
  • Integrates with existing stories.ts files in the same directory for context.
  • Offers robust error handling and informative messages.

Installation

  1. Prerequisites:

Usage

  1. Obtain OpenAI API Key:

    • Create an OpenAI account and access your API Keys (https://beta.openai.com/account/api-keys).

    • Create a .env file in the project root directory and add the following line, replacing YOUR_OPENAI_API_KEY with your actual key:

      OPENAI_API_KEY=YOUR_OPENAI_API_KEY
      
  2. Run the script:

    Using npx (without installing globally):

    npx github:AmazeeLabs/ai-stories-generator [path/to/your/component/ts]

    Replace path/to/your/component.ts with the actual path to your component source code file (e.g., example.ts).

  3. (Optional) Install Globally:

    Clone the repo and then:

    npm install -g .

    This allows you to run the script from anywhere using ai-story-creator path/to/your/component.ts.

Output

The script generates a new stories.ts file in the same directory as your component code file, containing the automatically generated Storybook stories.

Existing Stories Integration

The script reads existing .stories.ts files in the same directory and provides snippets of the first 10 lines to OpenAI for context. This can help the model generate more consistent stories that align with existing behavior.

Additional Notes

  • The script currently supports TypeScript component code.
  • Consider adding comments and descriptions to the generated stories.ts file for better maintainability.

Contributing

We welcome contributions to this project! Please see the CONTRIBUTING.md file for guidelines.

License

This project is licensed under the MIT License (see LICENSE.md).

About

[Experimental]: Storybook stories generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published