@@ -128,10 +128,19 @@ function validateConfig(configFile) {
128128
129129 try {
130130 validateConfigBrowsers ( storybookConfig . browsers ) ;
131- resolutions = storybookConfig . resolutions || storybookConfig . viewports
132- storybookConfig . resolutions = validateConfigResolutions ( resolutions ) ;
131+ let resolutions = storybookConfig . resolutions || storybookConfig . viewports
132+ if ( resolutions ) {
133+ storybookConfig . resolutions = validateConfigResolutions ( resolutions ) ;
134+ }
133135 storybookConfig . viewports = storybookConfig . resolutions ;
134- validateCustomViewPorts ( storybookConfig . customViewports )
136+ let customViewports = storybookConfig . customViewports ;
137+ if ( customViewports && customViewports . length > 0 ) {
138+ validateCustomViewPorts ( storybookConfig . customViewports )
139+ }
140+ if ( ! resolutions && ( ! customViewports || customViewports . length === 0 ) ) {
141+ console . log ( '[smartui] Error: No resolutions or customViewports found in config file' ) ;
142+ process . exit ( constants . ERROR_CATCHALL ) ;
143+ }
135144 } catch ( error ) {
136145 console . log ( `[smartui] Error: Invalid config, ${ error . message } ` ) ;
137146 process . exit ( constants . ERROR_CATCHALL ) ;
@@ -210,7 +219,7 @@ function validateConfigResolutions(resolutions) {
210219 if ( width && width < MIN_RESOLUTION_WIDTH || width > MAX_RESOLUTION_WIDTH ) {
211220 throw new ValidationError ( `width must be > ${ MIN_RESOLUTION_WIDTH } , < ${ MAX_RESOLUTION_WIDTH } ` ) ;
212221 }
213- if ( height & ( height < MIN_RESOLUTION_WIDTH || height > MAX_RESOLUTION_WIDTH ) ) {
222+ if ( height && ( height < MIN_RESOLUTION_HEIGHT || height > MAX_RESOLUTION_HEIGHT ) ) {
214223 throw new ValidationError ( `height must be > ${ MIN_RESOLUTION_HEIGHT } , < ${ MAX_RESOLUTION_HEIGHT } ` ) ;
215224 }
216225 res . push ( [ width , height || 0 ] ) ;
@@ -228,8 +237,8 @@ function validateCustomViewPorts(customViewports) {
228237 return
229238 }
230239 customViewports . forEach ( element => {
231- if ( ! Array . isArray ( element . stories ) || element . stories == 0 ) {
232- throw new ValidationError ( 'Missing `stories` in customViewports config. please check the config file ' ) ;
240+ if ( element . stories && element . stories . length !== 0 && element . exclude && element . exclude . length ! == 0 ) {
241+ throw new ValidationError ( 'Cannot specify both stories and excludeStories in customViewports ' ) ;
233242 }
234243 if ( element . styles ) {
235244 if ( ! element . styles ?. width ) {
@@ -246,7 +255,7 @@ function validateCustomViewPorts(customViewports) {
246255 if ( width && width < MIN_RESOLUTION_WIDTH || width > MAX_RESOLUTION_WIDTH ) {
247256 throw new ValidationError ( `customViewports.styles width must be > ${ MIN_RESOLUTION_WIDTH } , < ${ MAX_RESOLUTION_WIDTH } ` ) ;
248257 }
249- if ( height & ( height < MIN_RESOLUTION_WIDTH || height > MAX_RESOLUTION_WIDTH ) ) {
258+ if ( height && ( height < MIN_RESOLUTION_HEIGHT || height > MAX_RESOLUTION_HEIGHT ) ) {
250259 throw new ValidationError ( `customViewports.styles height must be > ${ MIN_RESOLUTION_HEIGHT } , < ${ MAX_RESOLUTION_HEIGHT } ` ) ;
251260 }
252261 element . styles . width = width ;
0 commit comments