mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Merge pull request #19452 from storybookjs/cli/old-framework-error
Core: Throw an error if renderer is used as framework
This commit is contained in:
commit
dd96c9e219
@ -22,6 +22,7 @@ export * from './utils/resolve-path-in-sb-cache';
|
||||
export * from './utils/cache';
|
||||
export * from './utils/template';
|
||||
export * from './utils/interpolate';
|
||||
export * from './utils/validate-config';
|
||||
export * from './utils/validate-configuration-files';
|
||||
export * from './utils/glob-to-regexp';
|
||||
export * from './utils/normalize-stories';
|
||||
|
26
code/lib/core-common/src/utils/validate-config.ts
Normal file
26
code/lib/core-common/src/utils/validate-config.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { dedent } from 'ts-dedent';
|
||||
|
||||
const rendererNames = [
|
||||
'@storybook/html',
|
||||
'@storybook/preact',
|
||||
'@storybook/react',
|
||||
'@storybook/server',
|
||||
'@storybook/svelte',
|
||||
'@storybook/vue',
|
||||
'@storybook/vue3',
|
||||
'@storybook/web-components',
|
||||
];
|
||||
|
||||
// Checks that the framework name is not a renderer
|
||||
export function validateFrameworkName(frameworkName: string) {
|
||||
if (rendererNames.includes(frameworkName)) {
|
||||
throw new Error(dedent`
|
||||
Invalid value of ${frameworkName} in the 'framework' field of Storybook config.
|
||||
|
||||
Please run 'npx sb@next automigrate'
|
||||
|
||||
See the v7 Migration guide for more information:
|
||||
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#framework-field-mandatory
|
||||
`);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import {
|
||||
loadAllPresets,
|
||||
cache,
|
||||
loadMainConfig,
|
||||
validateFrameworkName,
|
||||
} from '@storybook/core-common';
|
||||
import prompts from 'prompts';
|
||||
import global from 'global';
|
||||
@ -65,6 +66,8 @@ export async function buildDevStandalone(options: CLIOptions & LoadOptions & Bui
|
||||
const corePresets = [];
|
||||
|
||||
const frameworkName = typeof framework === 'string' ? framework : framework?.name;
|
||||
validateFrameworkName(frameworkName);
|
||||
|
||||
if (frameworkName) {
|
||||
corePresets.push(join(frameworkName, 'preset'));
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getReleaseNotesData, RELEASE_NOTES_CACHE_KEY } from './utils/release-notes';
|
||||
import { getReleaseNotesData, RELEASE_NOTES_CACHE_KEY } from '../release-notes';
|
||||
|
||||
describe('getReleaseNotesData', () => {
|
||||
it('handles errors gracefully', async () => {
|
Loading…
x
Reference in New Issue
Block a user