Skip to content
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
4 changes: 2 additions & 2 deletions src/commands/analytics/cmd-analytics.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('socket analytics', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket analytics`'
)
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('socket analytics', async () => {
\\x1b[39m"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket analytics`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/audit-log/cmd-audit-log.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('socket audit-log', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket audit-log\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket audit-log`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cdxgen/cmd-cdxgen.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('socket cdxgen', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket cdxgen\`, cwd: <redacted>"
`)

// expect(code, 'help should exit with code 2').toBe(2)
// expect(code, 'explicit help should exit with code 0').toBe(0)
expect(code, 'help should exit with code 2').toBe(0) // cdxgen special case
expect(stderr, 'banner includes base command').toContain('`socket cdxgen`')
})
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ci/cmd-ci.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('socket ci', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket ci\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket ci`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/cmd-config-get.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('socket config get', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket config get`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/cmd-config-list.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('socket config get', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket config list\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket config list`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/cmd-config-set.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('socket config get', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket config set\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket config set`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/cmd-config-unset.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('socket config unset', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket config unset\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket config unset`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/cmd-config.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('socket config', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket config\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket config`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/dependencies/cmd-dependencies.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('socket dependencies', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket dependencies\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket dependencies`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/diff-scan/cmd-diff-scan-get.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('socket diff-scan get', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket diff-scan get\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket diff-scan get`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/diff-scan/cmd-diff-scan.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('socket diff-scan', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket diff-scan\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket diff-scan`'
)
Expand Down
31 changes: 3 additions & 28 deletions src/commands/diff-scan/fetch-diff-scan.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import constants from '../../constants.mts'
import { handleApiError, queryApi } from '../../utils/api.mts'
import { getDefaultToken } from '../../utils/sdk.mts'
import { queryApiSafeJson } from '../../utils/api.mts'

import type { CResult } from '../../types.mts'
import type { SocketSdkReturnType } from '@socketsecurity/sdk'
Expand All @@ -14,31 +12,8 @@ export async function fetchDiffScan({
before: string
orgSlug: string
}): Promise<CResult<SocketSdkReturnType<'GetOrgDiffScan'>['data']>> {
const apiToken = getDefaultToken()

// Lazily access constants.spinner.
const { spinner } = constants

spinner.start('Fetching diff-scan...')

const response = await queryApi(
return await queryApiSafeJson<SocketSdkReturnType<'GetOrgDiffScan'>['data']>(
`orgs/${orgSlug}/full-scans/diff?before=${encodeURIComponent(before)}&after=${encodeURIComponent(after)}`,
apiToken || ''
'a scan diff'
)

spinner.successAndStop('Received diff-scan response')

if (!response.ok) {
const err = await handleApiError(response.status)
return {
ok: false,
message: 'Socket API returned an error',
cause: `${response.statusText}${err ? ` ( Reason: ${err} )` : ''}`
}
}

const result =
(await response.json()) as SocketSdkReturnType<'GetOrgDiffScan'>['data']

return { ok: true, data: result }
}
2 changes: 1 addition & 1 deletion src/commands/fix/cmd-fix.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('socket fix', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket fix\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket fix`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/info/cmd-info.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('socket info', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket info\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket info`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/login/cmd-login.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('socket login', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket login\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket login`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/logout/cmd-logout.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('socket logout', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket logout\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket logout`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manifest/cmd-manifest-auto.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('socket manifest auto', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket manifest auto\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket manifest auto`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manifest/cmd-manifest-conda.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('socket manifest conda', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket manifest conda\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket manifest conda`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manifest/cmd-manifest-gradle.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('socket manifest gradle', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket manifest gradle\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket manifest gradle`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manifest/cmd-manifest-kotlin.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('socket manifest kotlin', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket manifest kotlin\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket manifest kotlin`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manifest/cmd-manifest-scala.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('socket manifest scala', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket manifest scala\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket manifest scala`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manifest/cmd-manifest.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('socket manifest', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket manifest\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket manifest`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/npm/cmd-npm.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('socket npm', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket npm\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket npm`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/npx/cmd-npx.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('socket npx', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket npx\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket npx`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/oops/cmd-oops.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('socket oops', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket oops\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain('`socket oops`')
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/optimize/cmd-optimize.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('socket optimize', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket optimize\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket optimize`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/organization/cmd-organization-list.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('socket organization list', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket organization list\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket organization list`'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('socket organization policy license', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket organization policy license\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket organization policy license`'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('socket organization policy security', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket organization policy security\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket organization policy security`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/organization/cmd-organization-policy.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('socket organization list', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket organization policy\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket organization policy`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/organization/cmd-organization-quota.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('socket organization quota', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket organization quota\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket organization quota`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/organization/cmd-organization.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('socket organization', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket organization\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket organization`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/cmd-package-score.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('socket package score', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket package score\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(
stderr,
'header should include command (without params)'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/cmd-package-shallow.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('socket package shallow', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket package shallow\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket package shallow`'
)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/cmd-package.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('socket package', async () => {
|_____|___|___|_,_|___|_|.dev | Command: \`socket package\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'explicit help should exit with code 0').toBe(0)
expect(stderr, 'banner includes base command').toContain(
'`socket package`'
)
Expand Down
Loading