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:
Michael Shilman 2022-10-18 22:28:15 +08:00 committed by GitHub
commit dd96c9e219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 1 deletions

View File

@ -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';

View 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
`);
}
}

View File

@ -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 {

View File

@ -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 () => {