Skip to content

Commit e09fb66

Browse files
committed
More cleanup
1 parent ba56904 commit e09fb66

12 files changed

Lines changed: 35 additions & 45 deletions

src/commands/login/attempt-login.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export async function attemptLogin(
5353
const orgsCResult = await handleApiCall(sockSdk.getOrganizations(), {
5454
desc: 'token verification',
5555
})
56-
5756
if (!orgsCResult.ok) {
5857
process.exitCode = 1
5958
logger.fail(failMsgWithBadge(orgsCResult.message, orgsCResult.cause))

src/commands/package/fetch-purls-shallow-score.mts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function fetchPurlsShallowScore(
3030
`Requesting shallow score data for ${purls.length} package urls (purl): ${purls.join(', ')}`,
3131
)
3232

33-
const result = await handleApiCall(
33+
const batchPackageCResult = await handleApiCall(
3434
sockSdk.batchPackageFetch(
3535
{ components: purls.map(purl => ({ purl })) },
3636
{
@@ -39,15 +39,14 @@ export async function fetchPurlsShallowScore(
3939
),
4040
{ desc: 'looking up package' },
4141
)
42-
43-
if (!result.ok) {
44-
return result
42+
if (!batchPackageCResult.ok) {
43+
return batchPackageCResult
4544
}
4645

4746
// TODO: Seems like there's a bug in the typing since we absolutely have to
4847
// return the .data here.
4948
return {
5049
ok: true,
51-
data: result.data as SocketSdkSuccessResult<'batchPackageFetch'>,
50+
data: batchPackageCResult.data as SocketSdkSuccessResult<'batchPackageFetch'>,
5251
}
5352
}

src/commands/repository/fetch-list-all-repos.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ export async function fetchListAllRepos(
5050
{ desc: 'list of repositories' },
5151
)
5252
if (!orgRepoListCResult.ok) {
53-
debugFn('error', 'fail: fetch repo')
54-
debugDir('inspect', { orgRepoListCResult })
5553
return orgRepoListCResult
5654
}
5755

58-
orgRepoListCResult.data.results.forEach(row => rows.push(row))
56+
rows.push(...orgRepoListCResult.data.results)
5957
nextPage = orgRepoListCResult.data.nextPage ?? -1
6058
}
6159

src/commands/scan/cmd-scan-github.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { getOutputKind } from '../../utils/get-output-kind.mts'
1313
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
1414
import { getFlagListOutput } from '../../utils/output-formatting.mts'
1515
import { hasDefaultToken } from '../../utils/sdk.mts'
16-
import { readOrDefaultSocketJson } from '../../utils/socketjson.mts'
16+
import { readOrDefaultSocketJson } from '../../utils/socket-json.mts'
1717

1818
import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts'
1919

src/commands/scan/fetch-list-scans.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export async function fetchOrgFullScanList(
4646
...(repo ? { repo } : {}),
4747
sort,
4848
direction,
49-
per_page: String(perPage),
50-
page: String(page),
5149
from: from_time,
50+
page: String(page),
51+
per_page: String(perPage),
5252
}),
5353
{ desc: 'list of scans' },
5454
)

src/commands/scan/fetch-report-data.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export async function fetchScanData(
8888
const data = lines.map(line => {
8989
try {
9090
return JSON.parse(line)
91-
} catch {
91+
} catch (e) {
9292
ok = false
93-
debugFn('error', 'fail: parse NDJSON')
94-
debugDir('inspect', { line })
93+
debugFn('error', 'caught: JSON.parse error')
94+
debugDir('inspect', { error: e, line })
9595
return
9696
}
9797
}) as unknown as SocketArtifact[]

src/commands/scan/fetch-scan.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export async function fetchScan(
2626
const data = lines.map(line => {
2727
try {
2828
return JSON.parse(line)
29-
} catch {
29+
} catch (e) {
3030
ok = false
31-
debugFn('error', 'fail: parse NDJSON')
32-
debugDir('inspect', { line })
31+
debugFn('error', 'caught: JSON.parse error')
32+
debugDir('inspect', { error: e, line })
3333
return null
3434
}
3535
}) as unknown as SocketArtifact[]

src/commands/scan/handle-create-new-scan.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '../../utils/coana.mts'
1717
import { getPackageFilesForScan } from '../../utils/path-resolve.mts'
1818
import { setupSdk } from '../../utils/sdk.mts'
19-
import { readOrDefaultSocketJson } from '../../utils/socketjson.mts'
19+
import { readOrDefaultSocketJson } from '../../utils/socket-json.mts'
2020
import { detectManifestActions } from '../manifest/detect-manifest-actions.mts'
2121
import { generateAutoManifest } from '../manifest/generate_auto_manifest.mts'
2222

src/commands/wrapper/postinstall-wrapper.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Do you want to install "safe npm" (this will create an alias to the socket-npm c
4848
}
4949
}
5050
} catch (e) {
51-
debugFn('error', 'fail: setup tab completion')
51+
debugFn('error', 'caught: tab completion setup error')
5252
debugDir('inspect', { error: e })
5353
// Ignore. Skip tab completion setup.
5454
}

src/constants.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,15 @@ const LAZY_ENV = () => {
346346
// https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables-for-development
347347
SOCKET_CLI_API_BASE_URL:
348348
envAsString(env['SOCKET_CLI_API_BASE_URL']) ||
349+
// TODO: Remove legacy environment variable name.
349350
envAsString(env['SOCKET_SECURITY_API_BASE_URL']) ||
350351
getConfigValueOrUndef('apiBaseUrl') ||
351352
'https://api.socket.dev/v0/',
352353
// Set the proxy that all requests are routed through.
353354
// https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables-for-development
354355
SOCKET_CLI_API_PROXY:
355356
envAsString(env['SOCKET_CLI_API_PROXY']) ||
357+
// TODO: Remove legacy environment variable name.
356358
envAsString(env['SOCKET_SECURITY_API_PROXY']) ||
357359
// Commonly used environment variables to specify routing requests through
358360
// a proxy server.
@@ -364,6 +366,7 @@ const LAZY_ENV = () => {
364366
// https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables
365367
SOCKET_CLI_API_TOKEN:
366368
envAsString(env['SOCKET_CLI_API_TOKEN']) ||
369+
// TODO: Remove legacy environment variable names.
367370
envAsString(env['SOCKET_CLI_API_KEY']) ||
368371
envAsString(env['SOCKET_SECURITY_API_TOKEN']) ||
369372
envAsString(env['SOCKET_SECURITY_API_KEY']),
@@ -384,6 +387,7 @@ const LAZY_ENV = () => {
384387
// https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
385388
SOCKET_CLI_GITHUB_TOKEN:
386389
envAsString(env['SOCKET_CLI_GITHUB_TOKEN']) ||
390+
// TODO: Remove undocumented legacy environment variable name.
387391
envAsString(env['SOCKET_SECURITY_GITHUB_PAT']) ||
388392
GITHUB_TOKEN,
389393
// Make the default API token `undefined`.

0 commit comments

Comments
 (0)