socket 0.14.124 → 0.14.126
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/module-sync/cli.js +124 -149
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.js +2 -2
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/require/cli.js +124 -149
- package/dist/require/cli.js.map +1 -1
- package/dist/require/shadow-npm-inject.js +2 -2
- package/dist/require/shadow-npm-inject.js.map +1 -1
- package/package.json +1 -1
package/dist/module-sync/cli.js
CHANGED
|
@@ -917,7 +917,7 @@ function emitBanner(name) {
|
|
|
917
917
|
logger.logger.error(getAsciiHeader(name))
|
|
918
918
|
}
|
|
919
919
|
function getAsciiHeader(command) {
|
|
920
|
-
const cliVersion = '0.14.
|
|
920
|
+
const cliVersion = '0.14.126:cbde084:6c7196a9:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
921
921
|
const nodeVersion = process$1.version
|
|
922
922
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
923
923
|
const defaultOrg = shadowNpmInject.getConfigValue('defaultOrg')
|
|
@@ -4180,7 +4180,6 @@ async function npmFix(
|
|
|
4180
4180
|
)
|
|
4181
4181
|
let error
|
|
4182
4182
|
let errored = false
|
|
4183
|
-
let installed = false
|
|
4184
4183
|
let saved = false
|
|
4185
4184
|
|
|
4186
4185
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4196,7 +4195,6 @@ async function npmFix(
|
|
|
4196
4195
|
await install$1(arb.idealTree, {
|
|
4197
4196
|
cwd
|
|
4198
4197
|
})
|
|
4199
|
-
installed = true
|
|
4200
4198
|
if (test) {
|
|
4201
4199
|
if (!testedSpecs.has(newSpecKey)) {
|
|
4202
4200
|
testedSpecs.add(newSpecKey)
|
|
@@ -4502,32 +4500,43 @@ async function pnpmFix(
|
|
|
4502
4500
|
if (!packument) {
|
|
4503
4501
|
continue
|
|
4504
4502
|
}
|
|
4505
|
-
const failedSpecs = new Set()
|
|
4506
4503
|
const fixedSpecs = new Set()
|
|
4507
|
-
const installedSpecs = new Set()
|
|
4508
|
-
const testedSpecs = new Set()
|
|
4509
|
-
const unavailableSpecs = new Set()
|
|
4510
|
-
const revertedSpecs = new Set()
|
|
4511
4504
|
for (const pkgJsonPath of pkgJsonPaths) {
|
|
4505
|
+
// Re-read actualTree to avoid lockfile state issues
|
|
4506
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4507
|
+
actualTree = await getActualTree(cwd)
|
|
4508
|
+
const pkgPath = path$1.dirname(pkgJsonPath)
|
|
4509
|
+
const isWorkspaceRoot =
|
|
4510
|
+
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4511
|
+
const workspaceName = isWorkspaceRoot
|
|
4512
|
+
? 'root'
|
|
4513
|
+
: path$1.relative(rootPath, pkgPath)
|
|
4514
|
+
const editablePkgJson = isWorkspaceRoot
|
|
4515
|
+
? pkgEnvDetails.editablePkgJson
|
|
4516
|
+
: // eslint-disable-next-line no-await-in-loop
|
|
4517
|
+
await packages.readPackageJson(pkgJsonPath, {
|
|
4518
|
+
editable: true
|
|
4519
|
+
})
|
|
4520
|
+
|
|
4521
|
+
// Get current overrides for revert logic
|
|
4522
|
+
const oldPnpmSection = editablePkgJson.content[PNPM$8]
|
|
4523
|
+
const oldOverrides = oldPnpmSection?.[OVERRIDES$2]
|
|
4512
4524
|
for (const oldVersion of oldVersions) {
|
|
4513
4525
|
const oldSpec = `${name}@${oldVersion}`
|
|
4514
4526
|
const oldPurl = `pkg:npm/${oldSpec}`
|
|
4527
|
+
const node = shadowNpmInject.findPackageNode(
|
|
4528
|
+
actualTree,
|
|
4529
|
+
name,
|
|
4530
|
+
oldVersion
|
|
4531
|
+
)
|
|
4532
|
+
if (!node) {
|
|
4533
|
+
debug.debugLog(`Skipping ${oldSpec}, no node found in ${pkgJsonPath}`)
|
|
4534
|
+
continue
|
|
4535
|
+
}
|
|
4515
4536
|
for (const {
|
|
4516
4537
|
firstPatchedVersionIdentifier,
|
|
4517
4538
|
vulnerableVersionRange
|
|
4518
4539
|
} of infos) {
|
|
4519
|
-
const node = shadowNpmInject.findPackageNode(
|
|
4520
|
-
actualTree,
|
|
4521
|
-
name,
|
|
4522
|
-
oldVersion
|
|
4523
|
-
)
|
|
4524
|
-
if (!node) {
|
|
4525
|
-
debug.debugLog(
|
|
4526
|
-
`Skipping ${oldSpec}, no node found in arborist.actualTree`,
|
|
4527
|
-
pkgJsonPath
|
|
4528
|
-
)
|
|
4529
|
-
continue
|
|
4530
|
-
}
|
|
4531
4540
|
const availableVersions = Object.keys(packument.versions)
|
|
4532
4541
|
const newVersion = shadowNpmInject.findBestPatchVersion(
|
|
4533
4542
|
node,
|
|
@@ -4538,30 +4547,9 @@ async function pnpmFix(
|
|
|
4538
4547
|
? packument.versions[newVersion]
|
|
4539
4548
|
: undefined
|
|
4540
4549
|
if (!(newVersion && newVersionPackument)) {
|
|
4541
|
-
|
|
4542
|
-
unavailableSpecs.add(oldSpec)
|
|
4543
|
-
spinner?.fail(`No update available for ${oldSpec}`)
|
|
4544
|
-
}
|
|
4550
|
+
spinner?.fail(`No update available for ${oldSpec}`)
|
|
4545
4551
|
continue
|
|
4546
4552
|
}
|
|
4547
|
-
const isWorkspaceRoot =
|
|
4548
|
-
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4549
|
-
const workspaceName = isWorkspaceRoot
|
|
4550
|
-
? ''
|
|
4551
|
-
: path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
|
|
4552
|
-
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
4553
|
-
const editablePkgJson = isWorkspaceRoot
|
|
4554
|
-
? pkgEnvDetails.editablePkgJson
|
|
4555
|
-
: // eslint-disable-next-line no-await-in-loop
|
|
4556
|
-
await packages.readPackageJson(pkgJsonPath, {
|
|
4557
|
-
editable: true
|
|
4558
|
-
})
|
|
4559
|
-
const oldPnpm = editablePkgJson.content[PNPM$8]
|
|
4560
|
-
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4561
|
-
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4562
|
-
const oldOverridesCount = oldOverrides
|
|
4563
|
-
? Object.keys(oldOverrides).length
|
|
4564
|
-
: 0
|
|
4565
4553
|
const overrideKey = `${name}@${vulnerableVersionRange}`
|
|
4566
4554
|
const newVersionRange = shadowNpmInject.applyRange(
|
|
4567
4555
|
oldOverrides?.[overrideKey] ?? oldVersion,
|
|
@@ -4569,14 +4557,20 @@ async function pnpmFix(
|
|
|
4569
4557
|
rangeStyle
|
|
4570
4558
|
)
|
|
4571
4559
|
const newSpec = `${name}@${newVersionRange}`
|
|
4572
|
-
const newSpecKey = `${workspaceName
|
|
4560
|
+
const newSpecKey = `${workspaceName}:${newSpec}`
|
|
4561
|
+
if (fixedSpecs.has(newSpecKey)) {
|
|
4562
|
+
debug.debugLog(
|
|
4563
|
+
`Already fixed ${newSpec} in ${workspaceName}, skipping`
|
|
4564
|
+
)
|
|
4565
|
+
continue
|
|
4566
|
+
}
|
|
4573
4567
|
const updateData = isWorkspaceRoot
|
|
4574
4568
|
? {
|
|
4575
4569
|
[PNPM$8]: {
|
|
4576
|
-
...
|
|
4570
|
+
...oldPnpmSection,
|
|
4577
4571
|
[OVERRIDES$2]: {
|
|
4578
|
-
|
|
4579
|
-
|
|
4572
|
+
...oldOverrides,
|
|
4573
|
+
[overrideKey]: newVersionRange
|
|
4580
4574
|
}
|
|
4581
4575
|
}
|
|
4582
4576
|
}
|
|
@@ -4584,44 +4578,28 @@ async function pnpmFix(
|
|
|
4584
4578
|
const revertData = {
|
|
4585
4579
|
...(isWorkspaceRoot
|
|
4586
4580
|
? {
|
|
4587
|
-
[PNPM$8]:
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
:
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
}
|
|
4598
|
-
: undefined
|
|
4581
|
+
[PNPM$8]: {
|
|
4582
|
+
...oldPnpmSection,
|
|
4583
|
+
[OVERRIDES$2]:
|
|
4584
|
+
oldOverrides && Object.keys(oldOverrides).length > 1
|
|
4585
|
+
? {
|
|
4586
|
+
...oldOverrides,
|
|
4587
|
+
[overrideKey]: undefined
|
|
4588
|
+
}
|
|
4589
|
+
: undefined
|
|
4590
|
+
}
|
|
4599
4591
|
}
|
|
4600
4592
|
: {}),
|
|
4601
|
-
...(editablePkgJson.content.dependencies
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
:
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
}
|
|
4611
|
-
: undefined),
|
|
4612
|
-
...(editablePkgJson.content.peerDependencies
|
|
4613
|
-
? {
|
|
4614
|
-
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4615
|
-
}
|
|
4616
|
-
: undefined)
|
|
4593
|
+
...(editablePkgJson.content.dependencies && {
|
|
4594
|
+
dependencies: editablePkgJson.content.dependencies
|
|
4595
|
+
}),
|
|
4596
|
+
...(editablePkgJson.content.optionalDependencies && {
|
|
4597
|
+
optionalDependencies: editablePkgJson.content.optionalDependencies
|
|
4598
|
+
}),
|
|
4599
|
+
...(editablePkgJson.content.peerDependencies && {
|
|
4600
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4601
|
+
})
|
|
4617
4602
|
}
|
|
4618
|
-
const branch = isCi
|
|
4619
|
-
? getSocketBranchName(oldPurl, newVersion, workspaceName)
|
|
4620
|
-
: ''
|
|
4621
|
-
const shouldOpenPr = isCi
|
|
4622
|
-
? // eslint-disable-next-line no-await-in-loop
|
|
4623
|
-
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4624
|
-
: false
|
|
4625
4603
|
if (updateData) {
|
|
4626
4604
|
editablePkgJson.update(updateData)
|
|
4627
4605
|
}
|
|
@@ -4633,107 +4611,104 @@ async function pnpmFix(
|
|
|
4633
4611
|
rangeStyle
|
|
4634
4612
|
)
|
|
4635
4613
|
debug.debugLog(`Updated package.json from node: ${modded}`)
|
|
4636
|
-
let error
|
|
4637
|
-
let errored = false
|
|
4638
|
-
let installed = false
|
|
4639
4614
|
|
|
4640
4615
|
// eslint-disable-next-line no-await-in-loop
|
|
4641
4616
|
if (!(await editablePkgJson.save())) {
|
|
4642
4617
|
debug.debugLog(
|
|
4643
|
-
`
|
|
4618
|
+
`No changes saved for ${pkgJsonPath}, skipping install`
|
|
4644
4619
|
)
|
|
4645
4620
|
continue
|
|
4646
4621
|
}
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
}
|
|
4622
|
+
spinner?.info(`Installing ${newSpec} in ${workspaceName}`)
|
|
4623
|
+
let errored = false
|
|
4624
|
+
let error
|
|
4651
4625
|
try {
|
|
4652
4626
|
// eslint-disable-next-line no-await-in-loop
|
|
4653
4627
|
actualTree = await install(pkgEnvDetails, {
|
|
4654
4628
|
spinner
|
|
4655
4629
|
})
|
|
4656
|
-
installed = true
|
|
4657
4630
|
if (test) {
|
|
4658
|
-
|
|
4659
|
-
testedSpecs.add(newSpecKey)
|
|
4660
|
-
spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
|
|
4661
|
-
}
|
|
4631
|
+
spinner?.info(`Testing ${newSpec} in ${workspaceName}`)
|
|
4662
4632
|
// eslint-disable-next-line no-await-in-loop
|
|
4663
4633
|
await npm.runScript(testScript, [], {
|
|
4664
4634
|
spinner,
|
|
4665
4635
|
stdio: 'ignore'
|
|
4666
4636
|
})
|
|
4667
4637
|
}
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4638
|
+
fixedSpecs.add(newSpecKey)
|
|
4639
|
+
spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`)
|
|
4640
|
+
spinner?.start()
|
|
4641
|
+
const branch = getSocketBranchName(
|
|
4642
|
+
oldPurl,
|
|
4643
|
+
newVersion,
|
|
4644
|
+
workspaceName
|
|
4645
|
+
)
|
|
4646
|
+
const shouldOpenPr = isCi
|
|
4647
|
+
? // eslint-disable-next-line no-await-in-loop
|
|
4648
|
+
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4649
|
+
: false
|
|
4650
|
+
if (
|
|
4651
|
+
isCi &&
|
|
4652
|
+
shouldOpenPr &&
|
|
4653
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4654
|
+
(await gitCreateAndPushBranchIfNeeded(
|
|
4655
|
+
branch,
|
|
4656
|
+
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4657
|
+
cwd
|
|
4658
|
+
))
|
|
4659
|
+
) {
|
|
4660
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4661
|
+
const prResponse = await openGitHubPullRequest(
|
|
4662
|
+
owner,
|
|
4663
|
+
repo,
|
|
4664
|
+
baseBranch,
|
|
4665
|
+
branch,
|
|
4666
|
+
oldPurl,
|
|
4667
|
+
newVersion,
|
|
4668
|
+
{
|
|
4669
|
+
cwd,
|
|
4670
|
+
workspaceName
|
|
4671
|
+
}
|
|
4672
|
+
)
|
|
4673
|
+
if (prResponse) {
|
|
4674
|
+
const { data } = prResponse
|
|
4675
|
+
spinner?.info(`PR #${data.number} opened.`)
|
|
4676
|
+
if (autoMerge) {
|
|
4677
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4678
|
+
await enableAutoMerge(data)
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4672
4681
|
}
|
|
4673
4682
|
} catch (e) {
|
|
4674
4683
|
error = e
|
|
4675
4684
|
errored = true
|
|
4676
4685
|
}
|
|
4677
|
-
if (
|
|
4678
|
-
|
|
4679
|
-
shouldOpenPr &&
|
|
4686
|
+
if (errored) {
|
|
4687
|
+
editablePkgJson.update(revertData)
|
|
4680
4688
|
// eslint-disable-next-line no-await-in-loop
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
))
|
|
4686
|
-
) {
|
|
4689
|
+
await Promise.all([
|
|
4690
|
+
shadowNpmInject.removeNodeModules(cwd),
|
|
4691
|
+
editablePkgJson.save()
|
|
4692
|
+
])
|
|
4687
4693
|
// eslint-disable-next-line no-await-in-loop
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
newVersion,
|
|
4695
|
-
{
|
|
4696
|
-
cwd,
|
|
4697
|
-
workspaceName
|
|
4698
|
-
}
|
|
4694
|
+
actualTree = await install(pkgEnvDetails, {
|
|
4695
|
+
spinner
|
|
4696
|
+
})
|
|
4697
|
+
spinner?.failAndStop(
|
|
4698
|
+
`Update failed for ${oldSpec} in ${workspaceName}`,
|
|
4699
|
+
error
|
|
4699
4700
|
)
|
|
4700
|
-
|
|
4701
|
-
const { data } = prResponse
|
|
4702
|
-
spinner?.info(`PR #${data.number} opened.`)
|
|
4703
|
-
if (autoMerge) {
|
|
4704
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4705
|
-
await enableAutoMerge(data)
|
|
4706
|
-
}
|
|
4707
|
-
}
|
|
4708
|
-
}
|
|
4709
|
-
if (errored || isCi) {
|
|
4710
|
-
if (errored) {
|
|
4711
|
-
if (!revertedSpecs.has(newSpecKey)) {
|
|
4712
|
-
revertedSpecs.add(newSpecKey)
|
|
4713
|
-
spinner?.error(`Reverting ${newSpec}${workspaceDetails}`, error)
|
|
4714
|
-
}
|
|
4715
|
-
}
|
|
4716
|
-
editablePkgJson.update(revertData)
|
|
4701
|
+
} else if (isCi) {
|
|
4717
4702
|
// eslint-disable-next-line no-await-in-loop
|
|
4718
4703
|
await Promise.all([
|
|
4719
4704
|
shadowNpmInject.removeNodeModules(cwd),
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
: []),
|
|
4723
|
-
...(installed && !isCi ? [editablePkgJson.save()] : [])
|
|
4705
|
+
// Reset to base branch to isolate next PR
|
|
4706
|
+
gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
|
|
4724
4707
|
])
|
|
4725
4708
|
// eslint-disable-next-line no-await-in-loop
|
|
4726
4709
|
actualTree = await install(pkgEnvDetails, {
|
|
4727
4710
|
spinner
|
|
4728
4711
|
})
|
|
4729
|
-
if (errored) {
|
|
4730
|
-
if (!failedSpecs.has(newSpecKey)) {
|
|
4731
|
-
failedSpecs.add(newSpecKey)
|
|
4732
|
-
spinner?.failAndStop(
|
|
4733
|
-
`Update failed for ${oldSpec}${workspaceDetails}`
|
|
4734
|
-
)
|
|
4735
|
-
}
|
|
4736
|
-
}
|
|
4737
4712
|
}
|
|
4738
4713
|
}
|
|
4739
4714
|
}
|
|
@@ -12307,7 +12282,7 @@ void (async () => {
|
|
|
12307
12282
|
await vendor.updater({
|
|
12308
12283
|
name: SOCKET_CLI_BIN_NAME,
|
|
12309
12284
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
12310
|
-
version: '0.14.
|
|
12285
|
+
version: '0.14.126',
|
|
12311
12286
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
12312
12287
|
})
|
|
12313
12288
|
try {
|
|
@@ -12375,5 +12350,5 @@ void (async () => {
|
|
|
12375
12350
|
await shadowNpmInject.captureException(e)
|
|
12376
12351
|
}
|
|
12377
12352
|
})()
|
|
12378
|
-
//# debugId=
|
|
12353
|
+
//# debugId=aa5acd0c-77d1-4ae1-8a7f-0c5b01e272c0
|
|
12379
12354
|
//# sourceMappingURL=cli.js.map
|