11import { Context , Env , WebConfig , MobileConfig , basicAuth , tunnelConfig } from '../types.js'
22import constants from './constants.js'
33import { version } from '../../package.json'
4- import { validateConfig } from './schemaValidation.js'
4+ import { validateConfig , validateConfigForScheduled } from './schemaValidation.js'
55import logger from './logger.js'
66import getEnv from './env.js'
77import httpClient from './httpClient.js'
@@ -23,6 +23,7 @@ export default (options: Record<string, string>): Context => {
2323 let fetchResultObj : boolean ;
2424 let fetchResultsFileObj : string ;
2525 let buildNameObj : string ;
26+ let allowDuplicateSnapshotNames : boolean = false ;
2627 try {
2728 if ( options . config ) {
2829 config = JSON . parse ( fs . readFileSync ( options . config , 'utf-8' ) ) ;
@@ -35,9 +36,11 @@ export default (options: Record<string, string>): Context => {
3536 delete config . web . resolutions ;
3637 }
3738
39+ let validateConfigFn = options . scheduled ? validateConfigForScheduled : validateConfig ;
40+
3841 // validate config
39- if ( ! validateConfig ( config ) ) {
40- throw new Error ( validateConfig . errors [ 0 ] . message ) ;
42+ if ( ! validateConfigFn ( config ) ) {
43+ throw new Error ( validateConfigFn . errors [ 0 ] . message ) ;
4144 }
4245 } else {
4346 logger . info ( "## No config file provided. Using default config." ) ;
@@ -70,7 +73,7 @@ export default (options: Record<string, string>): Context => {
7073 }
7174 } catch ( error : any ) {
7275 console . log ( `[smartui] Error: ${ error . message } ` ) ;
73- process . exit ( ) ;
76+ process . exit ( 1 ) ;
7477 }
7578
7679 if ( config . web ) {
@@ -85,10 +88,13 @@ export default (options: Record<string, string>): Context => {
8588 }
8689 }
8790 if ( config . basicAuthorization ) {
88- basicAuthObj = config . basicAuthorization
91+ basicAuthObj = config . basicAuthorization ;
8992 }
9093 if ( config . tunnel ) {
91- tunnelObj = config . tunnel
94+ tunnelObj = config . tunnel ;
95+ }
96+ if ( config . allowDuplicateSnapshotNames ) {
97+ allowDuplicateSnapshotNames = true ;
9298 }
9399
94100 return {
@@ -114,7 +120,8 @@ export default (options: Record<string, string>): Context => {
114120 skipBuildCreation : config . skipBuildCreation ?? false ,
115121 tunnel : tunnelObj ,
116122 userAgent : config . userAgent || '' ,
117- requestHeaders : config . requestHeaders || { }
123+ requestHeaders : config . requestHeaders || { } ,
124+ allowDuplicateSnapshotNames : allowDuplicateSnapshotNames ,
118125 } ,
119126 uploadFilePath : '' ,
120127 webStaticConfig : [ ] ,
@@ -142,6 +149,7 @@ export default (options: Record<string, string>): Context => {
142149 force : options . force ? true : false ,
143150 markBaseline : options . markBaseline ? true : false ,
144151 buildName : options . buildName || '' ,
152+ scheduled : options . scheduled || '' ,
145153 port : port ,
146154 ignoreResolutions : resolutionOff ,
147155 fileExtension : extensionFiles ,
0 commit comments