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