diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 1931f0bcc32c..2adfe2e0e2b5 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -135,7 +135,7 @@ async function webpack( export const createStoriesMdxIndexer = (legacyMdx1?: boolean): Indexer => ({ test: /(stories|story)\.mdx$/, - index: async (fileName, opts) => { + createIndex: async (fileName, opts) => { let code = (await fs.readFile(fileName, 'utf-8')).toString(); const { compile } = legacyMdx1 ? await import('@storybook/mdx1-csf') diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index 9d581c307c73..347713e03aaf 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -197,7 +197,7 @@ export const features = async ( export const csfIndexer: Indexer = { test: /(stories|story)\.(m?js|ts)x?$/, - index: async (fileName, options) => (await readCsf(fileName, options)).parse().indexInputs, + createIndex: async (fileName, options) => (await readCsf(fileName, options)).parse().indexInputs, }; // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts index 882c0a9f5235..60d700bad62e 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts @@ -1166,7 +1166,7 @@ describe('StoryIndexGenerator with deprecated indexer API', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName, options) => { + createIndex: async (fileName, options) => { const code = (await fs.readFile(fileName, 'utf-8')).toString(); const csf = loadCsf(code, { ...options, fileName }).parse(); diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index d2a195a31463..7b03427729d2 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -306,7 +306,7 @@ export class StoryIndexGenerator { }); } - const indexInputs = await indexer.index(absolutePath, { makeTitle: defaultMakeTitle }); + const indexInputs = await indexer.createIndex(absolutePath, { makeTitle: defaultMakeTitle }); const entries: ((StoryIndexEntryWithMetaId | DocsCacheEntry) & { tags: Tag[] })[] = indexInputs.map((input) => { diff --git a/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts b/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts index 31d15a059b5d..39820b3e2c17 100644 --- a/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts +++ b/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts @@ -34,7 +34,7 @@ describe('story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ // properties identical to the auto-generated ones, eg. 'StoryOne' -> 'Story One' { type: 'story', @@ -107,7 +107,7 @@ describe('story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', importPath: fileName, @@ -150,7 +150,7 @@ describe('story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', __id: 'a--story-one', @@ -198,7 +198,7 @@ describe('story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', __id: 'a--story-one', @@ -246,7 +246,7 @@ describe('story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ // exportName + title -> id { exportName: 'StoryOne', @@ -336,7 +336,7 @@ describe('story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', tags: ['story-tag-from-indexer'], @@ -383,7 +383,7 @@ describe('docs entries from story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', __id: 'a--story-one', @@ -444,7 +444,7 @@ describe('docs entries from story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', __id: 'a--story-one', @@ -506,7 +506,7 @@ describe('docs entries from story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', __id: 'a--story-one', @@ -555,7 +555,7 @@ describe('docs entries from story extraction', () => { indexers: [ { test: /\.stories\.(m?js|ts)x?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: 'StoryOne', __id: 'a--story-one', @@ -617,7 +617,7 @@ describe('docs entries from story extraction', () => { indexers: [ { test: /\.stories\.mdx?$/, - index: async (fileName) => [ + createIndex: async (fileName) => [ { exportName: '__page', __id: 'page--page', diff --git a/code/lib/types/src/modules/indexer.ts b/code/lib/types/src/modules/indexer.ts index ccd1ddaef206..8ee01b07e83f 100644 --- a/code/lib/types/src/modules/indexer.ts +++ b/code/lib/types/src/modules/indexer.ts @@ -66,7 +66,7 @@ export type Indexer = BaseIndexer & { * @param options {@link IndexerOptions} for indexing the file. * @returns A promise that resolves to an array of {@link IndexInput} objects. */ - index: (fileName: string, options: IndexerOptions) => Promise; + createIndex: (fileName: string, options: IndexerOptions) => Promise; /** * @soonDeprecated Use {@link index} instead */ @@ -75,7 +75,7 @@ export type Indexer = BaseIndexer & { export type DeprecatedIndexer = BaseIndexer & { indexer: (fileName: string, options: IndexerOptions) => Promise; - index?: never; + createIndex?: never; }; /** diff --git a/code/renderers/server/src/preset.ts b/code/renderers/server/src/preset.ts index 23effa83e67f..63cc1aca491a 100644 --- a/code/renderers/server/src/preset.ts +++ b/code/renderers/server/src/preset.ts @@ -14,7 +14,7 @@ export const experimental_indexers: StorybookConfig['experimental_indexers'] = ( ) => [ { test: /(stories|story)\.(json|ya?ml)$/, - index: async (fileName) => { + createIndex: async (fileName) => { const content: FileContent = fileName.endsWith('.json') ? await fs.readJson(fileName, 'utf-8') : yaml.parse((await fs.readFile(fileName, 'utf-8')).toString());