socket 1.0.41 → 1.0.42

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
@@ -3812,9 +3812,9 @@ function getOverridesData(pkgEnvDetails, pkgJson) {
3812
3812
 
3813
3813
  const noopHandler = () => {};
3814
3814
  async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
3815
- beforeInstall = noopHandler,
3816
- // eslint-disable-next-line sort-destructure-keys/sort-destructure-keys
3817
3815
  afterInstall = noopHandler,
3816
+ afterUpdate = noopHandler,
3817
+ beforeInstall = noopHandler,
3818
3818
  revertInstall = noopHandler
3819
3819
  }, fixConfig) {
3820
3820
  const {
@@ -4040,6 +4040,9 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
4040
4040
  ignoreWhitespace: true
4041
4041
  });
4042
4042
 
4043
+ // eslint-disable-next-line no-await-in-loop
4044
+ await afterUpdate(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
4045
+
4043
4046
  // eslint-disable-next-line no-await-in-loop
4044
4047
  const unstagedCResult = await gitUnstagedModifiedFiles(cwd);
4045
4048
  const moddedFilepaths = unstagedCResult.ok ? unstagedCResult.data.filter(filepath => {
@@ -4057,11 +4060,6 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
4057
4060
  }
4058
4061
  continue infosLoop;
4059
4062
  }
4060
-
4061
- // eslint-disable-next-line no-await-in-loop
4062
- const pkgJsonSrc = await fs$1.promises.readFile(editablePkgJson.filename, 'utf8');
4063
- // eslint-disable-next-line no-await-in-loop
4064
- const lockSrc = await utils.readLockfile(pkgEnvDetails.lockPath);
4065
4063
  if (!hasAnnouncedWorkspace) {
4066
4064
  hasAnnouncedWorkspace = true;
4067
4065
  workspaceLogCallCount = logger.logger.logCallCount;
@@ -4102,11 +4100,6 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
4102
4100
 
4103
4101
  // Check repoInfo to make TypeScript happy.
4104
4102
  if (!errored && fixEnv.isCi && fixEnv.repoInfo) {
4105
- // Rewrite files in case the install reverted them.
4106
- // eslint-disable-next-line no-await-in-loop
4107
- await fs$1.promises.writeFile(editablePkgJson.filename, pkgJsonSrc, 'utf8');
4108
- // eslint-disable-next-line no-await-in-loop
4109
- await fs$1.promises.writeFile(pkgEnvDetails.lockPath, lockSrc, 'utf8');
4110
4103
  try {
4111
4104
  if (
4112
4105
  // eslint-disable-next-line no-await-in-loop
@@ -4328,7 +4321,7 @@ async function npmFix(pkgEnvDetails, fixConfig) {
4328
4321
  }
4329
4322
  let revertData;
4330
4323
  return await agentFix(pkgEnvDetails, actualTree, alertsMap, install$1, {
4331
- async beforeInstall(editablePkgJson, packument, oldVersion, newVersion) {
4324
+ async beforeInstall(editablePkgJson) {
4332
4325
  revertData = {
4333
4326
  ...(editablePkgJson.content.dependencies && {
4334
4327
  dependencies: {
@@ -4346,15 +4339,20 @@ async function npmFix(pkgEnvDetails, fixConfig) {
4346
4339
  }
4347
4340
  })
4348
4341
  };
4349
- const arb = new shadowNpmInject.Arborist({
4350
- path: pkgEnvDetails.pkgPath,
4351
- ...flatConfig
4352
- });
4353
- const idealTree = await arb.buildIdealTree();
4354
- const node = shadowNpmInject.findPackageNode(idealTree, packument.name, oldVersion);
4355
- if (node) {
4356
- shadowNpmInject.updateNode(node, newVersion, packument.versions[newVersion]);
4357
- await arb.reify();
4342
+ },
4343
+ async afterUpdate(editablePkgJson, packument, oldVersion, newVersion) {
4344
+ const isWorkspaceRoot = editablePkgJson.filename === pkgEnvDetails.editablePkgJson.filename;
4345
+ if (isWorkspaceRoot) {
4346
+ const arb = new shadowNpmInject.Arborist({
4347
+ path: pkgEnvDetails.pkgPath,
4348
+ ...flatConfig
4349
+ });
4350
+ const idealTree = await arb.buildIdealTree();
4351
+ const node = shadowNpmInject.findPackageNode(idealTree, packument.name, oldVersion);
4352
+ if (node) {
4353
+ shadowNpmInject.updateNode(node, newVersion, packument.versions[newVersion]);
4354
+ await arb.reify();
4355
+ }
4358
4356
  }
4359
4357
  },
4360
4358
  async revertInstall(editablePkgJson) {
@@ -14305,5 +14303,5 @@ void (async () => {
14305
14303
  await utils.captureException(e);
14306
14304
  }
14307
14305
  })();
14308
- //# debugId=61ea85e2-e40e-4ae7-ba74-ed9c4d21ffab
14306
+ //# debugId=1cc1c955-a609-45d8-a905-6f7ba892424a
14309
14307
  //# sourceMappingURL=cli.js.map