@@ -6,15 +6,18 @@ import auth from '../tasks/auth.js'
66import  ctxInit  from  '../lib/ctx.js' 
77import  getGitInfo  from  '../tasks/getGitInfo.js' 
88import  finalizeBuild  from  '../tasks/finalizeBuild.js' 
9- import  {  validateFigmaDesignConfig ,  validateWebFigmaConfig  }  from  '../lib/schemaValidation.js' 
9+ import  {  validateFigmaDesignConfig ,  validateWebFigmaConfig ,   validateAppFigmaConfig  }  from  '../lib/schemaValidation.js' 
1010import  uploadFigmaDesigns  from  '../tasks/uploadFigmaDesigns.js' 
1111import  uploadWebFigma  from  '../tasks/uploadWebFigma.js' 
12+ import  uploadAppFigma  from  '../tasks/uploadAppFigma.js'      
1213import  {  verifyFigmaWebConfig  }  from  '../lib/config.js' 
1314import  chalk  from  'chalk' ; 
1415
1516
1617const  uploadFigma  =  new  Command ( ) ; 
1718const  uploadWebFigmaCommand  =  new  Command ( ) ; 
19+ const  uploadAppFigmaCommand  =  new  Command ( ) ; 
20+ 
1821
1922uploadFigma 
2023    . name ( 'upload-figma' ) 
@@ -68,7 +71,7 @@ uploadFigma
6871
6972uploadWebFigmaCommand 
7073    . name ( 'upload-figma-web' ) 
71-     . description ( 'Capture screenshots of static sites ' ) 
74+     . description ( 'Capture figma  screenshots into CLI build ' ) 
7275    . argument ( '<file>' ,  'figma config config file' ) 
7376    . option ( '--markBaseline' ,  'Mark the uploaded images as baseline' ) 
7477    . option ( '--buildName <buildName>' ,  'Name of the build' ) 
@@ -130,4 +133,71 @@ uploadWebFigmaCommand
130133
131134    } ) 
132135
133- export  {  uploadFigma ,  uploadWebFigmaCommand  } 
136+ 
137+ 
138+     uploadAppFigmaCommand 
139+     . name ( 'upload-figma-app' ) 
140+     . description ( 'Capture figma screenshots into App Build' ) 
141+     . argument ( '<file>' ,  'figma config config file' ) 
142+     . option ( '--markBaseline' ,  'Mark the uploaded images as baseline' ) 
143+     . option ( '--buildName <buildName>' ,  'Name of the build' ) 
144+     . option ( '--fetch-results [filename]' ,  'Fetch results and optionally specify an output file, e.g., <filename>.json' ) 
145+     . action ( async  function  ( file ,  _ ,  command )  { 
146+         let  ctx : Context  =  ctxInit ( command . optsWithGlobals ( ) ) ; 
147+ 
148+         if  ( ! fs . existsSync ( file ) )  { 
149+             console . log ( `Error: figma-app config file ${ file }   not found.` ) ; 
150+             return ; 
151+         } 
152+         try  { 
153+             ctx . config  =  JSON . parse ( fs . readFileSync ( file ,  'utf8' ) ) ; 
154+             ctx . log . info ( JSON . stringify ( ctx . config ) ) ; 
155+             if  ( ! validateAppFigmaConfig ( ctx . config ) )  { 
156+                 ctx . log . debug ( JSON . stringify ( validateAppFigmaConfig . errors ,  null ,  2 ) ) ; 
157+                 // Iterate and add warning for "additionalProperties" 
158+                 validateAppFigmaConfig . errors ?. forEach ( error  =>  { 
159+                     if  ( error . keyword  ===  "additionalProperties" )  { 
160+                         ctx . log . warn ( `Additional property "${ error . params . additionalProperty }  " is not allowed.` ) 
161+                     }  else  { 
162+                         const  validationError  =  error . message ; 
163+                         throw  new  Error ( validationError  ||  'Invalid figma-app config found in file : '  +  file ) ; 
164+                     } 
165+                 } ) ; 
166+             } 
167+ 
168+             //Validate the figma config 
169+             verifyFigmaWebConfig ( ctx ) ; 
170+         }  catch  ( error : any )  { 
171+             ctx . log . error ( chalk . red ( `Invalid figma-app config; ${ error . message }  ` ) ) ; 
172+             return ; 
173+         } 
174+ 
175+         let  tasks  =  new  Listr < Context > ( 
176+             [ 
177+                 auth ( ctx ) , 
178+                 getGitInfo ( ctx ) , 
179+                 uploadAppFigma ( ctx ) , 
180+                 finalizeBuild ( ctx ) 
181+             ] , 
182+             { 
183+                 rendererOptions : { 
184+                     icon : { 
185+                         [ ListrDefaultRendererLogLevels . OUTPUT ] : `→` 
186+                     } , 
187+                     color : { 
188+                         [ ListrDefaultRendererLogLevels . OUTPUT ] : color . gray  as  LoggerFormat 
189+                     } 
190+                 } 
191+             } 
192+         ) 
193+ 
194+         try  { 
195+             await  tasks . run ( ctx ) ; 
196+         }  catch  ( error )  { 
197+             console . log ( '\nRefer docs: https://www.lambdatest.com/support/docs/smart-visual-regression-testing/' ) ; 
198+         } 
199+ 
200+     } ) 
201+ 
202+ 
203+ export  {  uploadFigma ,  uploadWebFigmaCommand ,  uploadAppFigmaCommand  } 
0 commit comments