Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve diff scan command #189

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .dep-stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"emoji-regex": "^10.3.0",
"fast-glob": "^3.3.2",
"graceful-fs": "^4.2.6",
"has-flag": "^4.0.0",
"hpagent": "^1.2.0",
"ignore": "^5.3.1",
"ini": "4.1.3",
Expand All @@ -113,7 +114,8 @@
"registry-auth-token": "^5.0.2",
"semver": "^7.6.2",
"signal-exit": "^4.1.0",
"supports-hyperlinks": "^2.2.0",
"supports-color": "^7.0.0",
"supports-hyperlinks": "^3.1.0",
"synp": "^1.9.13",
"which": "^4.0.0",
"write-file-atomic": "^5.0.1",
Expand All @@ -129,14 +131,16 @@
"emoji-regex": "^10.3.0",
"fast-glob": "^3.3.2",
"graceful-fs": "^4.2.6",
"has-flag": "^4.0.0",
"ini": "4.1.3",
"node-domexception": "^1.0.0",
"onetime": "^5.1.0",
"rc": "1.2.8",
"registry-auth-token": "^5.0.2",
"semver": "^7.6.2",
"signal-exit": "^4.1.0",
"supports-hyperlinks": "^2.2.0",
"supports-color": "^7.0.0",
"supports-hyperlinks": "^3.1.0",
"write-file-atomic": "^5.0.1"
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"emoji-regex": "^10.3.0",
"fast-glob": "^3.3.2",
"graceful-fs": "^4.2.6",
"has-flag": "^4.0.0",
"hpagent": "^1.2.0",
"ignore": "^5.3.1",
"ini": "4.1.3",
Expand All @@ -53,6 +54,7 @@
"registry-auth-token": "^5.0.2",
"semver": "^7.6.2",
"signal-exit": "^4.1.0",
"supports-color": "^7.0.0",
"supports-hyperlinks": "^3.1.0",
"synp": "^1.9.13",
"which": "^4.0.0",
Expand Down
21 changes: 16 additions & 5 deletions src/commands/diff-scan/get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk'

Check warning on line 1 in src/commands/diff-scan/get.ts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

There should be at least one empty line between import groups
import fs from 'fs'
import meow from 'meow'
import ora from 'ora'
Expand Down Expand Up @@ -138,7 +138,7 @@
}

async function getDiffScan(
{ before, after, orgSlug, file }: CommandContext,
{ before, after, orgSlug, file, outputJson }: CommandContext,
spinner: Ora,
apiKey: string,
): Promise<void> {
Expand All @@ -156,13 +156,24 @@

spinner.stop()

if(file){
if(file && !outputJson){
fs.writeFile(file, JSON.stringify(data), err => {
err ? console.error(err) : console.log(`Data successfully written to ${file}`)
})
return
}

console.log(`\n Diff scan result: \n`)
console.log(util.inspect(data, {showHidden: false, depth: null, colors: true}))
}
if(outputJson){
console.log(`\n Diff scan result: \n`)
console.log(util.inspect(data, {showHidden: false, depth: null, colors: true}))
// @ts-ignore
console.log(`\n View this diff scan in the Socket dashboard: ${chalk.cyan(data.diff_report_url)} \n`)
return
}

console.log("Diff scan result: ")
console.log(data)
console.log(`\n 📝 To display the detailed report in the terminal, use the --json flag \n`)
// @ts-ignore
console.log(`\n View this diff scan in the Socket dashboard: ${chalk.cyan(data.diff_report_url)} \n`)
}
Loading