@socketsecurity/cli-with-sentry 0.14.91 → 0.14.92
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/constants.d.ts +7 -0
- package/dist/constants.js +14 -1
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/cli.js +235 -203
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.js +7 -4
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/types.d.ts +1 -0
- package/dist/require/cli.js +235 -203
- package/dist/require/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/require/cli.js
CHANGED
|
@@ -417,7 +417,10 @@ ${mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
|
|
|
417
417
|
}
|
|
418
418
|
function displayAnalyticsScreen(data) {
|
|
419
419
|
const ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'))
|
|
420
|
-
|
|
420
|
+
// Lazily access constants.blessedOptions.
|
|
421
|
+
const screen = new ScreenWidget({
|
|
422
|
+
...constants.blessedOptions
|
|
423
|
+
})
|
|
421
424
|
const contrib = _socketInterop(require('blessed-contrib'))
|
|
422
425
|
const grid = new contrib.grid({
|
|
423
426
|
rows: 5,
|
|
@@ -912,7 +915,7 @@ function emitBanner(name) {
|
|
|
912
915
|
logger.logger.error(getAsciiHeader(name))
|
|
913
916
|
}
|
|
914
917
|
function getAsciiHeader(command) {
|
|
915
|
-
const cliVersion = '0.14.
|
|
918
|
+
const cliVersion = '0.14.92:5d5aa04:eb69c214:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
916
919
|
const nodeVersion = process$1.version
|
|
917
920
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
918
921
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
|
|
@@ -3731,40 +3734,19 @@ async function branchExists(branch, cwd = process.cwd()) {
|
|
|
3731
3734
|
}
|
|
3732
3735
|
async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
|
|
3733
3736
|
try {
|
|
3734
|
-
const currentBranch = (
|
|
3735
|
-
await spawn.spawn('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
3736
|
-
cwd
|
|
3737
|
-
})
|
|
3738
|
-
).stdout.trim()
|
|
3739
|
-
if (currentBranch === baseBranch) {
|
|
3740
|
-
logger.logger.info(`Already on ${baseBranch}`)
|
|
3741
|
-
return
|
|
3742
|
-
}
|
|
3743
|
-
logger.logger.info(
|
|
3744
|
-
`Switching branch from ${currentBranch} to ${baseBranch}...`
|
|
3745
|
-
)
|
|
3746
3737
|
await spawn.spawn('git', ['checkout', baseBranch], {
|
|
3747
3738
|
cwd
|
|
3748
3739
|
})
|
|
3749
|
-
|
|
3740
|
+
await spawn.spawn('git', ['reset', '--hard', `origin/${baseBranch}`], {
|
|
3741
|
+
cwd
|
|
3742
|
+
})
|
|
3743
|
+
logger.logger.info(`Checked out and reset to ${baseBranch}`)
|
|
3750
3744
|
} catch {
|
|
3751
3745
|
logger.logger.warn(
|
|
3752
3746
|
`Could not switch to ${baseBranch}. Proceeding with HEAD.`
|
|
3753
3747
|
)
|
|
3754
3748
|
}
|
|
3755
3749
|
}
|
|
3756
|
-
function getGitHubRepoInfo() {
|
|
3757
|
-
// Lazily access constants.ENV[GITHUB_REPOSITORY].
|
|
3758
|
-
const ownerSlashRepo = constants.ENV[GITHUB_REPOSITORY]
|
|
3759
|
-
const slashIndex = ownerSlashRepo.indexOf('/')
|
|
3760
|
-
if (slashIndex === -1) {
|
|
3761
|
-
throw new Error('GITHUB_REPOSITORY environment variable not set')
|
|
3762
|
-
}
|
|
3763
|
-
return {
|
|
3764
|
-
owner: ownerSlashRepo.slice(0, slashIndex),
|
|
3765
|
-
repo: ownerSlashRepo.slice(slashIndex + 1)
|
|
3766
|
-
}
|
|
3767
|
-
}
|
|
3768
3750
|
let _octokit
|
|
3769
3751
|
function getOctokit() {
|
|
3770
3752
|
if (_octokit === undefined) {
|
|
@@ -3775,6 +3757,16 @@ function getOctokit() {
|
|
|
3775
3757
|
}
|
|
3776
3758
|
return _octokit
|
|
3777
3759
|
}
|
|
3760
|
+
async function doesPullRequestExistForBranch(owner, repo, branch) {
|
|
3761
|
+
const octokit = getOctokit()
|
|
3762
|
+
const { data: prs } = await octokit.pulls.list({
|
|
3763
|
+
owner,
|
|
3764
|
+
repo,
|
|
3765
|
+
head: `${owner}:${branch}`,
|
|
3766
|
+
state: 'open'
|
|
3767
|
+
})
|
|
3768
|
+
return prs.length > 0
|
|
3769
|
+
}
|
|
3778
3770
|
async function enableAutoMerge(prResponseData) {
|
|
3779
3771
|
const octokit = getOctokit()
|
|
3780
3772
|
const { node_id: prId, number: prNumber } = prResponseData
|
|
@@ -3804,7 +3796,29 @@ async function enableAutoMerge(prResponseData) {
|
|
|
3804
3796
|
logger.logger.error(`Failed to enable auto-merge for PR #${prNumber}:`, e)
|
|
3805
3797
|
}
|
|
3806
3798
|
}
|
|
3807
|
-
|
|
3799
|
+
function getGitHubRepoInfo() {
|
|
3800
|
+
// Lazily access constants.ENV[GITHUB_REPOSITORY].
|
|
3801
|
+
const ownerSlashRepo = constants.ENV[GITHUB_REPOSITORY]
|
|
3802
|
+
const slashIndex = ownerSlashRepo.indexOf('/')
|
|
3803
|
+
if (slashIndex === -1) {
|
|
3804
|
+
throw new Error('GITHUB_REPOSITORY environment variable not set')
|
|
3805
|
+
}
|
|
3806
|
+
return {
|
|
3807
|
+
owner: ownerSlashRepo.slice(0, slashIndex),
|
|
3808
|
+
repo: ownerSlashRepo.slice(slashIndex + 1)
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
function getSocketBranchName(name, version) {
|
|
3812
|
+
return `socket-fix-${name}-${version.replace(/\./g, '-')}`
|
|
3813
|
+
}
|
|
3814
|
+
async function openGitHubPullRequest(
|
|
3815
|
+
owner,
|
|
3816
|
+
repo,
|
|
3817
|
+
branch,
|
|
3818
|
+
name,
|
|
3819
|
+
version,
|
|
3820
|
+
cwd = process.cwd()
|
|
3821
|
+
) {
|
|
3808
3822
|
// Lazily access constants.ENV[GITHUB_ACTIONS].
|
|
3809
3823
|
if (constants.ENV[GITHUB_ACTIONS]) {
|
|
3810
3824
|
// Lazily access constants.ENV[SOCKET_SECURITY_GITHUB_PAT].
|
|
@@ -3818,9 +3832,7 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
|
|
|
3818
3832
|
// GitHub defaults to branch name "main"
|
|
3819
3833
|
// https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch
|
|
3820
3834
|
'main'
|
|
3821
|
-
const
|
|
3822
|
-
const commitMsg = `chore: upgrade ${name} to ${targetVersion}`
|
|
3823
|
-
const { owner, repo } = getGitHubRepoInfo()
|
|
3835
|
+
const commitMsg = `chore: upgrade ${name} to ${version}`
|
|
3824
3836
|
const url = `https://x-access-token:${pat}@github.com/${owner}/${repo}`
|
|
3825
3837
|
await spawn.spawn('git', ['remote', 'set-url', 'origin', url], {
|
|
3826
3838
|
cwd
|
|
@@ -3851,7 +3863,7 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
|
|
|
3851
3863
|
title: commitMsg,
|
|
3852
3864
|
head: branch,
|
|
3853
3865
|
base: baseBranch,
|
|
3854
|
-
body: `[socket] Upgrade \`${name}\` to ${
|
|
3866
|
+
body: `[socket] Upgrade \`${name}\` to ${version}`
|
|
3855
3867
|
})
|
|
3856
3868
|
} else {
|
|
3857
3869
|
throw new Error(
|
|
@@ -3941,92 +3953,97 @@ async function npmFix(
|
|
|
3941
3953
|
continue
|
|
3942
3954
|
}
|
|
3943
3955
|
const oldSpec = `${name}@${oldVersion}`
|
|
3944
|
-
let targetVersion
|
|
3945
|
-
let failed = false
|
|
3946
|
-
let installed = false
|
|
3947
|
-
let saved = false
|
|
3948
3956
|
if (
|
|
3949
|
-
shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
|
|
3957
|
+
!shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
|
|
3950
3958
|
) {
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3959
|
+
spinner?.failAndStop(`Could not patch ${oldSpec}`)
|
|
3960
|
+
return
|
|
3961
|
+
}
|
|
3962
|
+
const targetVersion = node.package.version
|
|
3963
|
+
const fixSpec = `${name}@^${targetVersion}`
|
|
3964
|
+
const revertData = {
|
|
3965
|
+
...(editablePkgJson.content.dependencies
|
|
3966
|
+
? {
|
|
3967
|
+
dependencies: editablePkgJson.content.dependencies
|
|
3968
|
+
}
|
|
3969
|
+
: undefined),
|
|
3970
|
+
...(editablePkgJson.content.optionalDependencies
|
|
3971
|
+
? {
|
|
3972
|
+
optionalDependencies:
|
|
3973
|
+
editablePkgJson.content.optionalDependencies
|
|
3974
|
+
}
|
|
3975
|
+
: undefined),
|
|
3976
|
+
...(editablePkgJson.content.peerDependencies
|
|
3977
|
+
? {
|
|
3978
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
3979
|
+
}
|
|
3980
|
+
: undefined)
|
|
3981
|
+
}
|
|
3982
|
+
spinner?.info(`Installing ${fixSpec}`)
|
|
3983
|
+
let installed = false
|
|
3984
|
+
let saved = false
|
|
3985
|
+
try {
|
|
3986
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
3987
|
+
editablePkgJson,
|
|
3988
|
+
arb.idealTree,
|
|
3989
|
+
node,
|
|
3990
|
+
targetVersion,
|
|
3991
|
+
rangeStyle
|
|
3992
|
+
)
|
|
3993
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3994
|
+
await editablePkgJson.save()
|
|
3995
|
+
saved = true
|
|
3996
|
+
|
|
3997
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3998
|
+
await install$1(arb.idealTree, {
|
|
3999
|
+
cwd
|
|
4000
|
+
})
|
|
4001
|
+
installed = true
|
|
4002
|
+
if (test) {
|
|
4003
|
+
spinner?.info(`Testing ${fixSpec}`)
|
|
4004
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4005
|
+
await npm.runScript(testScript, [], {
|
|
4006
|
+
spinner,
|
|
4007
|
+
stdio: 'ignore'
|
|
4008
|
+
})
|
|
3970
4009
|
}
|
|
3971
|
-
spinner?.
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
targetVersion,
|
|
3978
|
-
rangeStyle
|
|
3979
|
-
)
|
|
4010
|
+
spinner?.successAndStop(`Fixed ${name}`)
|
|
4011
|
+
spinner?.start()
|
|
4012
|
+
} catch {
|
|
4013
|
+
spinner?.error(`Reverting ${fixSpec}`)
|
|
4014
|
+
if (saved) {
|
|
4015
|
+
editablePkgJson.update(revertData)
|
|
3980
4016
|
// eslint-disable-next-line no-await-in-loop
|
|
3981
4017
|
await editablePkgJson.save()
|
|
3982
|
-
|
|
3983
|
-
|
|
4018
|
+
}
|
|
4019
|
+
if (installed) {
|
|
3984
4020
|
// eslint-disable-next-line no-await-in-loop
|
|
3985
|
-
await install$1(
|
|
4021
|
+
await install$1(revertTree, {
|
|
3986
4022
|
cwd
|
|
3987
4023
|
})
|
|
3988
|
-
installed = true
|
|
3989
|
-
if (test) {
|
|
3990
|
-
spinner?.info(`Testing ${fixSpec}`)
|
|
3991
|
-
// eslint-disable-next-line no-await-in-loop
|
|
3992
|
-
await npm.runScript(testScript, [], {
|
|
3993
|
-
spinner,
|
|
3994
|
-
stdio: 'ignore'
|
|
3995
|
-
})
|
|
3996
|
-
}
|
|
3997
|
-
spinner?.successAndStop(`Fixed ${name}`)
|
|
3998
|
-
spinner?.start()
|
|
3999
|
-
} catch {
|
|
4000
|
-
failed = true
|
|
4001
|
-
spinner?.error(`Reverting ${fixSpec}`)
|
|
4002
|
-
if (saved) {
|
|
4003
|
-
editablePkgJson.update(revertData)
|
|
4004
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4005
|
-
await editablePkgJson.save()
|
|
4006
|
-
}
|
|
4007
|
-
if (installed) {
|
|
4008
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4009
|
-
await install$1(revertTree, {
|
|
4010
|
-
cwd
|
|
4011
|
-
})
|
|
4012
|
-
}
|
|
4013
|
-
spinner?.failAndStop(`Failed to fix ${oldSpec}`)
|
|
4014
4024
|
}
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
spinner?.failAndStop(`Could not patch ${oldSpec}`)
|
|
4025
|
+
spinner?.failAndStop(`Failed to fix ${oldSpec}`)
|
|
4026
|
+
return
|
|
4018
4027
|
}
|
|
4028
|
+
const { owner, repo } = getGitHubRepoInfo()
|
|
4029
|
+
const branch = getSocketBranchName(name, targetVersion)
|
|
4019
4030
|
if (
|
|
4020
|
-
!failed &&
|
|
4021
|
-
// Check targetVersion to make TypeScript happy.
|
|
4022
|
-
targetVersion &&
|
|
4023
4031
|
// Lazily access constants.ENV[CI].
|
|
4024
|
-
constants.ENV[CI$1]
|
|
4032
|
+
constants.ENV[CI$1] &&
|
|
4033
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4034
|
+
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4025
4035
|
) {
|
|
4026
4036
|
let prResponse
|
|
4027
4037
|
try {
|
|
4028
4038
|
// eslint-disable-next-line no-await-in-loop
|
|
4029
|
-
prResponse = await openGitHubPullRequest(
|
|
4039
|
+
prResponse = await openGitHubPullRequest(
|
|
4040
|
+
owner,
|
|
4041
|
+
repo,
|
|
4042
|
+
branch,
|
|
4043
|
+
name,
|
|
4044
|
+
targetVersion,
|
|
4045
|
+
cwd
|
|
4046
|
+
)
|
|
4030
4047
|
} catch (e) {
|
|
4031
4048
|
logger.logger.error('Failed to open pull request', e)
|
|
4032
4049
|
}
|
|
@@ -4341,122 +4358,128 @@ async function pnpmFix(
|
|
|
4341
4358
|
const targetPackument = targetVersion
|
|
4342
4359
|
? packument.versions[targetVersion]
|
|
4343
4360
|
: undefined
|
|
4344
|
-
|
|
4361
|
+
if (!(targetVersion && targetPackument)) {
|
|
4362
|
+
spinner?.failAndStop(`Could not patch ${oldSpec}`)
|
|
4363
|
+
return
|
|
4364
|
+
}
|
|
4365
|
+
const oldPnpm = editablePkgJson.content[PNPM$9]
|
|
4366
|
+
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4367
|
+
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4368
|
+
const oldOverridesCount = oldOverrides
|
|
4369
|
+
? Object.keys(oldOverrides).length
|
|
4370
|
+
: 0
|
|
4371
|
+
const overrideKey = `${node.name}@${vulnerableVersionRange}`
|
|
4372
|
+
const overrideRange = shadowNpmInject.applyRange(
|
|
4373
|
+
oldOverrides?.[overrideKey] ?? targetVersion,
|
|
4374
|
+
targetVersion,
|
|
4375
|
+
rangeStyle
|
|
4376
|
+
)
|
|
4377
|
+
const fixSpec = `${name}@${overrideRange}`
|
|
4378
|
+
const updateData = {
|
|
4379
|
+
[PNPM$9]: {
|
|
4380
|
+
...oldPnpm,
|
|
4381
|
+
[OVERRIDES$2]: {
|
|
4382
|
+
[overrideKey]: overrideRange,
|
|
4383
|
+
...oldOverrides
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
const revertData = {
|
|
4388
|
+
[PNPM$9]: oldPnpmKeyCount
|
|
4389
|
+
? {
|
|
4390
|
+
...oldPnpm,
|
|
4391
|
+
[OVERRIDES$2]:
|
|
4392
|
+
oldOverridesCount === 1
|
|
4393
|
+
? undefined
|
|
4394
|
+
: {
|
|
4395
|
+
[overrideKey]: undefined,
|
|
4396
|
+
...oldOverrides
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
: undefined,
|
|
4400
|
+
...(editablePkgJson.content.dependencies
|
|
4401
|
+
? {
|
|
4402
|
+
dependencies: editablePkgJson.content.dependencies
|
|
4403
|
+
}
|
|
4404
|
+
: undefined),
|
|
4405
|
+
...(editablePkgJson.content.optionalDependencies
|
|
4406
|
+
? {
|
|
4407
|
+
optionalDependencies:
|
|
4408
|
+
editablePkgJson.content.optionalDependencies
|
|
4409
|
+
}
|
|
4410
|
+
: undefined),
|
|
4411
|
+
...(editablePkgJson.content.peerDependencies
|
|
4412
|
+
? {
|
|
4413
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4414
|
+
}
|
|
4415
|
+
: undefined)
|
|
4416
|
+
}
|
|
4417
|
+
spinner?.info(`Installing ${fixSpec}`)
|
|
4345
4418
|
let installed = false
|
|
4346
4419
|
let saved = false
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
: 0
|
|
4354
|
-
const overrideKey = `${node.name}@${vulnerableVersionRange}`
|
|
4355
|
-
const overrideRange = shadowNpmInject.applyRange(
|
|
4356
|
-
oldOverrides?.[overrideKey] ?? targetVersion,
|
|
4420
|
+
try {
|
|
4421
|
+
editablePkgJson.update(updateData)
|
|
4422
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
4423
|
+
editablePkgJson,
|
|
4424
|
+
actualTree,
|
|
4425
|
+
node,
|
|
4357
4426
|
targetVersion,
|
|
4358
4427
|
rangeStyle
|
|
4359
4428
|
)
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
? undefined
|
|
4377
|
-
: {
|
|
4378
|
-
[overrideKey]: undefined,
|
|
4379
|
-
...oldOverrides
|
|
4380
|
-
}
|
|
4381
|
-
}
|
|
4382
|
-
: undefined,
|
|
4383
|
-
...(editablePkgJson.content.dependencies
|
|
4384
|
-
? {
|
|
4385
|
-
dependencies: editablePkgJson.content.dependencies
|
|
4386
|
-
}
|
|
4387
|
-
: undefined),
|
|
4388
|
-
...(editablePkgJson.content.optionalDependencies
|
|
4389
|
-
? {
|
|
4390
|
-
optionalDependencies:
|
|
4391
|
-
editablePkgJson.content.optionalDependencies
|
|
4392
|
-
}
|
|
4393
|
-
: undefined),
|
|
4394
|
-
...(editablePkgJson.content.peerDependencies
|
|
4395
|
-
? {
|
|
4396
|
-
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4397
|
-
}
|
|
4398
|
-
: undefined)
|
|
4429
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4430
|
+
await editablePkgJson.save()
|
|
4431
|
+
saved = true
|
|
4432
|
+
|
|
4433
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4434
|
+
actualTree = await install(pkgEnvDetails, {
|
|
4435
|
+
spinner
|
|
4436
|
+
})
|
|
4437
|
+
installed = true
|
|
4438
|
+
if (test) {
|
|
4439
|
+
spinner?.info(`Testing ${fixSpec}`)
|
|
4440
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4441
|
+
await npm.runScript(testScript, [], {
|
|
4442
|
+
spinner,
|
|
4443
|
+
stdio: 'ignore'
|
|
4444
|
+
})
|
|
4399
4445
|
}
|
|
4400
|
-
spinner?.
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
node,
|
|
4407
|
-
targetVersion,
|
|
4408
|
-
rangeStyle
|
|
4409
|
-
)
|
|
4446
|
+
spinner?.successAndStop(`Fixed ${name}`)
|
|
4447
|
+
spinner?.start()
|
|
4448
|
+
} catch (e) {
|
|
4449
|
+
spinner?.error(`Reverting ${fixSpec}`, e)
|
|
4450
|
+
if (saved) {
|
|
4451
|
+
editablePkgJson.update(revertData)
|
|
4410
4452
|
// eslint-disable-next-line no-await-in-loop
|
|
4411
4453
|
await editablePkgJson.save()
|
|
4412
|
-
|
|
4413
|
-
|
|
4454
|
+
}
|
|
4455
|
+
if (installed) {
|
|
4414
4456
|
// eslint-disable-next-line no-await-in-loop
|
|
4415
4457
|
actualTree = await install(pkgEnvDetails, {
|
|
4416
4458
|
spinner
|
|
4417
4459
|
})
|
|
4418
|
-
installed = true
|
|
4419
|
-
if (test) {
|
|
4420
|
-
spinner?.info(`Testing ${fixSpec}`)
|
|
4421
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4422
|
-
await npm.runScript(testScript, [], {
|
|
4423
|
-
spinner,
|
|
4424
|
-
stdio: 'ignore'
|
|
4425
|
-
})
|
|
4426
|
-
}
|
|
4427
|
-
spinner?.successAndStop(`Fixed ${name}`)
|
|
4428
|
-
spinner?.start()
|
|
4429
|
-
} catch (e) {
|
|
4430
|
-
failed = true
|
|
4431
|
-
spinner?.error(`Reverting ${fixSpec}`, e)
|
|
4432
|
-
if (saved) {
|
|
4433
|
-
editablePkgJson.update(revertData)
|
|
4434
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4435
|
-
await editablePkgJson.save()
|
|
4436
|
-
}
|
|
4437
|
-
if (installed) {
|
|
4438
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4439
|
-
actualTree = await install(pkgEnvDetails, {
|
|
4440
|
-
spinner
|
|
4441
|
-
})
|
|
4442
|
-
}
|
|
4443
|
-
spinner?.failAndStop(`Failed to fix ${oldSpec}`)
|
|
4444
4460
|
}
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
spinner?.failAndStop(`Could not patch ${oldSpec}`)
|
|
4461
|
+
spinner?.failAndStop(`Failed to fix ${oldSpec}`)
|
|
4462
|
+
return
|
|
4448
4463
|
}
|
|
4464
|
+
const { owner, repo } = getGitHubRepoInfo()
|
|
4465
|
+
const branch = getSocketBranchName(name, targetVersion)
|
|
4449
4466
|
if (
|
|
4450
|
-
!failed &&
|
|
4451
|
-
// Check targetVersion to make TypeScript happy.
|
|
4452
|
-
targetVersion &&
|
|
4453
4467
|
// Lazily access constants.ENV[CI].
|
|
4454
|
-
constants.ENV[CI]
|
|
4468
|
+
constants.ENV[CI] &&
|
|
4469
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4470
|
+
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4455
4471
|
) {
|
|
4456
4472
|
let prResponse
|
|
4457
4473
|
try {
|
|
4458
4474
|
// eslint-disable-next-line no-await-in-loop
|
|
4459
|
-
prResponse = await openGitHubPullRequest(
|
|
4475
|
+
prResponse = await openGitHubPullRequest(
|
|
4476
|
+
owner,
|
|
4477
|
+
repo,
|
|
4478
|
+
branch,
|
|
4479
|
+
name,
|
|
4480
|
+
targetVersion,
|
|
4481
|
+
cwd
|
|
4482
|
+
)
|
|
4460
4483
|
} catch (e) {
|
|
4461
4484
|
logger.logger.error('Failed to open pull request', e)
|
|
4462
4485
|
}
|
|
@@ -4904,9 +4927,14 @@ const config$z = {
|
|
|
4904
4927
|
hidden: true,
|
|
4905
4928
|
flags: {
|
|
4906
4929
|
...commonFlags,
|
|
4930
|
+
autoPilot: {
|
|
4931
|
+
type: 'boolean',
|
|
4932
|
+
default: false,
|
|
4933
|
+
description: `Shorthand for --autoMerge --test`
|
|
4934
|
+
},
|
|
4907
4935
|
autoMerge: {
|
|
4908
4936
|
type: 'boolean',
|
|
4909
|
-
default:
|
|
4937
|
+
default: false,
|
|
4910
4938
|
description: `Enable auto-merge for pull requests that Socket opens.\n See ${terminalLink('GitHub documentation', 'https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository')} for managing auto-merge for pull requests in your repository.`
|
|
4911
4939
|
},
|
|
4912
4940
|
rangeStyle: {
|
|
@@ -4925,7 +4953,7 @@ const config$z = {
|
|
|
4925
4953
|
},
|
|
4926
4954
|
test: {
|
|
4927
4955
|
type: 'boolean',
|
|
4928
|
-
default:
|
|
4956
|
+
default: false,
|
|
4929
4957
|
description: 'Verify the fix by running unit tests'
|
|
4930
4958
|
},
|
|
4931
4959
|
testScript: {
|
|
@@ -4972,6 +5000,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
4972
5000
|
const { spinner } = constants
|
|
4973
5001
|
await runFix({
|
|
4974
5002
|
autoMerge: Boolean(cli.flags['autoMerge']),
|
|
5003
|
+
autoPilot: Boolean(cli.flags['autoPilot']),
|
|
4975
5004
|
spinner,
|
|
4976
5005
|
rangeStyle: cli.flags['rangeStyle'] ?? undefined,
|
|
4977
5006
|
test: Boolean(cli.flags['test']),
|
|
@@ -10842,7 +10871,10 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
10842
10871
|
|
|
10843
10872
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
10844
10873
|
const ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'))
|
|
10845
|
-
|
|
10874
|
+
// Lazily access constants.blessedOptions.
|
|
10875
|
+
const screen = new ScreenWidget({
|
|
10876
|
+
...constants.blessedOptions
|
|
10877
|
+
})
|
|
10846
10878
|
// Register these keys first so you can always exit, even when it gets stuck
|
|
10847
10879
|
// If we don't do this and the code crashes, the user must hard-kill the
|
|
10848
10880
|
// node process just to exit it. That's very bad UX.
|
|
@@ -11349,7 +11381,7 @@ void (async () => {
|
|
|
11349
11381
|
await vendor.updater({
|
|
11350
11382
|
name: SOCKET_CLI_BIN_NAME,
|
|
11351
11383
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
11352
|
-
version: '0.14.
|
|
11384
|
+
version: '0.14.92',
|
|
11353
11385
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
11354
11386
|
})
|
|
11355
11387
|
try {
|
|
@@ -11417,5 +11449,5 @@ void (async () => {
|
|
|
11417
11449
|
await shadowNpmInject.captureException(e)
|
|
11418
11450
|
}
|
|
11419
11451
|
})()
|
|
11420
|
-
//# debugId=
|
|
11452
|
+
//# debugId=a79ad5f1-a2ab-429a-ab98-689ad89a4fd7
|
|
11421
11453
|
//# sourceMappingURL=cli.js.map
|