@socketsecurity/cli-with-sentry 0.15.1 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/cli.js +55 -11
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +7 -3
- package/dist/constants.js.map +1 -1
- package/dist/types/commands/fix/git.d.mts +1 -0
- package/dist/types/commands/fix/git.d.mts.map +1 -1
- package/dist/types/commands/fix/open-pr.d.mts.map +1 -1
- package/dist/types/constants.d.mts +1 -0
- package/dist/types/constants.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3494,6 +3494,8 @@ const cmdDiffScan = {
|
|
|
3494
3494
|
}
|
|
3495
3495
|
}
|
|
3496
3496
|
|
|
3497
|
+
const GITHUB_ACTIONS_BOT_USERNAME = 'github-actions[bot]'
|
|
3498
|
+
const GITHUB_ACTIONS_BOT_EMAIL = `${GITHUB_ACTIONS_BOT_USERNAME}@users.noreply.github.com`
|
|
3497
3499
|
function formatBranchName(str) {
|
|
3498
3500
|
return str
|
|
3499
3501
|
.replace(/[-_.\\/]+/g, '-')
|
|
@@ -3571,6 +3573,7 @@ async function gitCreateAndPushBranchIfNeeded(
|
|
|
3571
3573
|
logger.logger.warn('Nothing to commit, skipping push.')
|
|
3572
3574
|
return false
|
|
3573
3575
|
}
|
|
3576
|
+
await gitEnsureIdentity(cwd)
|
|
3574
3577
|
await spawn.spawn('git', ['checkout', '-b', branch], {
|
|
3575
3578
|
cwd
|
|
3576
3579
|
})
|
|
@@ -3600,6 +3603,48 @@ async function gitCreateAndPushBranchIfNeeded(
|
|
|
3600
3603
|
logger.logger.warn(`Force-push failed for "${branch}"`)
|
|
3601
3604
|
return false
|
|
3602
3605
|
}
|
|
3606
|
+
async function gitEnsureIdentity(cwd = process.cwd()) {
|
|
3607
|
+
let hasUserName = false
|
|
3608
|
+
try {
|
|
3609
|
+
const { stdout } = await spawn.spawn(
|
|
3610
|
+
'git',
|
|
3611
|
+
['config', '--get', 'user.name'],
|
|
3612
|
+
{
|
|
3613
|
+
cwd
|
|
3614
|
+
}
|
|
3615
|
+
)
|
|
3616
|
+
hasUserName = !!stdout.trim()
|
|
3617
|
+
} catch {}
|
|
3618
|
+
if (!hasUserName) {
|
|
3619
|
+
await spawn.spawn(
|
|
3620
|
+
'git',
|
|
3621
|
+
['config', 'user.name', GITHUB_ACTIONS_BOT_USERNAME],
|
|
3622
|
+
{
|
|
3623
|
+
cwd
|
|
3624
|
+
}
|
|
3625
|
+
)
|
|
3626
|
+
}
|
|
3627
|
+
let hasUserEmail = false
|
|
3628
|
+
try {
|
|
3629
|
+
const { stdout } = await spawn.spawn(
|
|
3630
|
+
'git',
|
|
3631
|
+
['config', '--get', 'user.email'],
|
|
3632
|
+
{
|
|
3633
|
+
cwd
|
|
3634
|
+
}
|
|
3635
|
+
)
|
|
3636
|
+
hasUserEmail = !!stdout.trim()
|
|
3637
|
+
} catch {}
|
|
3638
|
+
if (!hasUserEmail) {
|
|
3639
|
+
await spawn.spawn(
|
|
3640
|
+
'git',
|
|
3641
|
+
['config', 'user.email', GITHUB_ACTIONS_BOT_EMAIL],
|
|
3642
|
+
{
|
|
3643
|
+
cwd
|
|
3644
|
+
}
|
|
3645
|
+
)
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3603
3648
|
async function gitResetAndClean(branch = 'HEAD', cwd = process.cwd()) {
|
|
3604
3649
|
// Discards tracked changes.
|
|
3605
3650
|
await gitResetHard(branch, cwd)
|
|
@@ -3642,8 +3687,9 @@ let _octokit
|
|
|
3642
3687
|
function getOctokit() {
|
|
3643
3688
|
if (_octokit === undefined) {
|
|
3644
3689
|
_octokit = new vendor.Octokit({
|
|
3645
|
-
// Lazily access constants.ENV.
|
|
3646
|
-
auth:
|
|
3690
|
+
// Lazily access constants.ENV properties.
|
|
3691
|
+
auth:
|
|
3692
|
+
constants.ENV.SOCKET_SECURITY_GITHUB_PAT || constants.ENV.GITHUB_TOKEN
|
|
3647
3693
|
})
|
|
3648
3694
|
}
|
|
3649
3695
|
return _octokit
|
|
@@ -3653,8 +3699,8 @@ function getOctokitGraphql() {
|
|
|
3653
3699
|
if (!_octokitGraphql) {
|
|
3654
3700
|
_octokitGraphql = vendor.graphql2.defaults({
|
|
3655
3701
|
headers: {
|
|
3656
|
-
// Lazily access constants.ENV.
|
|
3657
|
-
authorization: `token ${constants.ENV.SOCKET_SECURITY_GITHUB_PAT}`
|
|
3702
|
+
// Lazily access constants.ENV properties.
|
|
3703
|
+
authorization: `token ${constants.ENV.SOCKET_SECURITY_GITHUB_PAT || constants.ENV.GITHUB_TOKEN}`
|
|
3658
3704
|
}
|
|
3659
3705
|
})
|
|
3660
3706
|
}
|
|
@@ -3921,12 +3967,10 @@ async function openPr(owner, repo, branch, purl, newVersion, options) {
|
|
|
3921
3967
|
}
|
|
3922
3968
|
// Lazily access constants.ENV.GITHUB_ACTIONS.
|
|
3923
3969
|
if (constants.ENV.GITHUB_ACTIONS) {
|
|
3924
|
-
// Lazily access constants.ENV.
|
|
3925
|
-
const
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
}
|
|
3929
|
-
const url = `https://x-access-token:${pat}@github.com/${owner}/${repo}`
|
|
3970
|
+
// Lazily access constants.ENV properties.
|
|
3971
|
+
const token =
|
|
3972
|
+
constants.ENV.SOCKET_SECURITY_GITHUB_PAT || constants.ENV.GITHUB_TOKEN
|
|
3973
|
+
const url = `https://x-access-token:${token}@github.com/${owner}/${repo}`
|
|
3930
3974
|
await spawn.spawn('git', ['remote', 'set-url', 'origin', url], {
|
|
3931
3975
|
cwd
|
|
3932
3976
|
})
|
|
@@ -12253,5 +12297,5 @@ void (async () => {
|
|
|
12253
12297
|
await utils.captureException(e)
|
|
12254
12298
|
}
|
|
12255
12299
|
})()
|
|
12256
|
-
//# debugId=
|
|
12300
|
+
//# debugId=87f7bc74-4cec-42a0-bcfb-577373e143fd
|
|
12257
12301
|
//# sourceMappingURL=cli.js.map
|