storyblok-cli icon indicating copy to clipboard operation
storyblok-cli copied to clipboard

Feature: Add Glob Patterns to Typedefs Generation

Open chimp1nski opened this issue 7 months ago • 1 comments

Pull request type

  • [ ] Bugfix
  • [x] Feature
  • [ ] Code style update (formatting, renaming)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Other (please describe):

How to test this PR

  1. Create a folder for your components in a frontend project ./storyblok/components
  2. Pull components from a space into separate files storyblok --space <SPACE-ID> pull-components --sf -p ./storyblok/components/
  3. Generate types for all components in the directory with provided glop pattern string "./storyblok/components/*" storyblok --space <SPACE-ID> generate-typescript-typedefs --source './storyblok/components/*' --target ./storyblok/storyblok-types.d.ts

What is the new behavior?

You can now provide a glob pattern string to the generate-typescript-typedefs command to allow for advanced file matching (e.g.: all files within a directory) while maintaining backwards compatibility.

Other information

This proposal stems from a problem I am currently facing where I want to generate types for specific components only without having to add each one of them separately to an npm script.

More Context

In a storyblok project I am currently working on we have separate teams for the creation of the bloks in the blok library and the development of the components in the frontend. Since the blok library team is constantly creating new bloks – primarily to try things out – the generated types in the frontend get littered with "test" components and types.

I now want to be able to pull all of the components with one command, only commit those I need to the codebase (folder) and then generate the types only for the components in that folder.

Thanks for your time and have a great weekend :)

chimp1nski avatar Jul 12 '24 11:07 chimp1nski