@@ -17,30 +17,29 @@ class ValidationError extends Error {
1717 }
1818}
1919
20- function validateProjectToken ( options , logger ) {
21- logger . debug ( "options" , options ) ;
22- if ( process . env . PROJECT_TOKEN ) {
20+ function validateProjectToken ( options ) {
21+ console . log ( "options" , options ) ;
22+ if ( process . env . PROJECT_TOKEN ) {
2323 return axios . get ( constants [ options . env ] . AUTH_URL , {
2424 headers : {
2525 projectToken : process . env . PROJECT_TOKEN
26- }
27- } )
26+ } } )
2827 . then ( function ( response ) {
29- logger . info ( '[smartui] Project Token Validated' ) ;
28+ console . log ( '[smartui] Project Token Validated' ) ;
3029 } )
3130 . catch ( function ( error ) {
3231 if ( error . response ) {
33- logger . error ( '[smartui] Error: Invalid Project Token' ) ;
32+ console . log ( '[smartui] Error: Invalid Project Token' ) ;
3433 } else if ( error . request ) {
35- logger . error ( '[smartui] Project Token not validated. Error: ' , error . message ) ;
34+ console . log ( '[smartui] Project Token not validated. Error: ' , error . message ) ;
3635 } else {
37- logger . error ( '[smartui] Project Token not validated. Error: ' , error . message ) ;
36+ console . log ( '[smartui] Project Token not validated. Error: ' , error . message ) ;
3837 }
3938 process . exit ( constants . ERROR_CATCHALL ) ;
40- } ) ;
39+ } ) ;
4140 }
42- else {
43- logger . error ( '[smartui] Error: please set PROJECT_TOKEN key, refer to https://smartui.lambdatest.com' ) ;
41+ else {
42+ console . log ( '[smartui] Error: please set PROJECT_TOKEN key, refer to https://smartui.lambdatest.com' ) ;
4443 process . exit ( constants . ERROR_CATCHALL ) ;
4544 }
4645} ;
@@ -95,8 +94,7 @@ async function validateLatestBuild(options) {
9594 params : {
9695 branch : commit . branch ,
9796 commitId : commit . shortHash
98- }
99- } )
97+ } } )
10098 . then ( function ( response ) {
10199 if ( response . data . status === 'Failure' ) {
102100 console . log ( `[smartui] Build with commit '${ commit . shortHash } ' on branch '${ commit . branch } ' already exists.` ) ;
@@ -200,56 +198,12 @@ function parse(file) {
200198 return JSON . parse ( data ) ;
201199}
202200
203- // Verify Screenshot config
204- function validateScreenshotConfig ( configFile , logger ) {
205- // Check for JSON extension
206- if ( ! isJSONFile ( configFile ) ) {
207- logger . error ( 'capture command only supports json file' ) ;
208- process . exit ( constants . ERROR_CATCHALL ) ;
209- }
210-
211- // Check if file exists
212- if ( configFile ) {
213- try {
214- fs . accessSync ( configFile , fs . constants . F_OK ) ;
215- } catch ( error ) {
216- logger . error ( 'Error: File does not exist ' + configFile ) ;
217- process . exit ( constants . ERROR_CATCHALL ) ;
218- }
219-
220- }
221-
222-
223- let screenshots = { } ;
224- // Check JSON Parse Error
225- if ( configFile ) {
226- try {
227- screenshots = parse ( configFile )
228- } catch ( error ) {
229- logger . error ( 'Error: Invalid json file' ) ;
230- process . exit ( constants . ERROR_CATCHALL ) ;
231- }
232- }
233-
234- logger . debug ( screenshots )
235-
236- //Check for URLs should not be empty
237- for ( const screenshot of screenshots ) {
238- if ( ! screenshot . url || screenshot . url == '' ) {
239- logger . error ( 'Error: Missing required URL for screenshot' ) ;
240- process . exit ( constants . ERROR_CATCHALL ) ;
241- }
242- //Check for URLs should valid (like abcd in URL)
243- try {
244- new URL ( screenshot . url ) ;
245- } catch ( error ) {
246- logger . error ( 'Error: Invalid screenshot URL: ' + screenshot . url ) ;
247- process . exit ( constants . ERROR_CATCHALL ) ;
248- }
249- }
201+ // Verify Screenshot config
202+ function validateScreenshotConfig ( configFile ) {
203+ // Verify config file exists
250204}
251205
252- module . exports = {
206+ module . exports = {
253207 ValidationError,
254208 validateProjectToken,
255209 validateStorybookUrl,
0 commit comments