Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sb-rn-get-stories does not support stories config with a configuration object (titlePrefix) #423

Closed
stevoland opened this issue Feb 3, 2023 · 3 comments

Comments

@stevoland
Copy link
Contributor

Describe the bug

6.0.1-beta.12 supports auto titles (thanks!) but using titlePrefix requires using a configuration object which sb-rn-get-stories does not handle.

Happy to contribute if you can confirm I'm on the right path:

Assume I could use this API in scripts/loader.js to handle configuration object configs and generate a storybook.requires.ts like:

// ...
const getStories = () => {
  return {
    'Prefix/Component': require('./stories/Component.stories.tsx'),
  }
}
// ...

To Reproduce

// .storybook/main.js
module.exports = {
  stories: [
    {
      directory: './stories',
      files: '**/*.stories.tsx',
      titlePrefix: 'Prefix',
    },
  ]
}
$ yarn sb-rn-get-stories
...
/Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/node_modules/minimatch/minimatch.js:275
    throw new TypeError('invalid pattern')
    ^

TypeError: invalid pattern
    at assertValidPattern (/Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/node_modules/minimatch/minimatch.js:275:11)
    at new Minimatch (/Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/node_modules/minimatch/minimatch.js:133:3)
    at setopts (/Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/node_modules/glob/common.js:116:20)
    at new GlobSync (/Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/node_modules/glob/sync.js:37:3)
    at Function.globSync [as sync] (/Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/node_modules/glob/sync.js:23:10)
    at /Users/stephen.collings/workspace/native/node_modules/@storybook/react-native/scripts/loader.js:85:24
...

Expected behavior
Generates a navigation structure like:

Prefix > Component

System:

System:
    OS: macOS 12.5.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Firefox: 108.0.1
    Safari: 15.6.1
  npmPackages:
    @storybook/addon-actions: 6.5.14 => 6.5.14
    @storybook/addon-essentials: 6.5.14 => 6.5.14
    @storybook/addon-knobs: 6.4.0 => 6.4.0
    @storybook/addon-links: 6.5.14 => 6.5.14
    @storybook/addon-ondevice-actions: 6.0.1-beta.12 => 6.0.1-beta.12
    @storybook/addon-ondevice-backgrounds: 6.0.1-beta.12 => 6.0.1-beta.12
    @storybook/addon-ondevice-controls: 6.0.1-beta.12 => 6.0.1-beta.12
    @storybook/addon-ondevice-notes: 6.0.1-beta.12 => 6.0.1-beta.12
    @storybook/addons: 6.5.14 => 6.5.14
    @storybook/react: 6.5.14 => 6.5.14
    @storybook/react-native: 6.0.1-beta.12 => 6.0.1-beta.12
    @storybook/react-native-server: 6.0.1-beta.12 => 6.0.1-beta.12
    @storybook/theming: 6.5.14 => 6.5.14
@dannyhw
Copy link
Member

dannyhw commented Feb 6, 2023

@stevoland hey thanks for raising this and offering your help, I would really appreciate that! Yes you are correct, the changes to support title generation were recently added and they are in scripts/loader.js.

@SethY8s

This comment was marked as outdated.

@stevoland
Copy link
Contributor Author

Resolved in v6.5.0-rc.1. Thanks @dannyhw 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants