Skip to content

Commit 16ee745

Browse files
committed
Sunset the report command
1 parent bf3de4c commit 16ee745

11 files changed

+17
-371
lines changed

src/commands/report/cmd-report-create.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ describe('socket report create', async () => {
4444
'should require args with just dry-run',
4545
async cmd => {
4646
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
47-
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
47+
expect(stdout).toMatchInlineSnapshot(`""`)
4848
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
4949
"
5050
_____ _ _ /---------------
5151
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
5252
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
53-
|_____|___|___|_,_|___|_|.dev | Command: \`socket report create\`, cwd: <redacted>"
53+
|_____|___|___|_,_|___|_|.dev | Command: \`socket report create\`, cwd: <redacted>
54+
55+
\\x1b[31m\\xd7\\x1b[39m This command has been sunset. Instead, please look at \`socket scan create\` to create scans and \`socket scan report\` to view a report of your scans."
5456
`)
5557

5658
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
import path from 'node:path'
2-
31
import { logger } from '@socketsecurity/registry/lib/logger'
42

5-
import { createReport } from './create-report'
6-
import { getSocketConfig } from './get-socket-config'
7-
import { viewReport } from './view-report'
8-
import constants from '../../constants'
93
import { commonFlags, outputFlags, validationFlags } from '../../flags'
10-
import { ColorOrMarkdown } from '../../utils/color-or-markdown'
114
import { meowOrExit } from '../../utils/meow-with-subcommands'
125

136
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
147

15-
const { DRY_RUN_BAIL_TEXT } = constants
16-
178
const config: CliCommandConfig = {
189
commandName: 'create',
1910
description: '[Deprecated] Create a project report',
@@ -51,52 +42,14 @@ async function run(
5142
importMeta: ImportMeta,
5243
{ parentName }: { parentName: string }
5344
): Promise<void> {
54-
const cli = meowOrExit({
45+
meowOrExit({
5546
argv,
5647
config,
5748
importMeta,
5849
parentName
5950
})
6051

61-
// TODO: Allow setting a custom cwd and/or configFile path?
62-
const cwd = process.cwd()
63-
const absoluteConfigPath = path.join(cwd, 'socket.yml')
64-
65-
const dryRun = Boolean(cli.flags['dryRun'])
66-
const json = Boolean(cli.flags['json'])
67-
const markdown = Boolean(cli.flags['markdown'])
68-
const strict = Boolean(cli.flags['strict'])
69-
const includeAllIssues = Boolean(cli.flags['all'])
70-
const view = Boolean(cli.flags['view'])
71-
72-
// Note exiting earlier to skirt a hidden auth requirement
73-
if (cli.flags['dryRun']) {
74-
logger.log(DRY_RUN_BAIL_TEXT)
75-
return
76-
}
77-
78-
const socketConfig = await getSocketConfig(absoluteConfigPath)
79-
80-
const result = await createReport(socketConfig, cli.input, { cwd, dryRun })
81-
82-
const commandName = `${parentName} ${config.commandName}`
83-
84-
if (result?.success) {
85-
if (view) {
86-
const reportId = result.data.id
87-
await viewReport(reportId, {
88-
all: includeAllIssues,
89-
commandName,
90-
outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
91-
strict
92-
})
93-
} else if (json) {
94-
logger.log(JSON.stringify(result.data, undefined, 2))
95-
} else {
96-
const format = new ColorOrMarkdown(markdown)
97-
logger.log(
98-
`New report: ${format.hyperlink(result.data.id, result.data.url, { fallbackToUrl: true })}`
99-
)
100-
}
101-
}
52+
logger.fail(
53+
'This command has been sunset. Instead, please look at `socket scan create` to create scans and `socket scan report` to view a report of your scans.'
54+
)
10255
}

src/commands/report/cmd-report-view.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ describe('socket report create', async () => {
4444
'should require args with just dry-run',
4545
async cmd => {
4646
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
47-
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
47+
expect(stdout).toMatchInlineSnapshot(`""`)
4848
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
4949
"
5050
_____ _ _ /---------------
5151
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
5252
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
53-
|_____|___|___|_,_|___|_|.dev | Command: \`socket report create\`, cwd: <redacted>"
53+
|_____|___|___|_,_|___|_|.dev | Command: \`socket report create\`, cwd: <redacted>
54+
55+
\\x1b[31m\\xd7\\x1b[39m This command has been sunset. Instead, please look at \`socket scan create\` to create scans and \`socket scan report\` to view a report of your scans."
5456
`)
5557

5658
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { logger } from '@socketsecurity/registry/lib/logger'
22

3-
import { viewReport } from './view-report'
43
import constants from '../../constants'
54
import { commonFlags, outputFlags, validationFlags } from '../../flags'
6-
import { handleBadInput } from '../../utils/handle-bad-input'
75
import { meowOrExit } from '../../utils/meow-with-subcommands'
86

97
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
108

11-
const { DRY_RUN_BAIL_TEXT } = constants
12-
139
const config: CliCommandConfig = {
1410
commandName: 'view',
1511
description: '[Deprecated] View a project report',
@@ -36,51 +32,14 @@ async function run(
3632
importMeta: ImportMeta,
3733
{ parentName }: { parentName: string }
3834
): Promise<void> {
39-
const cli = meowOrExit({
35+
meowOrExit({
4036
argv,
4137
config,
4238
importMeta,
4339
parentName
4440
})
4541

46-
const { json, markdown } = cli.flags
47-
const [reportId = '', ...extraInput] = cli.input
48-
49-
const wasBadInput = handleBadInput(
50-
{
51-
test: reportId,
52-
message: 'Need at least one report ID',
53-
pass: 'ok',
54-
fail: 'missing'
55-
},
56-
{
57-
nook: true,
58-
test: extraInput.length === 0,
59-
message: 'Can only handle a single report ID',
60-
pass: 'ok',
61-
fail: 'received ' + (extraInput.length + 1)
62-
},
63-
{
64-
nook: true,
65-
test: !json || !markdown,
66-
message: 'The json and markdown flags cannot be both set, pick one',
67-
pass: 'ok',
68-
fail: 'omit one'
69-
}
42+
logger.fail(
43+
'This command has been sunset. Instead, please look at `socket scan create` to create scans and `socket scan report` to view a report of your scans.'
7044
)
71-
if (wasBadInput) {
72-
return
73-
}
74-
75-
if (cli.flags['dryRun']) {
76-
logger.log(DRY_RUN_BAIL_TEXT)
77-
return
78-
}
79-
80-
await viewReport(reportId, {
81-
all: Boolean(cli.flags['all']),
82-
commandName: `${parentName} ${config.commandName}`,
83-
outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
84-
strict: Boolean(cli.flags['strict'])
85-
})
8645
}

src/commands/report/create-report.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/commands/report/fetch-report-data.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/commands/report/format-report-data.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)