socket 1.0.35 → 1.0.37

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 CHANGED
@@ -3479,6 +3479,7 @@ async function getSocketPrsWithContext(owner, repo, options) {
3479
3479
  __proto__: null,
3480
3480
  ...options
3481
3481
  };
3482
+ const branchPattern = getSocketBranchPattern(options);
3482
3483
  const checkAuthor = strings.isNonEmptyString(author);
3483
3484
  const octokit = getOctokit();
3484
3485
  const octokitGraphql = getOctokitGraphql();
@@ -3518,8 +3519,8 @@ async function getSocketPrsWithContext(owner, repo, options) {
3518
3519
  const node = nodes[i];
3519
3520
  const login = node.author?.login;
3520
3521
  const matchesAuthor = checkAuthor ? login === author : true;
3521
- const parsedBranch = genericSocketBranchParser(node.headRefName);
3522
- if (matchesAuthor && parsedBranch) {
3522
+ const matchesBranch = branchPattern.test(node.headRefName);
3523
+ if (matchesAuthor && matchesBranch) {
3523
3524
  contextualMatches.push({
3524
3525
  context: {
3525
3526
  apiType: 'graphql',
@@ -3531,8 +3532,7 @@ async function getSocketPrsWithContext(owner, repo, options) {
3531
3532
  },
3532
3533
  match: {
3533
3534
  ...node,
3534
- author: login ?? '<unknown>',
3535
- parsedBranch
3535
+ author: login ?? '<unknown>'
3536
3536
  }
3537
3537
  });
3538
3538
  }
@@ -3563,8 +3563,8 @@ async function getSocketPrsWithContext(owner, repo, options) {
3563
3563
  const login = pr.user?.login;
3564
3564
  const headRefName = pr.head.ref;
3565
3565
  const matchesAuthor = checkAuthor ? login === author : true;
3566
- const parsedBranch = genericSocketBranchParser(headRefName);
3567
- if (matchesAuthor && parsedBranch) {
3566
+ const matchesBranch = branchPattern.test(headRefName);
3567
+ if (matchesAuthor && matchesBranch) {
3568
3568
  // Upper cased mergeable_state is equivalent to mergeStateStatus.
3569
3569
  // https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request
3570
3570
  const mergeStateStatus = pr.mergeable_state?.toUpperCase?.() ?? 'UNKNOWN';
@@ -3587,7 +3587,6 @@ async function getSocketPrsWithContext(owner, repo, options) {
3587
3587
  headRefName,
3588
3588
  mergeStateStatus,
3589
3589
  number: pr.number,
3590
- parsedBranch,
3591
3590
  state,
3592
3591
  title: pr.title
3593
3592
  }
@@ -3906,7 +3905,6 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
3906
3905
  const pkgPath = path.dirname(pkgJsonPath);
3907
3906
  const isWorkspaceRoot = pkgJsonPath === pkgEnvDetails.editablePkgJson.filename;
3908
3907
  const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
3909
- const branchWorkspace = fixEnv.isCi ? getSocketBranchWorkspaceComponent(workspace) : '';
3910
3908
  // actualTree may not be defined on the first iteration of pkgJsonPathsLoop.
3911
3909
  if (!actualTree) {
3912
3910
  if (!fixEnv.isCi) {
@@ -3980,9 +3978,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
3980
3978
  continue infosLoop;
3981
3979
  }
3982
3980
  const branch = getSocketBranchName(oldPurl, newVersion, workspace);
3983
- const pr = prs.find(({
3984
- parsedBranch: b
3985
- }) => b.workspace === branchWorkspace && b.newVersion === newVersion);
3981
+ const pr = prs.find(p => p.headRefName === branch);
3986
3982
  if (pr) {
3987
3983
  debug.debugFn('notice', `skip: PR #${pr.number} for ${name} exists`);
3988
3984
  if (++count >= limit) {
@@ -4037,6 +4033,8 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
4037
4033
  continue infosLoop;
4038
4034
  }
4039
4035
 
4036
+ // eslint-disable-next-line no-await-in-loop
4037
+ const pkgJsonSrc = await fs$1.promises.readFile(editablePkgJson.filename, 'utf8');
4040
4038
  // eslint-disable-next-line no-await-in-loop
4041
4039
  const lockSrc = await utils.readLockfile(pkgEnvDetails.lockPath);
4042
4040
  if (!hasAnnouncedWorkspace) {
@@ -4081,9 +4079,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
4081
4079
  if (!errored && fixEnv.isCi && fixEnv.repoInfo) {
4082
4080
  // Rewrite files in case the install reverted them.
4083
4081
  // eslint-disable-next-line no-await-in-loop
4084
- await editablePkgJson.save({
4085
- ignoreWhitespace: true
4086
- });
4082
+ await fs$1.promises.writeFile(editablePkgJson.filename, pkgJsonSrc, 'utf8');
4087
4083
  // eslint-disable-next-line no-await-in-loop
4088
4084
  await fs$1.promises.writeFile(pkgEnvDetails.lockPath, lockSrc, 'utf8');
4089
4085
  try {
@@ -4267,17 +4263,16 @@ async function npmFix(pkgEnvDetails, fixConfig) {
4267
4263
  spinner
4268
4264
  } = fixConfig;
4269
4265
  spinner?.start();
4270
- let arb;
4266
+ const flatConfig = await utils.getNpmConfig({
4267
+ npmVersion: pkgEnvDetails.agentVersion
4268
+ });
4271
4269
  let actualTree;
4272
4270
  let alertsMap;
4273
4271
  try {
4274
4272
  if (purls.length) {
4275
4273
  alertsMap = await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions());
4276
4274
  } else {
4277
- const flatConfig = await utils.getNpmConfig({
4278
- npmVersion: pkgEnvDetails.agentVersion
4279
- });
4280
- arb = new shadowNpmInject.Arborist({
4275
+ const arb = new shadowNpmInject.Arborist({
4281
4276
  path: pkgEnvDetails.pkgPath,
4282
4277
  ...flatConfig
4283
4278
  });
@@ -4318,6 +4313,10 @@ async function npmFix(pkgEnvDetails, fixConfig) {
4318
4313
  }
4319
4314
  })
4320
4315
  };
4316
+ const arb = new shadowNpmInject.Arborist({
4317
+ path: pkgEnvDetails.pkgPath,
4318
+ ...flatConfig
4319
+ });
4321
4320
  const idealTree = await arb.buildIdealTree();
4322
4321
  const node = shadowNpmInject.findPackageNode(idealTree, packument.name, oldVersion);
4323
4322
  if (node) {
@@ -14263,5 +14262,5 @@ void (async () => {
14263
14262
  await utils.captureException(e);
14264
14263
  }
14265
14264
  })();
14266
- //# debugId=4d4efe6d-3f8e-4bd8-b5f9-0987e88a59d4
14265
+ //# debugId=66b4f897-caf8-4f1b-ac3a-1f9030377bf2
14267
14266
  //# sourceMappingURL=cli.js.map