@@ -6,15 +6,18 @@ import auth from '../tasks/auth.js'
6
6
import ctxInit from '../lib/ctx.js'
7
7
import getGitInfo from '../tasks/getGitInfo.js'
8
8
import finalizeBuild from '../tasks/finalizeBuild.js'
9
- import { validateFigmaDesignConfig , validateWebFigmaConfig } from '../lib/schemaValidation.js'
9
+ import { validateFigmaDesignConfig , validateWebFigmaConfig , validateAppFigmaConfig } from '../lib/schemaValidation.js'
10
10
import uploadFigmaDesigns from '../tasks/uploadFigmaDesigns.js'
11
11
import uploadWebFigma from '../tasks/uploadWebFigma.js'
12
+ import uploadAppFigma from '../tasks/uploadAppFigma.js'
12
13
import { verifyFigmaWebConfig } from '../lib/config.js'
13
14
import chalk from 'chalk' ;
14
15
15
16
16
17
const uploadFigma = new Command ( ) ;
17
18
const uploadWebFigmaCommand = new Command ( ) ;
19
+ const uploadAppFigmaCommand = new Command ( ) ;
20
+
18
21
19
22
uploadFigma
20
23
. name ( 'upload-figma' )
@@ -68,7 +71,7 @@ uploadFigma
68
71
69
72
uploadWebFigmaCommand
70
73
. name ( 'upload-figma-web' )
71
- . description ( 'Capture screenshots of static sites ' )
74
+ . description ( 'Capture figma screenshots into CLI build ' )
72
75
. argument ( '<file>' , 'figma config config file' )
73
76
. option ( '--markBaseline' , 'Mark the uploaded images as baseline' )
74
77
. option ( '--buildName <buildName>' , 'Name of the build' )
@@ -130,4 +133,71 @@ uploadWebFigmaCommand
130
133
131
134
} )
132
135
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