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

feat: Move storybook.requires.js and Storybook.tsx files from the root directory to the .storybook folder #252

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/react-native/scripts/loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const fs = require('fs');
const glob = require('glob');
const storybookRequiresLocation = '/.storybook/storybook.requires.js';

function requireUncached(module) {
delete require.cache[require.resolve(module)];
Expand Down Expand Up @@ -37,7 +38,7 @@ function getAddons() {
function getPaths() {
return getGlobs().reduce((acc, storyGlob) => {
const paths = glob.sync(storyGlob);
return [...acc, ...paths];
return [...acc, ...paths.map((storyPath) => `../${storyPath}`)];
}, []);
}

Expand All @@ -47,12 +48,12 @@ function writeRequires() {
const storyPaths = getPaths();
const addons = getAddons();

fs.writeFileSync(path.join(cwd, '/storybook.requires.js'), '');
fs.writeFileSync(path.join(cwd, storybookRequiresLocation), '');

const previewExists = getPreviewExists();
let previewJs = previewExists
? `
import { decorators, parameters } from './.storybook/preview';
import { decorators, parameters } from './preview';
if (decorators) {
decorators.forEach((decorator) => addDecorator(decorator));
}
Expand Down Expand Up @@ -91,7 +92,7 @@ configure(getStories, module, false)

`;

fs.writeFileSync(path.join(cwd, '/storybook.requires.js'), fileContent, {
fs.writeFileSync(path.join(cwd, storybookRequiresLocation), fileContent, {
encoding: 'utf8',
flag: 'w',
});
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/native/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import StorybookUIRoot from './Storybook';
import StorybookUIRoot from './.storybook/Storybook';

export { StorybookUIRoot as default };
4 changes: 2 additions & 2 deletions v6README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ const StorybookUIRoot = getStorybookUI({
asyncStorage: AsyncStorage,
});

export default StorybookUIRoot;" > Storybook.tsx
export default StorybookUIRoot;" >.storybook/Storybook.tsx

echo "import StorybookUIRoot from './Storybook';
echo "import StorybookUIRoot from './.storybook/Storybook';
export { StorybookUIRoot as default };" > App.tsx
```

Expand Down