Skip to content

Commit fc51f6a

Browse files
committed
Add debug around octokit pr api
1 parent 32fcad8 commit fc51f6a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/commands/fix/pull-request.mts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ function getOctokit() {
3939
if (!SOCKET_CLI_GITHUB_TOKEN) {
4040
debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var')
4141
}
42-
_octokit = new Octokit({
42+
const octokitOptions = {
4343
auth: SOCKET_CLI_GITHUB_TOKEN,
4444
// Lazily access constants.ENV.GITHUB_API_URL.
4545
baseUrl: constants.ENV.GITHUB_API_URL,
46-
})
46+
}
47+
debugDir('inspect', { octokitOptions })
48+
_octokit = new Octokit(octokitOptions)
4749
}
4850
return _octokit
4951
}
@@ -478,14 +480,16 @@ export async function openPr(
478480
const purlObj = getPurlObject(purl)
479481
const octokit = getOctokit()
480482
try {
481-
return await octokit.pulls.create({
483+
const octokitPullsCreateParams = {
482484
owner,
483485
repo,
484486
title: getSocketPullRequestTitle(purlObj, newVersion, workspace),
485487
head: branch,
486488
base: baseBranch,
487489
body: getSocketPullRequestBody(purlObj, newVersion, workspace),
488-
})
490+
}
491+
debugDir('inspect', { octokitPullsCreateParams })
492+
return await octokit.pulls.create(octokitPullsCreateParams)
489493
} catch (e) {
490494
let message = `Failed to open pull request`
491495
const errors =

src/commands/scan/create-scan-from-github.mts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import os from 'node:os'
33
import path from 'node:path'
44
import { pipeline } from 'node:stream/promises'
55

6-
import { debugFn } from '@socketsecurity/registry/lib/debug'
6+
import { debugDir, debugFn } from '@socketsecurity/registry/lib/debug'
77
import { logger } from '@socketsecurity/registry/lib/logger'
88
import { confirm, select } from '@socketsecurity/registry/lib/prompts'
99

@@ -398,7 +398,7 @@ async function downloadManifestFile({
398398
debugFn('notice', 'request: download url from GitHub')
399399

400400
const fileUrl = `${repoApiUrl}/contents/${file}?ref=${defaultBranch}`
401-
debugFn('inspect', 'url: file', fileUrl)
401+
debugDir('inspect', { fileUrl })
402402

403403
const downloadUrlResponse = await fetch(fileUrl, {
404404
method: 'GET',
@@ -497,7 +497,7 @@ async function streamDownloadWithFetch(
497497
'An error was thrown while trying to download a manifest file... url:',
498498
downloadUrl,
499499
)
500-
debugFn('inspect', { error })
500+
debugDir('inspect', { error })
501501

502502
// If an error occurs and fileStream was created, attempt to clean up.
503503
if (fs.existsSync(localPath)) {
@@ -654,7 +654,7 @@ async function getRepoDetails({
654654
CResult<{ defaultBranch: string; repoDetails: unknown; repoApiUrl: string }>
655655
> {
656656
const repoApiUrl = `${githubApiUrl}/repos/${orgGithub}/${repoSlug}`
657-
debugFn('inspect', 'url: repo', repoApiUrl)
657+
debugDir('inspect', { repoApiUrl })
658658

659659
const repoDetailsResponse = await fetch(repoApiUrl, {
660660
method: 'GET',
@@ -754,7 +754,7 @@ async function getRepoBranchTree({
754754
}
755755

756756
if (!treeDetails.tree || !Array.isArray(treeDetails.tree)) {
757-
debugFn('inspect', 'treeDetails.tree:', treeDetails.tree)
757+
debugDir('inspect', { treeDetails: { tree: treeDetails.tree } })
758758

759759
return {
760760
ok: false,

0 commit comments

Comments
 (0)