Merge pull request #8000 from marleypowell/marley/7999-storybook-fix

fix: Fixed issue with running a subset of stories caused by incorrectly resolved paths.
This commit is contained in:
Patrik Oldsberg
2021-11-12 11:04:23 +01:00
committed by GitHub
+18 -11
View File
@@ -1,23 +1,30 @@
const path = require('path');
const WebpackPluginFailBuildOnWarning = require('./webpack-plugin-fail-build-on-warning');
/**
* This set of stories are the ones that we publish to backstage.io.
*/
const BACKSTAGE_CORE_STORIES = [
'packages/core-components',
'plugins/org',
'plugins/search',
];
module.exports = ({ args }) => {
// Calling storybook with no args causes our default list of stories to be used.
// This set of stories are the ones that we publish to backstage.io
//
// If it's called with args, each arg should be the path to a package that we will
// show the stories from, for example `yarn storybook plugins/catalog`.
let stories;
if (args.length === 0) {
stories = [
'../../core-components/src/**/*.stories.tsx',
'../../../plugins/org/src/**/*.stories.tsx',
'../../../plugins/search/src/**/*.stories.tsx',
];
} else {
const rootDir = path.resolve(__dirname, '../../..');
stories = args.map(arg => path.join(rootDir, arg, 'src/**/*.stories.tsx'));
}
const rootPath = '../../..';
const storiesSrcGlob = 'src/**/*.stories.tsx';
const getStoriesPath = package =>
path.posix.join(rootPath, package, storiesSrcGlob);
const packages = args.length === 0 ? BACKSTAGE_CORE_STORIES : args;
const stories = packages.map(getStoriesPath);
return {
stories,