-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26726 from storybookjs/valentin/add-file-search-api
Controls: Add Channels API to search for files in the project root
- Loading branch information
Showing
53 changed files
with
853 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { SupportedFrameworks, SupportedRenderers } from '@storybook/types'; | ||
|
||
export const frameworkToRenderer: Record< | ||
SupportedFrameworks | SupportedRenderers, | ||
SupportedRenderers | 'vue' | ||
> = { | ||
// frameworks | ||
angular: 'angular', | ||
ember: 'ember', | ||
'html-vite': 'html', | ||
'html-webpack5': 'html', | ||
nextjs: 'react', | ||
'preact-vite': 'preact', | ||
'preact-webpack5': 'preact', | ||
qwik: 'qwik', | ||
'react-vite': 'react', | ||
'react-webpack5': 'react', | ||
'server-webpack5': 'server', | ||
solid: 'solid', | ||
'svelte-vite': 'svelte', | ||
'svelte-webpack5': 'svelte', | ||
sveltekit: 'svelte', | ||
'vue3-vite': 'vue3', | ||
'vue3-webpack5': 'vue3', | ||
'web-components-vite': 'web-components', | ||
'web-components-webpack5': 'web-components', | ||
// renderers | ||
html: 'html', | ||
preact: 'preact', | ||
'react-native': 'react-native', | ||
react: 'react', | ||
server: 'server', | ||
svelte: 'svelte', | ||
vue3: 'vue3', | ||
'web-components': 'web-components', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { extractProperFrameworkName } from './get-framework-name'; | ||
|
||
describe('get-framework-name', () => { | ||
describe('extractProperFrameworkName', () => { | ||
it('should extract the proper framework name from the given framework field', () => { | ||
expect(extractProperFrameworkName('@storybook/angular')).toBe('@storybook/angular'); | ||
expect(extractProperFrameworkName('/path/to/@storybook/angular')).toBe('@storybook/angular'); | ||
expect(extractProperFrameworkName('\\path\\to\\@storybook\\angular')).toBe( | ||
'@storybook/angular' | ||
); | ||
}); | ||
|
||
it('should return the given framework name if it is a third-party framework', () => { | ||
expect(extractProperFrameworkName('@third-party/framework')).toBe('@third-party/framework'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { it } from 'node:test'; | ||
import { describe, expect } from 'vitest'; | ||
import { extractProperRendererNameFromFramework } from './get-renderer-name'; | ||
|
||
describe('get-renderer-name', () => { | ||
describe('extractProperRendererNameFromFramework', () => { | ||
it('should return the renderer name for a known framework', async () => { | ||
const renderer = await extractProperRendererNameFromFramework('@storybook/react'); | ||
expect(renderer).toEqual('react'); | ||
}); | ||
|
||
it('should return null for an unknown framework', async () => { | ||
const renderer = await extractProperRendererNameFromFramework('@third-party/framework'); | ||
expect(renderer).toBeNull(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { normalizePath } from './normalize-path'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
describe('normalize-path', () => { | ||
it('should normalize paths', () => { | ||
expect(normalizePath('path/to/../file')).toBe('path/file'); | ||
expect(normalizePath('path/to/./file')).toBe('path/to/file'); | ||
expect(normalizePath('path\\to\\file')).toBe('path/to/file'); | ||
expect(normalizePath('foo\\..\\bar')).toBe('bar'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import path from 'path'; | ||
|
||
/** | ||
* Normalize a path to use forward slashes and remove .. and . | ||
* @param p The path to normalize | ||
* @returns The normalized path | ||
* @example | ||
* normalizePath('path/to/../file') // => 'path/file' | ||
* normalizePath('path/to/./file') // => 'path/to/file' | ||
* normalizePath('path\\to\\file') // => 'path/to/file' | ||
*/ | ||
export function normalizePath(p: string) { | ||
return path.posix.normalize(p.replace(/\\/g, '/')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.