diff --git a/src/commands/diff-scan/get-diff-scan.ts b/src/commands/diff-scan/get-diff-scan.ts index 11cdc8875..044cbaaf1 100644 --- a/src/commands/diff-scan/get-diff-scan.ts +++ b/src/commands/diff-scan/get-diff-scan.ts @@ -36,7 +36,9 @@ export async function getDiffScan( if (!response.ok) { const err = await handleAPIError(response.status) - spinner.error(`${colors.bgRed(colors.white(response.statusText))}: ${err}`) + spinner.errorAndStop( + `${colors.bgRed(colors.white(response.statusText))}: ${err}` + ) return } diff --git a/src/commands/fix/run-fix.ts b/src/commands/fix/run-fix.ts index 2511c59b3..37460fe4e 100644 --- a/src/commands/fix/run-fix.ts +++ b/src/commands/fix/run-fix.ts @@ -113,7 +113,7 @@ export async function runFix() { // eslint-disable-next-line no-await-in-loop await editablePkgJson.save() } catch { - spinner.error(`Reverting ${name} to ${oldVersion}`) + spinner.errorAndStop(`Reverting ${name} to ${oldVersion}`) spinner.start() arb.idealTree = revertToIdealTree } diff --git a/src/commands/info/format-package-info.ts b/src/commands/info/format-package-info.ts index 440c5ea80..3aad7f05b 100644 --- a/src/commands/info/format-package-info.ts +++ b/src/commands/info/format-package-info.ts @@ -58,7 +58,7 @@ export function formatPackageInfo( ) formatPackageIssuesDetails(data, outputMarkdown) } else { - spinner.success('Package has no issues') + spinner.successAndStop('Package has no issues') } const format = new ColorOrMarkdown(!!outputMarkdown) diff --git a/src/commands/login/attempt-login.ts b/src/commands/login/attempt-login.ts index 4ba839532..468f53e67 100644 --- a/src/commands/login/attempt-login.ts +++ b/src/commands/login/attempt-login.ts @@ -55,7 +55,7 @@ export async function attemptLogin( orgs = result.data spinner.success('API key verified') } catch { - spinner.error('Invalid API key') + spinner.errorAndStop('Invalid API key') return } @@ -97,8 +97,8 @@ export async function attemptLogin( const oldToken = getSetting('apiToken') try { applyLogin(apiToken, enforcedOrgs, apiBaseUrl, apiProxy) - spinner.success(`API credentials ${oldToken ? 'updated' : 'set'}`) + spinner.successAndStop(`API credentials ${oldToken ? 'updated' : 'set'}`) } catch { - spinner.error(`API login failed`) + spinner.errorAndStop(`API login failed`) } } diff --git a/src/commands/manifest/convert_gradle_to_maven.ts b/src/commands/manifest/convert_gradle_to_maven.ts index 9da0eddf1..77043e2cb 100644 --- a/src/commands/manifest/convert_gradle_to_maven.ts +++ b/src/commands/manifest/convert_gradle_to_maven.ts @@ -53,7 +53,7 @@ export async function convertGradleToMaven( const output = await spawn(bin, commandArgs, { cwd: target || '.' }) - spinner.success() + spinner.stop() if (verbose) { console.group('[VERBOSE] gradle stdout:') console.log(output) @@ -61,7 +61,7 @@ export async function convertGradleToMaven( } if (output.stderr) { - spinner.error('There were errors while running gradle') + spinner.errorAndStop('There were errors while running gradle') // (In verbose mode, stderr was printed above, no need to repeat it) if (!verbose) { console.group('[VERBOSE] stderr:') @@ -71,6 +71,9 @@ export async function convertGradleToMaven( process.exit(1) } + spinner.start() + spinner.successAndStop('Executed gradle successfully') + console.log('Reported exports:') output.stdout.replace( /^POM file copied to: (.*)/gm, @@ -82,7 +85,7 @@ export async function convertGradleToMaven( // const loc = output.stdout?.match(/Wrote (.*?.pom)\n/)?.[1]?.trim() // if (!loc) { - // spinner.error( + // spinner.errorAndStop( // 'There were no errors from sbt but could not find the location of resulting .pom file either' // ) // process.exit(1) @@ -104,11 +107,11 @@ export async function convertGradleToMaven( // } // // TODO: do we prefer fs-extra? renaming can be gnarly on windows and fs-extra's version is better // await renamep(loc, out) - // spinner.success() + // spinner.successAndStop() // spinner.start().success(`OK. File should be available in \`${out}\``) // } } catch (e) { - spinner.error( + spinner.errorAndStop( 'There was an unexpected error while running this' + (verbose ? '' : ' (use --verbose for details)') ) diff --git a/src/commands/manifest/convert_sbt_to_maven.ts b/src/commands/manifest/convert_sbt_to_maven.ts index ea04252f6..7c7e31d2a 100644 --- a/src/commands/manifest/convert_sbt_to_maven.ts +++ b/src/commands/manifest/convert_sbt_to_maven.ts @@ -43,7 +43,7 @@ export async function convertSbtToMaven( const output = await spawn(bin, ['makePom'].concat(sbtOpts), { cwd: target || '.' }) - spinner.success() + spinner.successAndStop() if (verbose) { console.group('[VERBOSE] sbt stdout:') console.log(output) @@ -51,7 +51,8 @@ export async function convertSbtToMaven( } if (output.stderr) { - spinner.error('There were errors while running sbt') + spinner.start() + spinner.errorAndStop('There were errors while running sbt') // (In verbose mode, stderr was printed above, no need to repeat it) if (!verbose) { console.group('[VERBOSE] stderr:') @@ -68,7 +69,7 @@ export async function convertSbtToMaven( }) if (!poms.length) { - spinner.error( + spinner.errorAndStop( 'There were no errors from sbt but it seems to not have generated any poms either' ) process.exit(1) @@ -106,7 +107,7 @@ export async function convertSbtToMaven( spinner.start().success(`OK`) } } catch (e) { - spinner.error( + spinner.errorAndStop( 'There was an unexpected error while running this' + (verbose ? '' : ' (use --verbose for details)') ) diff --git a/src/commands/report/create-report.ts b/src/commands/report/create-report.ts index 570de1743..50cdfa463 100644 --- a/src/commands/report/create-report.ts +++ b/src/commands/report/create-report.ts @@ -73,7 +73,7 @@ export async function createReport( handleUnsuccessfulApiResponse('createReport', result, spinner) return undefined } - spinner.success() + spinner.successAndStop() return result } } diff --git a/src/commands/report/fetch-report-data.ts b/src/commands/report/fetch-report-data.ts index 69386b302..fb31f0e83 100644 --- a/src/commands/report/fetch-report-data.ts +++ b/src/commands/report/fetch-report-data.ts @@ -54,9 +54,9 @@ export async function fetchReportData( if (strict) { if (result.data.healthy) { - spinner.success('Report result is healthy and great!') + spinner.successAndStop('Report result is healthy and great!') } else { - spinner.error('Report result deemed unhealthy for project') + spinner.errorAndStop('Report result deemed unhealthy for project') } } else if (!result.data.healthy) { const severityCount = getSeverityCount( @@ -64,9 +64,9 @@ export async function fetchReportData( includeAllIssues ? undefined : 'high' ) const issueSummary = formatSeverityCount(severityCount) - spinner.success(`Report has these issues: ${issueSummary}`) + spinner.successAndStop(`Report has these issues: ${issueSummary}`) } else { - spinner.success('Report has no issues') + spinner.successAndStop('Report has no issues') } return result.data diff --git a/src/commands/repos/create-repo.ts b/src/commands/repos/create-repo.ts index fe9bbbdc6..ad8566ff7 100644 --- a/src/commands/repos/create-repo.ts +++ b/src/commands/repos/create-repo.ts @@ -43,7 +43,7 @@ export async function createRepo({ ) if (result.success) { - spinner.success('Repository created successfully') + spinner.successAndStop('Repository created successfully') } else { handleUnsuccessfulApiResponse('createOrgRepo', result, spinner) } diff --git a/src/commands/repos/delete-repo.ts b/src/commands/repos/delete-repo.ts index c149fbb55..9f65bf722 100644 --- a/src/commands/repos/delete-repo.ts +++ b/src/commands/repos/delete-repo.ts @@ -18,7 +18,7 @@ export async function deleteRepo( ) if (result.success) { - spinner.success('Repository deleted successfully') + spinner.successAndStop('Repository deleted successfully') } else { handleUnsuccessfulApiResponse('deleteOrgRepo', result, spinner) } diff --git a/src/commands/repos/update-repo.ts b/src/commands/repos/update-repo.ts index 6eb7ba09e..bc417b350 100644 --- a/src/commands/repos/update-repo.ts +++ b/src/commands/repos/update-repo.ts @@ -43,7 +43,7 @@ export async function updateRepo({ ) if (result.success) { - spinner.success('Repository updated successfully') + spinner.successAndStop('Repository updated successfully') } else { handleUnsuccessfulApiResponse('updateOrgRepo', result, spinner) } diff --git a/src/commands/scan/delete-full-scan.ts b/src/commands/scan/delete-full-scan.ts index c662ac84b..0dd9e2789 100644 --- a/src/commands/scan/delete-full-scan.ts +++ b/src/commands/scan/delete-full-scan.ts @@ -18,7 +18,7 @@ export async function deleteOrgFullScan( ) if (result.success) { - spinner.success('Scan deleted successfully') + spinner.successAndStop('Scan deleted successfully') } else { handleUnsuccessfulApiResponse('deleteOrgFullScan', result, spinner) }