@socketsecurity/cli-with-sentry 1.0.37 → 1.0.39
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/cli.js +55 -12
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/types/commands/fix/agent-fix.d.mts +1 -0
- package/dist/types/commands/fix/agent-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/git.d.mts +2 -0
- package/dist/types/commands/fix/git.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -3096,7 +3096,22 @@ async function gitCleanFdx(cwd = process.cwd()) {
|
|
|
3096
3096
|
// TODO: propagate CResult?
|
|
3097
3097
|
await spawn.spawn('git', ['clean', '-fdx'], stdioIgnoreOptions);
|
|
3098
3098
|
}
|
|
3099
|
+
async function gitCheckoutBranch(branch, cwd = process.cwd()) {
|
|
3100
|
+
const stdioIgnoreOptions = {
|
|
3101
|
+
cwd,
|
|
3102
|
+
stdio: debug.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
3103
|
+
};
|
|
3104
|
+
try {
|
|
3105
|
+
await spawn.spawn('git', ['checkout', branch], stdioIgnoreOptions);
|
|
3106
|
+
return true;
|
|
3107
|
+
} catch {}
|
|
3108
|
+
return false;
|
|
3109
|
+
}
|
|
3099
3110
|
async function gitCreateAndPushBranch(branch, commitMsg, filepaths, options) {
|
|
3111
|
+
if (!filepaths.length) {
|
|
3112
|
+
debug.debugFn('notice', `miss: no filepaths to add`);
|
|
3113
|
+
return false;
|
|
3114
|
+
}
|
|
3100
3115
|
const {
|
|
3101
3116
|
cwd = process.cwd(),
|
|
3102
3117
|
// Lazily access constants.ENV.SOCKET_CLI_GIT_USER_EMAIL.
|
|
@@ -3124,9 +3139,17 @@ async function gitCreateAndPushBranch(branch, commitMsg, filepaths, options) {
|
|
|
3124
3139
|
error: e
|
|
3125
3140
|
});
|
|
3126
3141
|
}
|
|
3142
|
+
return false;
|
|
3143
|
+
}
|
|
3144
|
+
async function gitDeleteBranch(branch, cwd = process.cwd()) {
|
|
3145
|
+
const stdioIgnoreOptions = {
|
|
3146
|
+
cwd,
|
|
3147
|
+
stdio: debug.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
3148
|
+
};
|
|
3127
3149
|
try {
|
|
3128
3150
|
// Will throw with exit code 1 if branch does not exist.
|
|
3129
3151
|
await spawn.spawn('git', ['branch', '-D', branch], stdioIgnoreOptions);
|
|
3152
|
+
return true;
|
|
3130
3153
|
} catch {}
|
|
3131
3154
|
return false;
|
|
3132
3155
|
}
|
|
@@ -3803,6 +3826,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3803
3826
|
cwd,
|
|
3804
3827
|
limit,
|
|
3805
3828
|
minSatisfying,
|
|
3829
|
+
noPrCheck,
|
|
3806
3830
|
rangeStyle,
|
|
3807
3831
|
spinner,
|
|
3808
3832
|
test,
|
|
@@ -3890,6 +3914,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3890
3914
|
if (!packument) {
|
|
3891
3915
|
logger.logger.warn(`Unexpected condition: No packument found for ${name}.\n`);
|
|
3892
3916
|
cleanupInfoEntriesLoop();
|
|
3917
|
+
// Skip to next package.
|
|
3893
3918
|
continue infoEntriesLoop;
|
|
3894
3919
|
}
|
|
3895
3920
|
const availableVersions = Object.keys(packument.versions);
|
|
@@ -3930,8 +3955,8 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3930
3955
|
const oldVersions = arrays.arrayUnique(shadowNpmInject.findPackageNodes(actualTree, name).map(n => n.version).filter(Boolean));
|
|
3931
3956
|
if (!oldVersions.length) {
|
|
3932
3957
|
debug.debugFn('notice', `skip: ${name} not found\n`);
|
|
3933
|
-
// Skip to next package.
|
|
3934
3958
|
cleanupInfoEntriesLoop();
|
|
3959
|
+
// Skip to next package.
|
|
3935
3960
|
continue infoEntriesLoop;
|
|
3936
3961
|
}
|
|
3937
3962
|
|
|
@@ -3941,6 +3966,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3941
3966
|
const editablePkgJson = await packages.readPackageJson(pkgJsonPath, {
|
|
3942
3967
|
editable: true
|
|
3943
3968
|
});
|
|
3969
|
+
const seenBranches = new Set();
|
|
3944
3970
|
const seenVersions = new Set();
|
|
3945
3971
|
let hasAnnouncedWorkspace = false;
|
|
3946
3972
|
let workspaceLogCallCount = logger.logger.logCallCount;
|
|
@@ -3978,23 +4004,20 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3978
4004
|
continue infosLoop;
|
|
3979
4005
|
}
|
|
3980
4006
|
const branch = getSocketBranchName(oldPurl, newVersion, workspace);
|
|
3981
|
-
|
|
4007
|
+
if (seenBranches.has(newVersion)) {
|
|
4008
|
+
continue infosLoop;
|
|
4009
|
+
}
|
|
4010
|
+
const pr = noPrCheck ? undefined : prs.find(p => p.headRefName === branch);
|
|
3982
4011
|
if (pr) {
|
|
3983
4012
|
debug.debugFn('notice', `skip: PR #${pr.number} for ${name} exists`);
|
|
3984
|
-
|
|
3985
|
-
cleanupInfoEntriesLoop();
|
|
3986
|
-
break infoEntriesLoop;
|
|
3987
|
-
}
|
|
4013
|
+
seenBranches.add(branch);
|
|
3988
4014
|
continue infosLoop;
|
|
3989
4015
|
}
|
|
3990
4016
|
if (fixEnv.isCi && (
|
|
3991
4017
|
// eslint-disable-next-line no-await-in-loop
|
|
3992
4018
|
await gitRemoteBranchExists(branch, cwd))) {
|
|
3993
4019
|
debug.debugFn('notice', `skip: remote branch "${branch}" exists`);
|
|
3994
|
-
|
|
3995
|
-
cleanupInfoEntriesLoop();
|
|
3996
|
-
break infoEntriesLoop;
|
|
3997
|
-
}
|
|
4020
|
+
seenBranches.add(branch);
|
|
3998
4021
|
continue infosLoop;
|
|
3999
4022
|
}
|
|
4000
4023
|
const {
|
|
@@ -4029,6 +4052,8 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4029
4052
|
if (fixEnv.isCi) {
|
|
4030
4053
|
// eslint-disable-next-line no-await-in-loop
|
|
4031
4054
|
await gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4055
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4056
|
+
await gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4032
4057
|
}
|
|
4033
4058
|
continue infosLoop;
|
|
4034
4059
|
}
|
|
@@ -4094,6 +4119,10 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4094
4119
|
// eslint-disable-next-line no-await-in-loop
|
|
4095
4120
|
await gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4096
4121
|
// eslint-disable-next-line no-await-in-loop
|
|
4122
|
+
await gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4123
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4124
|
+
await gitDeleteBranch(branch, cwd);
|
|
4125
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4097
4126
|
const maybeActualTree = await installer(pkgEnvDetails, {
|
|
4098
4127
|
cwd,
|
|
4099
4128
|
spinner
|
|
@@ -4105,6 +4134,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4105
4134
|
// Exit early if install fails.
|
|
4106
4135
|
return handleInstallFail();
|
|
4107
4136
|
}
|
|
4137
|
+
seenBranches.add(branch);
|
|
4108
4138
|
|
|
4109
4139
|
// eslint-disable-next-line no-await-in-loop
|
|
4110
4140
|
await Promise.allSettled([setGitRemoteGithubRepoUrl(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, fixEnv.githubToken, cwd), cleanupPrs(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, {
|
|
@@ -4150,7 +4180,9 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4150
4180
|
if (fixEnv.isCi) {
|
|
4151
4181
|
spinner?.start();
|
|
4152
4182
|
// eslint-disable-next-line no-await-in-loop
|
|
4153
|
-
await gitResetAndClean(
|
|
4183
|
+
await gitResetAndClean(branch, cwd);
|
|
4184
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4185
|
+
await gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4154
4186
|
// eslint-disable-next-line no-await-in-loop
|
|
4155
4187
|
const maybeActualTree = await installer(pkgEnvDetails, {
|
|
4156
4188
|
cwd,
|
|
@@ -4194,6 +4226,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4194
4226
|
debug.debugFn('notice', 'increment: count', count + 1);
|
|
4195
4227
|
if (++count >= limit) {
|
|
4196
4228
|
cleanupInfoEntriesLoop();
|
|
4229
|
+
// Exit main loop.
|
|
4197
4230
|
break infoEntriesLoop;
|
|
4198
4231
|
}
|
|
4199
4232
|
}
|
|
@@ -4520,6 +4553,7 @@ async function handleFix({
|
|
|
4520
4553
|
ghsas,
|
|
4521
4554
|
limit,
|
|
4522
4555
|
minSatisfying,
|
|
4556
|
+
noPrCheck,
|
|
4523
4557
|
outputKind,
|
|
4524
4558
|
purls,
|
|
4525
4559
|
rangeStyle,
|
|
@@ -4615,6 +4649,7 @@ async function handleFix({
|
|
|
4615
4649
|
cwd,
|
|
4616
4650
|
limit,
|
|
4617
4651
|
minSatisfying,
|
|
4652
|
+
noPrCheck,
|
|
4618
4653
|
purls,
|
|
4619
4654
|
rangeStyle,
|
|
4620
4655
|
spinner,
|
|
@@ -4664,6 +4699,12 @@ const config$H = {
|
|
|
4664
4699
|
default: false,
|
|
4665
4700
|
description: 'Constrain dependency updates to the minimum satisfying version'
|
|
4666
4701
|
},
|
|
4702
|
+
noPrCheck: {
|
|
4703
|
+
type: 'boolean',
|
|
4704
|
+
default: false,
|
|
4705
|
+
description: 'Skip PR existence check',
|
|
4706
|
+
hidden: true
|
|
4707
|
+
},
|
|
4667
4708
|
purl: {
|
|
4668
4709
|
type: 'string',
|
|
4669
4710
|
default: [],
|
|
@@ -4769,6 +4810,7 @@ async function run$H(argv, importMeta, {
|
|
|
4769
4810
|
const limit = (cli.flags['limit'] ? parseInt(String(cli.flags['limit'] || ''), 10) : Infinity) || Infinity;
|
|
4770
4811
|
const maxSatisfying = Boolean(cli.flags['maxSatisfying']);
|
|
4771
4812
|
const minSatisfying = Boolean(cli.flags['minSatisfying']) || !maxSatisfying;
|
|
4813
|
+
const noPrCheck = Boolean(cli.flags['noPrCheck']);
|
|
4772
4814
|
const purls = utils.cmdFlagValueToArray(cli.flags['purl']);
|
|
4773
4815
|
const testScript = String(cli.flags['testScript'] || 'test');
|
|
4774
4816
|
await handleFix({
|
|
@@ -4777,6 +4819,7 @@ async function run$H(argv, importMeta, {
|
|
|
4777
4819
|
ghsas,
|
|
4778
4820
|
limit,
|
|
4779
4821
|
minSatisfying,
|
|
4822
|
+
noPrCheck,
|
|
4780
4823
|
outputKind,
|
|
4781
4824
|
purls,
|
|
4782
4825
|
rangeStyle,
|
|
@@ -14262,5 +14305,5 @@ void (async () => {
|
|
|
14262
14305
|
await utils.captureException(e);
|
|
14263
14306
|
}
|
|
14264
14307
|
})();
|
|
14265
|
-
//# debugId=
|
|
14308
|
+
//# debugId=87862000-d157-410a-ab83-7488bd4cfc60
|
|
14266
14309
|
//# sourceMappingURL=cli.js.map
|