Skip to content

Commit 8de0359

Browse files
committed
wip
1 parent ff2e5b7 commit 8de0359

File tree

5 files changed

+29
-24
lines changed

5 files changed

+29
-24
lines changed

lib/commands/fullscans/create.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import { getDefaultKey, setupSdk } from '../../utils/sdk.js'
1919

2020
/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */
2121
export const create = {
22-
description: 'Create a full scan',
22+
description: 'Create a scan',
2323
async run (argv, importMeta, { parentName }) {
2424
const name = parentName + ' create'
2525

2626
const input = await setupCommand(name, create.description, argv, importMeta)
2727
if (input) {
28-
const spinnerText = 'Creating a full scan... \n'
28+
const spinnerText = 'Creating a scan... \n'
2929
const spinner = ora(spinnerText).start()
3030

3131
await createFullScan(input, spinner)
@@ -85,7 +85,7 @@ const createFullScanFlags = prepareFlags({
8585
type: 'boolean',
8686
shortFlag: 't',
8787
default: false,
88-
description: 'Set the visibility (true/false) of the full scan in your dashboard',
88+
description: 'Set the visibility (true/false) of the scan in your dashboard',
8989
}
9090
})
9191

@@ -213,14 +213,14 @@ async function createFullScan (input, spinner) {
213213
make_default_branch: defaultBranch,
214214
set_as_pending_head: pendingHead,
215215
tmp
216-
}, packagePaths), 'Creating full scan')
216+
}, packagePaths), 'Creating scan')
217217

218218
if (!result.success) {
219219
return handleUnsuccessfulApiResponse('CreateOrgFullScan', result, spinner)
220220
}
221221
spinner.stop()
222222

223-
console.log('\n✅ Full scan created successfully \n')
223+
console.log('\n✅ Scan created successfully \n')
224224
const link = chalk.hex('#00FFFF').underline(`${result.data.html_report_url}`)
225225
console.log(`Available at: ${link} \n`)
226226

lib/commands/fullscans/delete.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { getDefaultKey, setupSdk } from '../../utils/sdk.js'
1111

1212
/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */
1313
export const del = {
14-
description: 'Delete a full scan',
14+
description: 'Delete a scan',
1515
async run (argv, importMeta, { parentName }) {
1616
const name = parentName + ' del'
1717

1818
const input = setupCommand(name, del.description, argv, importMeta)
1919
if (input) {
20-
const spinnerText = 'Deleting full scan...'
20+
const spinnerText = 'Deleting scan...'
2121
const spinner = ora(spinnerText).start()
2222
await deleteOrgFullScan(input.orgSlug, input.fullScanId, spinner)
2323
}
@@ -48,7 +48,7 @@ function setupCommand (name, description, argv, importMeta) {
4848

4949
const cli = meow(`
5050
Usage
51-
$ ${name} <org slug> <full scan ID>
51+
$ ${name} <org slug> <scan ID>
5252
5353
Options
5454
${printFlagList(flags, 6)}
@@ -68,7 +68,10 @@ function setupCommand (name, description, argv, importMeta) {
6868
} = cli.flags
6969

7070
if (cli.input.length < 2) {
71-
throw new InputError('Please specify an organization slug and a full scan ID.')
71+
throw new InputError(`Please specify an organization slug and a scan ID. \n
72+
Example:
73+
socket scan del FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
74+
`)
7275
}
7376

7477
const orgSlug = cli.input[0] || ''
@@ -95,13 +98,13 @@ function setupCommand (name, description, argv, importMeta) {
9598
*/
9699
async function deleteOrgFullScan (orgSlug, fullScanId, spinner) {
97100
const socketSdk = await setupSdk(getDefaultKey())
98-
const result = await handleApiCall(socketSdk.deleteOrgFullScan(orgSlug, fullScanId), 'Deleting full scan')
101+
const result = await handleApiCall(socketSdk.deleteOrgFullScan(orgSlug, fullScanId), 'Deleting scan')
99102

100103
if (!result.success) {
101104
return handleUnsuccessfulApiResponse('deleteOrgFullScan', result, spinner)
102105
}
103106

104-
console.log('\n ✅ Full scan deleted successfully. \n')
107+
console.log('\n ✅ Scan deleted successfully. \n')
105108

106109
spinner.stop()
107110

lib/commands/fullscans/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { list } from './list.js'
44
import { stream } from './stream.js'
55
import { meowWithSubcommands } from '../../utils/meow-with-subcommands.js'
66

7-
const description = 'Full scans related commands'
7+
const description = 'Scans related commands'
88

99
/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */
1010
export const fullscans = {

lib/commands/fullscans/list.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import { getDefaultKey, setupSdk } from '../../utils/sdk.js'
1515

1616
/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */
1717
export const list = {
18-
description: 'List full scans',
18+
description: 'List scans',
1919
async run (argv, importMeta, { parentName }) {
2020
const name = parentName + ' list'
2121

2222
const input = setupCommand(name, list.description, argv, importMeta)
2323
if (input) {
24-
const spinnerText = 'Listing full scans... \n'
24+
const spinnerText = 'Listing scans... \n'
2525
const spinner = ora(spinnerText).start()
2626
await listOrgFullScan(input.orgSlug, input, spinner)
2727
}
@@ -155,19 +155,19 @@ function setupCommand (name, description, argv, importMeta) {
155155
async function listOrgFullScan (orgSlug, input, spinner) {
156156
const socketSdk = await setupSdk(getDefaultKey())
157157
// @ts-ignore
158-
const result = await handleApiCall(socketSdk.getOrgFullScanList(orgSlug, input), 'Listing full scans')
158+
const result = await handleApiCall(socketSdk.getOrgFullScanList(orgSlug, input), 'Listing scans')
159159

160160
if (!result.success) {
161161
return handleUnsuccessfulApiResponse('getOrgFullScanList', result, spinner)
162162
}
163163
spinner.stop()
164164

165-
console.log(`\n Listing full scans for: ${orgSlug} \n`)
165+
console.log(`\n Listing scans for: ${orgSlug} \n`)
166166

167167
const options = {
168168
columns: [
169169
{ field: 'id', name: chalk.magenta('ID') },
170-
{ field: 'report_url', name: chalk.magenta('Report URL') },
170+
{ field: 'report_url', name: chalk.magenta('Scan URL') },
171171
{ field: 'branch', name: chalk.magenta('Branch') },
172172
{ field: 'created_at', name: chalk.magenta('Created at') }
173173
]

lib/commands/fullscans/stream.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { getDefaultKey, setupSdk } from '../../utils/sdk.js'
1111

1212
/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */
1313
export const stream = {
14-
description: 'Stream a full scan',
14+
description: 'Stream a scan',
1515
async run (argv, importMeta, { parentName }) {
1616
const name = parentName + ' stream'
1717

1818
const input = setupCommand(name, stream.description, argv, importMeta)
1919
if (input) {
20-
const spinnerText = 'Streaming full scan... \n'
20+
const spinnerText = 'Streaming scan... \n'
2121
const spinner = ora(spinnerText).start()
2222
await getOrgFullScan(input.orgSlug, input.fullScanId, input.file, spinner)
2323
}
@@ -49,7 +49,7 @@ function setupCommand (name, description, argv, importMeta) {
4949

5050
const cli = meow(`
5151
Usage
52-
$ ${name} <org slug> <full scan ID> <file>
52+
$ ${name} <org slug> <scan ID> <file>
5353
5454
Options
5555
${printFlagList(flags, 6)}
@@ -69,7 +69,10 @@ function setupCommand (name, description, argv, importMeta) {
6969
} = cli.flags
7070

7171
if (cli.input.length < 2) {
72-
throw new InputError('Please specify an organization slug and a full scan ID.')
72+
throw new InputError(`Please specify an organization slug and a scan ID.\n
73+
Example:
74+
socket scan stream FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
75+
`)
7376
}
7477

7578
const orgSlug = cli.input[0] || ''
@@ -93,14 +96,13 @@ function setupCommand (name, description, argv, importMeta) {
9396
/**
9497
* @param {string} orgSlug
9598
* @param {string} fullScanId
96-
* @param {string|undefined} file
99+
* @param {string | undefined} file
97100
* @param {import('ora').Ora} spinner
98101
* @returns {Promise<void|FullScanData>}
99102
*/
100103
async function getOrgFullScan (orgSlug, fullScanId, file, spinner) {
101104
const socketSdk = await setupSdk(getDefaultKey())
102-
// @ts-ignore
103-
const result = await handleApiCall(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a full scan')
105+
const result = await handleApiCall(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a scan')
104106

105107
if (!result?.success) {
106108
return handleUnsuccessfulApiResponse('getOrgFullScan', result, spinner)

0 commit comments

Comments
 (0)