Skip to content

Commit

Permalink
Add prompt to open new full scan in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
charliegerard committed Jun 11, 2024
1 parent 99eb85f commit 1f64f21
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
21 changes: 16 additions & 5 deletions lib/commands/fullscans/create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* eslint-disable no-console */

import { stdin as inputText, stdout as output } from 'node:process'
import * as readline from 'node:readline/promises'

import chalk from 'chalk'
import meow from 'meow'
import open from 'open'
import ora from 'ora'
import { ErrorWithCause } from 'pony-cause'

Expand All @@ -21,7 +25,7 @@ export const create = {

const input = await setupCommand(name, create.description, argv, importMeta)
if (input) {
const spinnerText = 'Creating a full scan...'
const spinnerText = 'Creating a full scan... \n'
const spinner = ora(spinnerText).start()

await createFullScan(input, spinner)
Expand Down Expand Up @@ -197,12 +201,19 @@ async function createFullScan (input, spinner) {
if (!result.success) {
return handleUnsuccessfulApiResponse('CreateOrgFullScan', result, spinner)
}
spinner.stop()

console.log('\n Full scan created successfully \n')
const link = chalk.hex('#FF08E8').underline(`${result.data.html_report_url}`)
console.log(`Check it out at ${link} \n`)
console.log('\n Full scan created successfully \n')
const link = chalk.hex('#00FFFF').underline(`${result.data.html_report_url}`)
console.log(`Available at: ${link} \n`)

spinner.stop()
const rl = readline.createInterface({ input: inputText, output })

const answer = await rl.question('Would you like to open it in your browser? (y/n) ')

answer.toLowerCase() === 'y' && open(`${result.data.html_report_url}`)

rl.close()

return {
data: result.data
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/fullscans/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function deleteOrgFullScan (orgSlug, fullScanId, spinner) {
return handleUnsuccessfulApiResponse('deleteOrgFullScan', result, spinner)
}

console.log('\n Full scan deleted successfully. \n')
console.log('\n Full scan deleted successfully. \n')

spinner.stop()

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"//postinstall": "node ./cli.js wrapper --postinstall"
},
"devDependencies": {
"@socketsecurity/eslint-config": "^3.0.1",
"@socketsecurity/eslint-config": "^3.0.0",
"@tsconfig/node14": "^14.1.0",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
Expand Down Expand Up @@ -92,9 +92,11 @@
"is-interactive": "^2.0.0",
"is-unicode-supported": "^1.3.0",
"meow": "^12.0.1",
"open": "^9.1.0",
"ora": "^7.0.1",
"pony-cause": "^2.1.8",
"prompts": "^2.4.2",
"strip-ansi": "^7.1.0",
"terminal-link": "^3.0.0",
"update-notifier": "^6.0.2",
"which": "^3.0.0"
Expand Down

0 comments on commit 1f64f21

Please sign in to comment.