@socketsecurity/cli 0.14.90 → 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/blessed/lib/widgets/node.js +1 -2
- package/dist/blessed/lib/widgets/screen.js +5 -7
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +17 -3
- package/dist/constants.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/fs.d.ts +61 -0
- 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 +4 -4
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:b37f17a4: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
|
}
|
|
@@ -4337,122 +4354,128 @@ async function pnpmFix(
|
|
|
4337
4354
|
const targetPackument = targetVersion
|
|
4338
4355
|
? packument.versions[targetVersion]
|
|
4339
4356
|
: undefined
|
|
4340
|
-
|
|
4357
|
+
if (!(targetVersion && targetPackument)) {
|
|
4358
|
+
spinner?.failAndStop(`Could not patch ${oldSpec}`)
|
|
4359
|
+
return
|
|
4360
|
+
}
|
|
4361
|
+
const oldPnpm = editablePkgJson.content[PNPM$9]
|
|
4362
|
+
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4363
|
+
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4364
|
+
const oldOverridesCount = oldOverrides
|
|
4365
|
+
? Object.keys(oldOverrides).length
|
|
4366
|
+
: 0
|
|
4367
|
+
const overrideKey = `${node.name}@${vulnerableVersionRange}`
|
|
4368
|
+
const overrideRange = shadowNpmInject.applyRange(
|
|
4369
|
+
oldOverrides?.[overrideKey] ?? targetVersion,
|
|
4370
|
+
targetVersion,
|
|
4371
|
+
rangeStyle
|
|
4372
|
+
)
|
|
4373
|
+
const fixSpec = `${name}@${overrideRange}`
|
|
4374
|
+
const updateData = {
|
|
4375
|
+
[PNPM$9]: {
|
|
4376
|
+
...oldPnpm,
|
|
4377
|
+
[OVERRIDES$2]: {
|
|
4378
|
+
[overrideKey]: overrideRange,
|
|
4379
|
+
...oldOverrides
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
const revertData = {
|
|
4384
|
+
[PNPM$9]: oldPnpmKeyCount
|
|
4385
|
+
? {
|
|
4386
|
+
...oldPnpm,
|
|
4387
|
+
[OVERRIDES$2]:
|
|
4388
|
+
oldOverridesCount === 1
|
|
4389
|
+
? undefined
|
|
4390
|
+
: {
|
|
4391
|
+
[overrideKey]: undefined,
|
|
4392
|
+
...oldOverrides
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
: undefined,
|
|
4396
|
+
...(editablePkgJson.content.dependencies
|
|
4397
|
+
? {
|
|
4398
|
+
dependencies: editablePkgJson.content.dependencies
|
|
4399
|
+
}
|
|
4400
|
+
: undefined),
|
|
4401
|
+
...(editablePkgJson.content.optionalDependencies
|
|
4402
|
+
? {
|
|
4403
|
+
optionalDependencies:
|
|
4404
|
+
editablePkgJson.content.optionalDependencies
|
|
4405
|
+
}
|
|
4406
|
+
: undefined),
|
|
4407
|
+
...(editablePkgJson.content.peerDependencies
|
|
4408
|
+
? {
|
|
4409
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4410
|
+
}
|
|
4411
|
+
: undefined)
|
|
4412
|
+
}
|
|
4413
|
+
spinner?.info(`Installing ${fixSpec}`)
|
|
4341
4414
|
let installed = false
|
|
4342
4415
|
let saved = false
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
: 0
|
|
4350
|
-
const overrideKey = `${node.name}@${vulnerableVersionRange}`
|
|
4351
|
-
const overrideRange = shadowNpmInject.applyRange(
|
|
4352
|
-
oldOverrides?.[overrideKey] ?? targetVersion,
|
|
4416
|
+
try {
|
|
4417
|
+
editablePkgJson.update(updateData)
|
|
4418
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
4419
|
+
editablePkgJson,
|
|
4420
|
+
actualTree,
|
|
4421
|
+
node,
|
|
4353
4422
|
targetVersion,
|
|
4354
4423
|
rangeStyle
|
|
4355
4424
|
)
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
? undefined
|
|
4373
|
-
: {
|
|
4374
|
-
[overrideKey]: undefined,
|
|
4375
|
-
...oldOverrides
|
|
4376
|
-
}
|
|
4377
|
-
}
|
|
4378
|
-
: undefined,
|
|
4379
|
-
...(editablePkgJson.content.dependencies
|
|
4380
|
-
? {
|
|
4381
|
-
dependencies: editablePkgJson.content.dependencies
|
|
4382
|
-
}
|
|
4383
|
-
: undefined),
|
|
4384
|
-
...(editablePkgJson.content.optionalDependencies
|
|
4385
|
-
? {
|
|
4386
|
-
optionalDependencies:
|
|
4387
|
-
editablePkgJson.content.optionalDependencies
|
|
4388
|
-
}
|
|
4389
|
-
: undefined),
|
|
4390
|
-
...(editablePkgJson.content.peerDependencies
|
|
4391
|
-
? {
|
|
4392
|
-
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4393
|
-
}
|
|
4394
|
-
: undefined)
|
|
4425
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4426
|
+
await editablePkgJson.save()
|
|
4427
|
+
saved = true
|
|
4428
|
+
|
|
4429
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4430
|
+
actualTree = await install(pkgEnvDetails, {
|
|
4431
|
+
spinner
|
|
4432
|
+
})
|
|
4433
|
+
installed = true
|
|
4434
|
+
if (test) {
|
|
4435
|
+
spinner?.info(`Testing ${fixSpec}`)
|
|
4436
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4437
|
+
await npm.runScript(testScript, [], {
|
|
4438
|
+
spinner,
|
|
4439
|
+
stdio: 'ignore'
|
|
4440
|
+
})
|
|
4395
4441
|
}
|
|
4396
|
-
spinner?.
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
node,
|
|
4403
|
-
targetVersion,
|
|
4404
|
-
rangeStyle
|
|
4405
|
-
)
|
|
4442
|
+
spinner?.successAndStop(`Fixed ${name}`)
|
|
4443
|
+
spinner?.start()
|
|
4444
|
+
} catch (e) {
|
|
4445
|
+
spinner?.error(`Reverting ${fixSpec}`, e)
|
|
4446
|
+
if (saved) {
|
|
4447
|
+
editablePkgJson.update(revertData)
|
|
4406
4448
|
// eslint-disable-next-line no-await-in-loop
|
|
4407
4449
|
await editablePkgJson.save()
|
|
4408
|
-
|
|
4409
|
-
|
|
4450
|
+
}
|
|
4451
|
+
if (installed) {
|
|
4410
4452
|
// eslint-disable-next-line no-await-in-loop
|
|
4411
4453
|
actualTree = await install(pkgEnvDetails, {
|
|
4412
4454
|
spinner
|
|
4413
4455
|
})
|
|
4414
|
-
installed = true
|
|
4415
|
-
if (test) {
|
|
4416
|
-
spinner?.info(`Testing ${fixSpec}`)
|
|
4417
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4418
|
-
await npm.runScript(testScript, [], {
|
|
4419
|
-
spinner,
|
|
4420
|
-
stdio: 'ignore'
|
|
4421
|
-
})
|
|
4422
|
-
}
|
|
4423
|
-
spinner?.successAndStop(`Fixed ${name}`)
|
|
4424
|
-
spinner?.start()
|
|
4425
|
-
} catch (e) {
|
|
4426
|
-
failed = true
|
|
4427
|
-
spinner?.error(`Reverting ${fixSpec}`, e)
|
|
4428
|
-
if (saved) {
|
|
4429
|
-
editablePkgJson.update(revertData)
|
|
4430
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4431
|
-
await editablePkgJson.save()
|
|
4432
|
-
}
|
|
4433
|
-
if (installed) {
|
|
4434
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4435
|
-
actualTree = await install(pkgEnvDetails, {
|
|
4436
|
-
spinner
|
|
4437
|
-
})
|
|
4438
|
-
}
|
|
4439
|
-
spinner?.failAndStop(`Failed to fix ${oldSpec}`)
|
|
4440
4456
|
}
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
spinner?.failAndStop(`Could not patch ${oldSpec}`)
|
|
4457
|
+
spinner?.failAndStop(`Failed to fix ${oldSpec}`)
|
|
4458
|
+
return
|
|
4444
4459
|
}
|
|
4460
|
+
const { owner, repo } = getGitHubRepoInfo()
|
|
4461
|
+
const branch = getSocketBranchName(name, targetVersion)
|
|
4445
4462
|
if (
|
|
4446
|
-
!failed &&
|
|
4447
|
-
// Check targetVersion to make TypeScript happy.
|
|
4448
|
-
targetVersion &&
|
|
4449
4463
|
// Lazily access constants.ENV[CI].
|
|
4450
|
-
constants.ENV[CI]
|
|
4464
|
+
constants.ENV[CI] &&
|
|
4465
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4466
|
+
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4451
4467
|
) {
|
|
4452
4468
|
let prResponse
|
|
4453
4469
|
try {
|
|
4454
4470
|
// eslint-disable-next-line no-await-in-loop
|
|
4455
|
-
prResponse = await openGitHubPullRequest(
|
|
4471
|
+
prResponse = await openGitHubPullRequest(
|
|
4472
|
+
owner,
|
|
4473
|
+
repo,
|
|
4474
|
+
branch,
|
|
4475
|
+
name,
|
|
4476
|
+
targetVersion,
|
|
4477
|
+
cwd
|
|
4478
|
+
)
|
|
4456
4479
|
} catch (e) {
|
|
4457
4480
|
logger.logger.error('Failed to open pull request', e)
|
|
4458
4481
|
}
|
|
@@ -4900,9 +4923,14 @@ const config$z = {
|
|
|
4900
4923
|
hidden: true,
|
|
4901
4924
|
flags: {
|
|
4902
4925
|
...commonFlags,
|
|
4926
|
+
autoPilot: {
|
|
4927
|
+
type: 'boolean',
|
|
4928
|
+
default: false,
|
|
4929
|
+
description: `Shorthand for --autoMerge --test`
|
|
4930
|
+
},
|
|
4903
4931
|
autoMerge: {
|
|
4904
4932
|
type: 'boolean',
|
|
4905
|
-
default:
|
|
4933
|
+
default: false,
|
|
4906
4934
|
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.`
|
|
4907
4935
|
},
|
|
4908
4936
|
rangeStyle: {
|
|
@@ -4921,7 +4949,7 @@ const config$z = {
|
|
|
4921
4949
|
},
|
|
4922
4950
|
test: {
|
|
4923
4951
|
type: 'boolean',
|
|
4924
|
-
default:
|
|
4952
|
+
default: false,
|
|
4925
4953
|
description: 'Verify the fix by running unit tests'
|
|
4926
4954
|
},
|
|
4927
4955
|
testScript: {
|
|
@@ -4968,6 +4996,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
4968
4996
|
const { spinner } = constants
|
|
4969
4997
|
await runFix({
|
|
4970
4998
|
autoMerge: Boolean(cli.flags['autoMerge']),
|
|
4999
|
+
autoPilot: Boolean(cli.flags['autoPilot']),
|
|
4971
5000
|
spinner,
|
|
4972
5001
|
rangeStyle: cli.flags['rangeStyle'] ?? undefined,
|
|
4973
5002
|
test: Boolean(cli.flags['test']),
|
|
@@ -10838,7 +10867,10 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
10838
10867
|
|
|
10839
10868
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
10840
10869
|
const ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'))
|
|
10841
|
-
|
|
10870
|
+
// Lazily access constants.blessedOptions.
|
|
10871
|
+
const screen = new ScreenWidget({
|
|
10872
|
+
...constants.blessedOptions
|
|
10873
|
+
})
|
|
10842
10874
|
// Register these keys first so you can always exit, even when it gets stuck
|
|
10843
10875
|
// If we don't do this and the code crashes, the user must hard-kill the
|
|
10844
10876
|
// node process just to exit it. That's very bad UX.
|
|
@@ -11345,7 +11377,7 @@ void (async () => {
|
|
|
11345
11377
|
await vendor.updater({
|
|
11346
11378
|
name: SOCKET_CLI_BIN_NAME,
|
|
11347
11379
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
11348
|
-
version: '0.14.
|
|
11380
|
+
version: '0.14.92',
|
|
11349
11381
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
11350
11382
|
})
|
|
11351
11383
|
try {
|
|
@@ -11413,5 +11445,5 @@ void (async () => {
|
|
|
11413
11445
|
await shadowNpmInject.captureException(e)
|
|
11414
11446
|
}
|
|
11415
11447
|
})()
|
|
11416
|
-
//# debugId=
|
|
11448
|
+
//# debugId=250a0889-ea75-4014-b465-519a0252e6fe
|
|
11417
11449
|
//# sourceMappingURL=cli.js.map
|