From b050b1faa2ba9b47c1ac687f30feede1c92b3fef Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Wed, 16 Aug 2023 16:49:47 +0800 Subject: [PATCH 1/2] Merge pull request #23852 from storybookjs/shilman/fix-story-indexer Index: Fix `*.story.*` CSF indexing (cherry picked from commit 377f7f9c0a022ae073ab0e93792d4e15dd88b15c) --- .../core-server/src/presets/common-preset.ts | 2 +- .../src/utils/StoryIndexGenerator.test.ts | 30 +++++++++++++++++++ .../src/utils/__mockdata__/src/F.story.ts | 7 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 code/lib/core-server/src/utils/__mockdata__/src/F.story.ts diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index fcb4b5681571..7e13ade9ddf0 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -195,7 +195,7 @@ export const features = async ( }); export const csfIndexer: Indexer = { - test: /\.stories\.(m?js|ts)x?$/, + test: /\.(stories|story)\.(m?js|ts)x?$/, index: async (fileName, options) => (await readCsf(fileName, options)).parse().indexInputs, }; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts index 7110743b7003..b1097c168a86 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -99,6 +99,36 @@ describe('StoryIndexGenerator', () => { `); }); }); + describe('single file .story specifier', () => { + it('extracts stories from the right files', async () => { + const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + './src/F.story.ts', + options + ); + + const generator = new StoryIndexGenerator([specifier], options); + await generator.initialize(); + + expect(await generator.getIndex()).toMatchInlineSnapshot(` + Object { + "entries": Object { + "f--story-one": Object { + "id": "f--story-one", + "importPath": "./src/F.story.ts", + "name": "Story One", + "tags": Array [ + "autodocs", + "story", + ], + "title": "F", + "type": "story", + }, + }, + "v": 4, + } + `); + }); + }); describe('non-recursive specifier', () => { it('extracts stories from the right files', async () => { const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( diff --git a/code/lib/core-server/src/utils/__mockdata__/src/F.story.ts b/code/lib/core-server/src/utils/__mockdata__/src/F.story.ts new file mode 100644 index 000000000000..bb14d42c7112 --- /dev/null +++ b/code/lib/core-server/src/utils/__mockdata__/src/F.story.ts @@ -0,0 +1,7 @@ +const component = {}; +export default { + component, + tags: ['autodocs'], +}; + +export const StoryOne = {}; From 3c34b0af3df702e1cfbeb70054edab2d5377b37b Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Wed, 16 Aug 2023 09:12:37 +0000 Subject: [PATCH 2/2] Write changelog for 7.3.1 --- CHANGELOG.md | 4 ++++ code/package.json | 3 ++- docs/versions/latest.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4a4cfb7b83..076226ae9e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.3.1 + +- Index: Fix `*.story.*` CSF indexing - [#23852](https://github.com/storybookjs/storybook/pull/23852), thanks [@shilman](https://github.com/shilman)! + ## 7.3.0 - ✨ Indexer: Introduce new experimental `indexer` API - #23691, thanks [@JReinhold](https://github.com/jreinhold)! diff --git a/code/package.json b/code/package.json index df1c2df8d920..112b9d186e04 100644 --- a/code/package.json +++ b/code/package.json @@ -326,5 +326,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "7.3.1" } diff --git a/docs/versions/latest.json b/docs/versions/latest.json index 7618803cf164..52543f66851f 100644 --- a/docs/versions/latest.json +++ b/docs/versions/latest.json @@ -1 +1 @@ -{"version":"7.3.0","info":{"plain":"- Core: Improve `composeStories` typings - [#23577](https://github.com/storybookjs/storybook/pull/23577), thanks [@yannbf](https://github.com/yannbf)!"}} +{"version":"7.3.1","info":{"plain":"- Index: Fix `*.story.*` CSF indexing - [#23852](https://github.com/storybookjs/storybook/pull/23852), thanks [@shilman](https://github.com/shilman)!"}}