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