@@ -77,7 +77,10 @@ export async function handleCreateNewScan({
7777
7878 const supportedFilesCResult = await fetchSupportedScanFileNames ( )
7979 if ( ! supportedFilesCResult . ok ) {
80- await outputCreateNewScan ( supportedFilesCResult , outputKind , interactive )
80+ await outputCreateNewScan ( supportedFilesCResult , {
81+ interactive,
82+ outputKind,
83+ } )
8184 return
8285 }
8386
@@ -141,7 +144,7 @@ export async function handleCreateNewScan({
141144 spinner . stop ( )
142145
143146 if ( ! reachResult . ok ) {
144- await outputCreateNewScan ( reachResult , outputKind , interactive )
147+ await outputCreateNewScan ( reachResult , { interactive, outputKind } )
145148 return
146149 }
147150
@@ -199,12 +202,17 @@ export async function handleCreateNewScan({
199202 cause : 'Server did not respond with a scan ID' ,
200203 data : fullScanCResult . data ,
201204 } ,
202- outputKind ,
203- interactive ,
205+ {
206+ interactive,
207+ outputKind,
208+ } ,
204209 )
205210 }
206211 } else {
207- await outputCreateNewScan ( fullScanCResult , outputKind , interactive )
212+ spinner . stop ( )
213+ spinner . clear ( )
214+
215+ await outputCreateNewScan ( fullScanCResult , { interactive, outputKind } )
208216 }
209217}
210218
@@ -250,7 +258,7 @@ async function performReachabilityAnalysis(
250258
251259 const sockSdk = sockSdkCResult . data
252260
253- const wasSpinning = spinner ?. isSpinning ?? false
261+ const wasSpinning = ! ! spinner ?. isSpinning
254262
255263 // Upload manifests to get tar hash
256264 spinner ?. start ( 'Uploading manifests for reachability analysis...' )
@@ -266,17 +274,20 @@ async function performReachabilityAnalysis(
266274 spinner,
267275 } ,
268276 )
277+
278+ spinner ?. stop ( )
279+
269280 if ( ! uploadCResult . ok ) {
270- if ( ! wasSpinning ) {
271- spinner ?. stop ( )
281+ if ( wasSpinning ) {
282+ spinner . start ( )
272283 }
273284 return uploadCResult
274285 }
275286
276287 const tarHash = ( uploadCResult . data as { tarHash ?: string } ) ?. tarHash
277288 if ( ! tarHash ) {
278- if ( ! wasSpinning ) {
279- spinner ?. stop ( )
289+ if ( wasSpinning ) {
290+ spinner . start ( )
280291 }
281292 return {
282293 ok : false ,
@@ -285,11 +296,11 @@ async function performReachabilityAnalysis(
285296 }
286297 }
287298
299+ spinner ?. start ( )
288300 spinner ?. success ( `Manifests uploaded successfully. Tar hash: ${ tarHash } ` )
301+ spinner ?. infoAndStop ( 'Running reachability analysis with Coana...' )
289302
290303 // Run Coana with the manifests tar hash.
291- spinner ?. info ( 'Running reachability analysis with Coana...' )
292-
293304 const coanaResult = await spawnCoana (
294305 [
295306 'run' ,
@@ -304,29 +315,29 @@ async function performReachabilityAnalysis(
304315 ] ,
305316 {
306317 cwd,
307- stdio : 'inherit' ,
308318 env : {
309319 ...process . env ,
310320 SOCKET_REPO_NAME : repoName ,
311321 SOCKET_BRANCH_NAME : branchName ,
312322 } ,
323+ spinner,
324+ stdio : 'inherit' ,
313325 } ,
314326 )
315327
316- if ( ! wasSpinning ) {
317- spinner ?. stop ( )
318- }
319- if ( ! coanaResult . ok ) {
320- return coanaResult
321- }
322- // Use the DOT_SOCKET_DOT_FACTS_JSON file for the scan.
323- return {
324- ok : true ,
325- data : {
326- scanPaths : [ constants . DOT_SOCKET_DOT_FACTS_JSON ] ,
327- tier1ReachabilityScanId : extractTier1ReachabilityScanId (
328- constants . DOT_SOCKET_DOT_FACTS_JSON ,
329- ) ,
330- } ,
328+ if ( wasSpinning ) {
329+ spinner . start ( )
331330 }
331+ return coanaResult . ok
332+ ? {
333+ ok : true ,
334+ data : {
335+ // Use the DOT_SOCKET_DOT_FACTS_JSON file for the scan.
336+ scanPaths : [ constants . DOT_SOCKET_DOT_FACTS_JSON ] ,
337+ tier1ReachabilityScanId : extractTier1ReachabilityScanId (
338+ constants . DOT_SOCKET_DOT_FACTS_JSON ,
339+ ) ,
340+ } ,
341+ }
342+ : coanaResult
332343}
0 commit comments