Skip to content

Commit

Permalink
Merge pull request #28338 from storybookjs/valentin/fix-story-glob-pa…
Browse files Browse the repository at this point in the history
…ttern

Config: Apply JavaScript-only story glob extensions for JavaScript projects
  • Loading branch information
valentinpalkovic authored Jun 25, 2024
2 parents aee10a9 + 74646c6 commit 77c3c8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions code/lib/cli/src/generators/configure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('configureMain', () => {
expect(mainConfigContent).toMatchInlineSnapshot(`
"/** @type { import('@storybook/react-vite').StorybookConfig } */
const config = {
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs)'],
addons: [],
framework: {
name: '@storybook/react-vite',
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('configureMain', () => {
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs)'],
addons: [
path.dirname(require.resolve(path.join('@storybook/addon-links', 'package.json'))),
path.dirname(require.resolve(path.join('@storybook/addon-essentials', 'package.json'))),
Expand Down
8 changes: 7 additions & 1 deletion code/lib/cli/src/generators/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const sanitizeFramework = (framework: string) => {
return matches[0];
};

const typescriptExtensions = ['ts', 'tsx', 'mts', 'cts'];

export async function configureMain({
addons,
extensions = ['js', 'jsx', 'mjs', 'ts', 'tsx'],
Expand All @@ -57,10 +59,14 @@ export async function configureMain({
prefixes = [],
...custom
}: ConfigureMainOptions) {
const isLanguageJavascript = language === SupportedLanguage.JAVASCRIPT;
const filteredExtensions = extensions.filter((extension) =>
isLanguageJavascript ? !typescriptExtensions.includes(extension) : true
);
const srcPath = path.resolve(storybookConfigFolder, '../src');
const prefix = (await fse.pathExists(srcPath)) ? '../src' : '../stories';
const config = {
stories: [`${prefix}/**/*.mdx`, `${prefix}/**/*.stories.@(${extensions.join('|')})`],
stories: [`${prefix}/**/*.mdx`, `${prefix}/**/*.stories.@(${filteredExtensions.join('|')})`],
addons,
...custom,
};
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const publish = async (packages: { name: string; location: string }[], url: stri
const command = `cd ${path.resolve(
'../code',
location
)} && yarn pack --out=${PACKS_DIRECTORY}/${tarballFilename} && cd ${PACKS_DIRECTORY} && npm publish ./${tarballFilename} --registry ${url} --force --access restricted --ignore-scripts`;
)} && yarn pack --out=${PACKS_DIRECTORY}/${tarballFilename} && cd ${PACKS_DIRECTORY} && npm publish ./${tarballFilename} --registry ${url} --force --ignore-scripts`;
exec(command, (e) => {
if (e) {
rej(e);
Expand Down

0 comments on commit 77c3c8a

Please sign in to comment.