@coana-tech/cli 14.12.28 → 14.12.29

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/cli.mjs CHANGED
@@ -11905,15 +11905,15 @@ var require_file = __commonJS({
11905
11905
  _incFile(callback) {
11906
11906
  debug("_incFile", this.filename);
11907
11907
  const ext2 = path2.extname(this._basename);
11908
- const basename10 = path2.basename(this._basename, ext2);
11908
+ const basename11 = path2.basename(this._basename, ext2);
11909
11909
  const tasks = [];
11910
11910
  if (this.zippedArchive) {
11911
11911
  tasks.push(
11912
11912
  function(cb) {
11913
11913
  const num = this._created > 0 && !this.tailable ? this._created : "";
11914
11914
  this._compressFile(
11915
- path2.join(this.dirname, `${basename10}${num}${ext2}`),
11916
- path2.join(this.dirname, `${basename10}${num}${ext2}.gz`),
11915
+ path2.join(this.dirname, `${basename11}${num}${ext2}`),
11916
+ path2.join(this.dirname, `${basename11}${num}${ext2}.gz`),
11917
11917
  cb
11918
11918
  );
11919
11919
  }.bind(this)
@@ -11923,9 +11923,9 @@ var require_file = __commonJS({
11923
11923
  function(cb) {
11924
11924
  if (!this.tailable) {
11925
11925
  this._created += 1;
11926
- this._checkMaxFilesIncrementing(ext2, basename10, cb);
11926
+ this._checkMaxFilesIncrementing(ext2, basename11, cb);
11927
11927
  } else {
11928
- this._checkMaxFilesTailable(ext2, basename10, cb);
11928
+ this._checkMaxFilesTailable(ext2, basename11, cb);
11929
11929
  }
11930
11930
  }.bind(this)
11931
11931
  );
@@ -11939,9 +11939,9 @@ var require_file = __commonJS({
11939
11939
  */
11940
11940
  _getFile() {
11941
11941
  const ext2 = path2.extname(this._basename);
11942
- const basename10 = path2.basename(this._basename, ext2);
11942
+ const basename11 = path2.basename(this._basename, ext2);
11943
11943
  const isRotation = this.rotationFormat ? this.rotationFormat() : this._created;
11944
- return !this.tailable && this._created ? `${basename10}${isRotation}${ext2}` : `${basename10}${ext2}`;
11944
+ return !this.tailable && this._created ? `${basename11}${isRotation}${ext2}` : `${basename11}${ext2}`;
11945
11945
  }
11946
11946
  /**
11947
11947
  * Increment the number of files created or checked by this instance.
@@ -11951,14 +11951,14 @@ var require_file = __commonJS({
11951
11951
  * @returns {undefined}
11952
11952
  * @private
11953
11953
  */
11954
- _checkMaxFilesIncrementing(ext2, basename10, callback) {
11954
+ _checkMaxFilesIncrementing(ext2, basename11, callback) {
11955
11955
  if (!this.maxFiles || this._created < this.maxFiles) {
11956
11956
  return setImmediate(callback);
11957
11957
  }
11958
11958
  const oldest = this._created - this.maxFiles;
11959
11959
  const isOldest = oldest !== 0 ? oldest : "";
11960
11960
  const isZipped = this.zippedArchive ? ".gz" : "";
11961
- const filePath = `${basename10}${isOldest}${ext2}${isZipped}`;
11961
+ const filePath = `${basename11}${isOldest}${ext2}${isZipped}`;
11962
11962
  const target = path2.join(this.dirname, filePath);
11963
11963
  fs.unlink(target, callback);
11964
11964
  }
@@ -11973,7 +11973,7 @@ var require_file = __commonJS({
11973
11973
  * @returns {undefined}
11974
11974
  * @private
11975
11975
  */
11976
- _checkMaxFilesTailable(ext2, basename10, callback) {
11976
+ _checkMaxFilesTailable(ext2, basename11, callback) {
11977
11977
  const tasks = [];
11978
11978
  if (!this.maxFiles) {
11979
11979
  return;
@@ -11981,21 +11981,21 @@ var require_file = __commonJS({
11981
11981
  const isZipped = this.zippedArchive ? ".gz" : "";
11982
11982
  for (let x2 = this.maxFiles - 1; x2 > 1; x2--) {
11983
11983
  tasks.push(function(i6, cb) {
11984
- let fileName3 = `${basename10}${i6 - 1}${ext2}${isZipped}`;
11984
+ let fileName3 = `${basename11}${i6 - 1}${ext2}${isZipped}`;
11985
11985
  const tmppath = path2.join(this.dirname, fileName3);
11986
11986
  fs.exists(tmppath, (exists2) => {
11987
11987
  if (!exists2) {
11988
11988
  return cb(null);
11989
11989
  }
11990
- fileName3 = `${basename10}${i6}${ext2}${isZipped}`;
11990
+ fileName3 = `${basename11}${i6}${ext2}${isZipped}`;
11991
11991
  fs.rename(tmppath, path2.join(this.dirname, fileName3), cb);
11992
11992
  });
11993
11993
  }.bind(this, x2));
11994
11994
  }
11995
11995
  asyncSeries(tasks, () => {
11996
11996
  fs.rename(
11997
- path2.join(this.dirname, `${basename10}${ext2}${isZipped}`),
11998
- path2.join(this.dirname, `${basename10}1${ext2}${isZipped}`),
11997
+ path2.join(this.dirname, `${basename11}${ext2}${isZipped}`),
11998
+ path2.join(this.dirname, `${basename11}1${ext2}${isZipped}`),
11999
11999
  callback
12000
12000
  );
12001
12001
  });
@@ -45334,7 +45334,7 @@ var require_mime_types = __commonJS({
45334
45334
  "../../node_modules/.pnpm/mime-types@2.1.35/node_modules/mime-types/index.js"(exports2) {
45335
45335
  "use strict";
45336
45336
  var db = require_mime_db();
45337
- var extname = __require("path").extname;
45337
+ var extname2 = __require("path").extname;
45338
45338
  var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
45339
45339
  var TEXT_TYPE_REGEXP = /^text\//i;
45340
45340
  exports2.charset = charset;
@@ -45388,7 +45388,7 @@ var require_mime_types = __commonJS({
45388
45388
  if (!path2 || typeof path2 !== "string") {
45389
45389
  return false;
45390
45390
  }
45391
- var extension2 = extname("x." + path2).toLowerCase().substr(1);
45391
+ var extension2 = extname2("x." + path2).toLowerCase().substr(1);
45392
45392
  if (!extension2) {
45393
45393
  return false;
45394
45394
  }
@@ -96473,7 +96473,7 @@ var require_parseParams = __commonJS({
96473
96473
  var require_basename = __commonJS({
96474
96474
  "../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
96475
96475
  "use strict";
96476
- module2.exports = function basename10(path2) {
96476
+ module2.exports = function basename11(path2) {
96477
96477
  if (typeof path2 !== "string") {
96478
96478
  return "";
96479
96479
  }
@@ -96500,7 +96500,7 @@ var require_multipart = __commonJS({
96500
96500
  var Dicer = require_Dicer();
96501
96501
  var parseParams = require_parseParams();
96502
96502
  var decodeText = require_decodeText();
96503
- var basename10 = require_basename();
96503
+ var basename11 = require_basename();
96504
96504
  var getLimit2 = require_getLimit();
96505
96505
  var RE_BOUNDARY = /^boundary$/i;
96506
96506
  var RE_FIELD = /^form-data$/i;
@@ -96617,7 +96617,7 @@ var require_multipart = __commonJS({
96617
96617
  } else if (RE_FILENAME.test(parsed[i6][0])) {
96618
96618
  filename = parsed[i6][1];
96619
96619
  if (!preservePath) {
96620
- filename = basename10(filename);
96620
+ filename = basename11(filename);
96621
96621
  }
96622
96622
  }
96623
96623
  }
@@ -115453,8 +115453,8 @@ var require_tmp = __commonJS({
115453
115453
  if (option === "name") {
115454
115454
  if (path2.isAbsolute(name))
115455
115455
  throw new Error(`${option} option must not contain an absolute path, found "${name}".`);
115456
- let basename10 = path2.basename(name);
115457
- if (basename10 === ".." || basename10 === "." || basename10 !== name)
115456
+ let basename11 = path2.basename(name);
115457
+ if (basename11 === ".." || basename11 === "." || basename11 !== name)
115458
115458
  throw new Error(`${option} option must not contain a path, found "${name}".`);
115459
115459
  } else {
115460
115460
  if (path2.isAbsolute(name) && !name.startsWith(tmpDir)) {
@@ -194030,11 +194030,10 @@ async function loadPom(rootDir, pomFile, validateFile, visited = /* @__PURE__ */
194030
194030
  xml: xml2,
194031
194031
  indentation,
194032
194032
  sourceText,
194033
- profiles: /* @__PURE__ */ new Map(),
194034
- visited
194033
+ profiles: /* @__PURE__ */ new Map()
194035
194034
  };
194036
194035
  const parentPomPath = getParentPomPath(pom);
194037
- const parentPom = parentPomPath ? await loadPom(rootDir, parentPomPath, validateFile) : void 0;
194036
+ const parentPom = parentPomPath ? await loadPom(rootDir, parentPomPath, validateFile, visited) : void 0;
194038
194037
  pom.profiles = extractProfilesFromPom(pom, parentPom?.profiles);
194039
194038
  return pom;
194040
194039
  }
@@ -194240,7 +194239,7 @@ function evaluate(expression, pom, profileId) {
194240
194239
  if (property) {
194241
194240
  return evaluateWithContext(property.text, depth + 1);
194242
194241
  } else {
194243
- logger.warn(`Unknown property ${propertyName} for pom ${relative2(pom.rootDir, pom.validatedPomFile)}`);
194242
+ logger.debug(`Unknown property ${propertyName} for pom ${relative2(pom.rootDir, pom.validatedPomFile)}`);
194244
194243
  return match2;
194245
194244
  }
194246
194245
  });
@@ -198810,12 +198809,18 @@ var MavenSocketUpgradeManager = class {
198810
198809
  const patches = [];
198811
198810
  for (const upgrade of upgrades) {
198812
198811
  const artifact = artifacts[upgrade.idx];
198813
- const directManifestFiles = i(artifact.manifestFiles?.map((ref) => ref.file) ?? []);
198814
- for (const manifestFile of directManifestFiles) {
198812
+ const manifestFilesForArtifact = i(
198813
+ (artifact.manifestFiles?.map((ref) => ref.file) ?? []).concat(
198814
+ artifact.toplevelAncestors?.flatMap(
198815
+ (ancestorId) => artifacts.find((a5) => a5.id === ancestorId)?.manifestFiles?.map((m3) => m3.file) ?? []
198816
+ ) ?? []
198817
+ )
198818
+ );
198819
+ for (const manifestFile of manifestFilesForArtifact) {
198815
198820
  if (this.pomMatcher(basename(manifestFile))) {
198816
198821
  const project = await loadPom(this.rootDir, manifestFile, validateFile);
198817
198822
  if (project) {
198818
- for (const patch of await this.handlePom(project, upgrade, artifact, rangeStyle, "DIRECT")) {
198823
+ for (const patch of await this.handlePom(project, upgrade, artifact, rangeStyle)) {
198819
198824
  patches.push(patch);
198820
198825
  }
198821
198826
  } else {
@@ -198828,43 +198833,7 @@ var MavenSocketUpgradeManager = class {
198828
198833
  } else if (this.gradleLockfileMatcher(basename(manifestFile))) {
198829
198834
  const lockFileContent = await loadLockFile(this.rootDir, manifestFile, validateFile);
198830
198835
  if (lockFileContent) {
198831
- for (const patch of await this.handleGradleLockfile(lockFileContent, upgrade, artifact, "DIRECT")) {
198832
- patches.push(patch);
198833
- }
198834
- } else {
198835
- patches.push({
198836
- success: false,
198837
- upgrades: [upgrade],
198838
- reason: `Manifest file not valid for updates: ${manifestFile}`
198839
- });
198840
- }
198841
- } else {
198842
- logger.warn(`File does not match supported patterns for upgrading dependencies: ${manifestFile}`);
198843
- }
198844
- }
198845
- const ancestorManifestFiles = i(
198846
- artifact.toplevelAncestors?.flatMap(
198847
- (ancestorId) => artifacts.find((a5) => a5.id === ancestorId)?.manifestFiles?.map((ref) => ref.file) ?? []
198848
- ) ?? []
198849
- );
198850
- for (const manifestFile of ancestorManifestFiles) {
198851
- if (this.pomMatcher(basename(manifestFile))) {
198852
- const project = await loadPom(this.rootDir, manifestFile, validateFile);
198853
- if (project) {
198854
- for (const patch of await this.handlePom(project, upgrade, artifact, rangeStyle, "ANCESTOR")) {
198855
- patches.push(patch);
198856
- }
198857
- } else {
198858
- patches.push({
198859
- success: false,
198860
- upgrades: [upgrade],
198861
- reason: `Manifest file not valid for updates: ${manifestFile}`
198862
- });
198863
- }
198864
- } else if (this.gradleLockfileMatcher(basename(manifestFile))) {
198865
- const lockFile = await loadLockFile(this.rootDir, manifestFile, validateFile);
198866
- if (lockFile) {
198867
- for (const patch of await this.handleGradleLockfile(lockFile, upgrade, artifact, "ANCESTOR")) {
198836
+ for (const patch of await this.handleGradleLockfile(lockFileContent, upgrade, artifact)) {
198868
198837
  patches.push(patch);
198869
198838
  }
198870
198839
  } else {
@@ -198884,7 +198853,7 @@ var MavenSocketUpgradeManager = class {
198884
198853
  /**
198885
198854
  * Handle POM files for updating existing dependencies/managed dependencies
198886
198855
  */
198887
- async handlePom(pom, upgrade, artifact, rangeStyle, kind) {
198856
+ async handlePom(pom, upgrade, artifact, rangeStyle) {
198888
198857
  const patches = [];
198889
198858
  assert3(artifact.namespace);
198890
198859
  assert3(artifact.name);
@@ -198899,78 +198868,36 @@ var MavenSocketUpgradeManager = class {
198899
198868
  new Restriction(upgradeMavenVersion, true, upgradeMavenVersion, true)
198900
198869
  ]);
198901
198870
  const upgradeMavenRange = existingMavenVersion.compareTo(upgradeMavenVersion) <= 0 ? new VersionRange(null, [new Restriction(upgradeMavenVersion, true, null, false)]) : new VersionRange(null, [new Restriction(null, false, upgradeMavenVersion, true)]);
198902
- if (kind === "DIRECT") {
198903
- for (const [profileId, profile] of pom.profiles) {
198904
- const foundDep = profile.dependencies.reverse().find((dep) => {
198905
- return groupId === evaluate(dep.groupId.text, pom, profileId) && artifactId === evaluate(dep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(dep.type?.text ?? "jar", pom, profileId) && classifier === (dep.classifier && evaluate(dep.classifier.text, pom, profileId));
198906
- });
198907
- if (foundDep) {
198908
- if (foundDep.version) {
198909
- const existingVersionRange = VersionRange.createFromVersionSpec(evaluate(foundDep.version.text, pom));
198910
- const patchLocation = findPatchLocation(foundDep.pom.validatedPomFile, foundDep.version, pom, profileId);
198911
- if (patchLocation?.offset !== void 0) {
198912
- patches.push({
198913
- success: true,
198914
- upgrades: [upgrade],
198915
- patch: {
198916
- file: patchLocation.file,
198917
- offset: patchLocation.offset,
198918
- oldText: patchLocation.text,
198919
- newText: (
198920
- // Use pinned version if rangeStyle is set or if we break existing spec!
198921
- rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
198922
- )
198923
- }
198924
- });
198925
- } else {
198926
- patches.push({
198927
- success: false,
198928
- upgrades: [upgrade],
198929
- reason: "Failed to create patch for direct dependency"
198930
- });
198931
- }
198932
- } else {
198933
- const foundManagedDep = profile.managedDependencies.reverse().concat(pom.profiles.get(void 0)?.managedDependencies.reverse() ?? []).find((dep) => {
198934
- return groupId === evaluate(dep.groupId.text, pom, profileId) && artifactId === evaluate(dep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(dep.type?.text ?? "jar", pom, profileId) && classifier === (dep.classifier && evaluate(dep.classifier.text, pom, profileId));
198935
- });
198936
- if (foundManagedDep) {
198937
- const existingVersionRange = VersionRange.createFromVersionSpec(
198938
- evaluate(foundManagedDep.version.text, pom)
198939
- );
198940
- const patchLocation = findPatchLocation(
198941
- foundManagedDep.pom.validatedPomFile,
198942
- foundManagedDep.version,
198943
- pom,
198944
- profileId
198945
- );
198946
- if (patchLocation?.offset !== void 0) {
198947
- patches.push({
198948
- success: true,
198949
- upgrades: [upgrade],
198950
- patch: {
198951
- file: patchLocation.file,
198952
- offset: patchLocation.offset,
198953
- oldText: patchLocation.text,
198954
- newText: (
198955
- // Use pinned version if rangeStyle is set or if we break existing spec!
198956
- rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
198957
- )
198958
- }
198959
- });
198960
- } else {
198961
- patches.push({
198962
- success: false,
198963
- upgrades: [upgrade],
198964
- reason: "Failed to create patch for direct managed dependency"
198965
- });
198966
- }
198871
+ for (const [profileId, profile] of pom.profiles) {
198872
+ const foundDep = profile.dependencies.reverse().find((dep) => {
198873
+ return groupId === evaluate(dep.groupId.text, pom, profileId) && artifactId === evaluate(dep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(dep.type?.text ?? "jar", pom, profileId) && classifier === (dep.classifier && evaluate(dep.classifier.text, pom, profileId));
198874
+ });
198875
+ if (foundDep?.version) {
198876
+ const existingVersionRange = VersionRange.createFromVersionSpec(evaluate(foundDep.version.text, pom));
198877
+ const patchLocation = findPatchLocation(foundDep.pom.validatedPomFile, foundDep.version, pom, profileId);
198878
+ if (patchLocation?.offset !== void 0) {
198879
+ patches.push({
198880
+ success: true,
198881
+ upgrades: [upgrade],
198882
+ patch: {
198883
+ file: patchLocation.file,
198884
+ offset: patchLocation.offset,
198885
+ oldText: patchLocation.text,
198886
+ newText: (
198887
+ // Use pinned version if rangeStyle is set or if we break existing spec!
198888
+ rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
198889
+ )
198967
198890
  }
198968
- }
198891
+ });
198892
+ } else {
198893
+ patches.push({
198894
+ success: false,
198895
+ upgrades: [upgrade],
198896
+ reason: "Failed to create patch for direct dependency"
198897
+ });
198969
198898
  }
198970
- }
198971
- } else {
198972
- for (const [profileId, profile] of pom.profiles) {
198973
- const foundManagedDep = profile.managedDependencies.reverse().find((dep) => {
198899
+ } else {
198900
+ const foundManagedDep = profile.managedDependencies.reverse().concat(pom.profiles.get(void 0)?.managedDependencies.reverse() ?? []).find((dep) => {
198974
198901
  return groupId === evaluate(dep.groupId.text, pom, profileId) && artifactId === evaluate(dep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(dep.type?.text ?? "jar", pom, profileId) && classifier === (dep.classifier && evaluate(dep.classifier.text, pom, profileId));
198975
198902
  });
198976
198903
  if (foundManagedDep) {
@@ -198999,7 +198926,7 @@ var MavenSocketUpgradeManager = class {
198999
198926
  patches.push({
199000
198927
  success: false,
199001
198928
  upgrades: [upgrade],
199002
- reason: "Failed to create patch for transitive managed dependency"
198929
+ reason: "Failed to create patch for direct managed dependency"
199003
198930
  });
199004
198931
  }
199005
198932
  }
@@ -199010,7 +198937,7 @@ var MavenSocketUpgradeManager = class {
199010
198937
  /**
199011
198938
  * Handle gradle.lockfile manifest files
199012
198939
  */
199013
- async handleGradleLockfile(lockFile, upgrade, artifact, _kind) {
198940
+ async handleGradleLockfile(lockFile, upgrade, artifact) {
199014
198941
  assert3(artifact.namespace);
199015
198942
  assert3(artifact.name);
199016
198943
  assert3(artifact.version);
@@ -199042,56 +198969,26 @@ var MavenSocketUpgradeManager = class {
199042
198969
  */
199043
198970
  async collectFallbackPatches(upgrades, artifacts, rangeStyle, validateFile) {
199044
198971
  const patches = [];
199045
- const directUpgradesByManifestFile = {};
199046
- const ancestorUpgradesByManifestFile = {};
198972
+ const upgradesByManifestFile = {};
199047
198973
  for (const upgrade of upgrades) {
199048
198974
  const artifact = artifacts[upgrade.idx];
199049
- const directManifestFiles = i(artifact.manifestFiles?.map((ref) => ref.file) ?? []);
199050
- for (const manifestFile of directManifestFiles) {
199051
- (directUpgradesByManifestFile[manifestFile] ??= []).push({ upgrade, artifact });
199052
- }
199053
- const ancestorManifestFiles = i(
199054
- artifact.toplevelAncestors?.flatMap(
199055
- (ancestorId) => artifacts.find((a5) => a5.id === ancestorId)?.manifestFiles?.map((ref) => ref.file) ?? []
199056
- ) ?? []
198975
+ const manifestFilesForArtifact = i(
198976
+ (artifact.manifestFiles?.map((ref) => ref.file) ?? []).concat(
198977
+ artifact.toplevelAncestors?.flatMap(
198978
+ (ancestorId) => artifacts.find((a5) => a5.id === ancestorId)?.manifestFiles?.map((m3) => m3.file) ?? []
198979
+ ) ?? []
198980
+ )
199057
198981
  );
199058
- for (const manifestFile of ancestorManifestFiles) {
199059
- (ancestorUpgradesByManifestFile[manifestFile] ??= []).push({ upgrade, artifact });
198982
+ for (const manifestFile of manifestFilesForArtifact) {
198983
+ (upgradesByManifestFile[manifestFile] ??= []).push({ upgrade, artifact });
199060
198984
  }
199061
198985
  }
199062
- for (const [manifestFile, upgradeArtifactPairs] of Object.entries(directUpgradesByManifestFile)) {
198986
+ for (const [manifestFile, upgradeArtifactPairs] of Object.entries(upgradesByManifestFile)) {
199063
198987
  const fileName3 = basename(manifestFile);
199064
198988
  if (this.pomMatcher(fileName3)) {
199065
198989
  const project = await loadPom(this.rootDir, manifestFile, validateFile);
199066
198990
  if (project) {
199067
- patches.push(...await this.handlePomFallback(project, upgradeArtifactPairs, rangeStyle, "DIRECT"));
199068
- } else {
199069
- patches.push({
199070
- success: false,
199071
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199072
- reason: `Manifest file not valid for updates: ${manifestFile}`
199073
- });
199074
- }
199075
- } else if (this.gradleLockfileMatcher(fileName3)) {
199076
- patches.push({
199077
- success: false,
199078
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199079
- reason: `Should have upgraded dependencies in grade lockfiles during first pass: ${manifestFile}`
199080
- });
199081
- } else {
199082
- patches.push({
199083
- success: false,
199084
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199085
- reason: `File does not match supported patterns: ${manifestFile}`
199086
- });
199087
- }
199088
- }
199089
- for (const [manifestFile, upgradeArtifactPairs] of Object.entries(ancestorUpgradesByManifestFile)) {
199090
- const fileName3 = basename(manifestFile);
199091
- if (this.pomMatcher(fileName3)) {
199092
- const project = await loadPom(this.rootDir, manifestFile, validateFile);
199093
- if (project) {
199094
- patches.push(...await this.handlePomFallback(project, upgradeArtifactPairs, rangeStyle, "ANCESTOR"));
198991
+ patches.push(...await this.handlePomFallback(project, upgradeArtifactPairs, rangeStyle));
199095
198992
  } else {
199096
198993
  patches.push({
199097
198994
  success: false,
@@ -199118,7 +199015,7 @@ var MavenSocketUpgradeManager = class {
199118
199015
  /**
199119
199016
  * Handle POM files for adding new managed dependencies
199120
199017
  */
199121
- async handlePomFallback(pom, upgradeArtifactPairs, rangeStyle, kind) {
199018
+ async handlePomFallback(pom, upgradeArtifactPairs, rangeStyle) {
199122
199019
  const patches = [];
199123
199020
  const dependencies = upgradeArtifactPairs.map(({ upgrade, artifact }) => {
199124
199021
  assert3(artifact.namespace);
@@ -199136,36 +199033,19 @@ var MavenSocketUpgradeManager = class {
199136
199033
  classifier: artifact.qualifiers?.classifier
199137
199034
  };
199138
199035
  });
199139
- if (kind === "DIRECT") {
199140
- const patch = createDependenciesPatch(pom, dependencies);
199141
- if (patch) {
199142
- patches.push({
199143
- success: true,
199144
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199145
- patch
199146
- });
199147
- } else {
199148
- patches.push({
199149
- success: false,
199150
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199151
- reason: `Could not create dependency batch patch in ${relative4(pom.rootDir, pom.validatedPomFile)}`
199152
- });
199153
- }
199036
+ const patch = createDependenciesPatch(pom, dependencies);
199037
+ if (patch) {
199038
+ patches.push({
199039
+ success: true,
199040
+ upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199041
+ patch
199042
+ });
199154
199043
  } else {
199155
- const patch = createManagedDependenciesPatch(pom, dependencies);
199156
- if (patch) {
199157
- patches.push({
199158
- success: true,
199159
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199160
- patch
199161
- });
199162
- } else {
199163
- patches.push({
199164
- success: false,
199165
- upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199166
- reason: `Could not create managed dependency batch patch in ${relative4(pom.rootDir, pom.validatedPomFile)}`
199167
- });
199168
- }
199044
+ patches.push({
199045
+ success: false,
199046
+ upgrades: upgradeArtifactPairs.map(({ upgrade }) => upgrade),
199047
+ reason: `Could not create dependency batch patch in ${relative4(pom.rootDir, pom.validatedPomFile)}`
199048
+ });
199169
199049
  }
199170
199050
  return patches;
199171
199051
  }
@@ -207283,17 +207163,26 @@ var CargoFixingManager = class {
207283
207163
 
207284
207164
  // ../fixing-management/src/fixing-management/nuget/nuget-socket-upgrade-manager.ts
207285
207165
  var import_picomatch2 = __toESM(require_picomatch2(), 1);
207286
- import { basename as basename4, relative as relative10, resolve as resolve18 } from "node:path";
207166
+ import { basename as basename5, relative as relative10, resolve as resolve18 } from "node:path";
207287
207167
 
207288
207168
  // ../fixing-management/src/fixing-management/nuget/nuget-project-utils.ts
207289
207169
  var import_parse_xml3 = __toESM(require_dist(), 1);
207290
207170
  import { readFile as readFile17 } from "node:fs/promises";
207291
- import { dirname as dirname8, join as join12, relative as relative9, resolve as resolve17 } from "node:path";
207171
+ import { dirname as dirname8, join as join12, relative as relative9, resolve as resolve17, basename as basename4, extname } from "node:path";
207292
207172
  import { existsSync as existsSync11 } from "node:fs";
207293
207173
  function normalizeMSBuildPath(path2) {
207294
207174
  return path2.replace(/\\/g, "/");
207295
207175
  }
207296
- async function loadNuGetProject(rootDir, projectFile, validateFile, visited = new TransformMap((f5) => f5.toLocaleLowerCase())) {
207176
+ async function loadNuGetProject(rootDir, projectFile, validateFile) {
207177
+ return loadNuGetProjectOrTarget(
207178
+ rootDir,
207179
+ projectFile,
207180
+ void 0,
207181
+ new TransformMap((p3) => p3.toLocaleLowerCase()),
207182
+ validateFile
207183
+ );
207184
+ }
207185
+ async function loadNuGetProjectOrTarget(rootDir, projectFile, mainProject, visited, validateFile) {
207297
207186
  const validatedProjectPath = validateFile(resolve17(rootDir, projectFile));
207298
207187
  if (!validatedProjectPath || !existsSync11(validatedProjectPath)) return void 0;
207299
207188
  if (visited.has(validatedProjectPath)) return void 0;
@@ -207301,7 +207190,7 @@ async function loadNuGetProject(rootDir, projectFile, validateFile, visited = ne
207301
207190
  const sourceText = await readFile17(validatedProjectPath, "utf-8");
207302
207191
  const xml2 = (0, import_parse_xml3.parseXml)(sourceText, { includeOffsets: true });
207303
207192
  const indentation = inferIndentationFromParsedXml2(xml2, sourceText);
207304
- const project = {
207193
+ const currentProject = {
207305
207194
  rootDir,
207306
207195
  validatedProjectPath,
207307
207196
  xml: xml2,
@@ -207309,34 +207198,44 @@ async function loadNuGetProject(rootDir, projectFile, validateFile, visited = ne
207309
207198
  sourceText,
207310
207199
  packageReferences: [],
207311
207200
  packageVersions: [],
207312
- properties: new TransformMap((p3) => p3.toLocaleLowerCase()),
207313
- visited
207201
+ properties: new TransformMap((p3) => p3.toLocaleLowerCase())
207314
207202
  };
207315
- for (const directoryBuildPropsProject of await findDirectoryBuildPropsProjects(project, validateFile)) {
207203
+ mainProject ??= currentProject;
207204
+ for (const directoryBuildPropsProject of await findDirectoryBuildPropsProjects(
207205
+ currentProject,
207206
+ mainProject,
207207
+ visited,
207208
+ validateFile
207209
+ )) {
207316
207210
  for (const pkgRef of directoryBuildPropsProject.packageReferences) {
207317
- project.packageReferences.push(pkgRef);
207211
+ currentProject.packageReferences.push(pkgRef);
207318
207212
  }
207319
207213
  for (const pkgVer of directoryBuildPropsProject.packageVersions) {
207320
- project.packageVersions.push(pkgVer);
207214
+ currentProject.packageVersions.push(pkgVer);
207321
207215
  }
207322
207216
  for (const [name, property] of directoryBuildPropsProject.properties) {
207323
- project.properties.set(name, property);
207217
+ currentProject.properties.set(name, property);
207324
207218
  }
207325
207219
  }
207326
- const directoryPackagesPropsProject = await findDirectoryPackagesPropsProjects(project, validateFile);
207220
+ const directoryPackagesPropsProject = await findDirectoryPackagesPropsProject(
207221
+ currentProject,
207222
+ mainProject,
207223
+ visited,
207224
+ validateFile
207225
+ );
207327
207226
  if (directoryPackagesPropsProject) {
207328
207227
  for (const pkgRef of directoryPackagesPropsProject.packageReferences) {
207329
- project.packageReferences.push(pkgRef);
207228
+ currentProject.packageReferences.push(pkgRef);
207330
207229
  }
207331
207230
  for (const pkgVer of directoryPackagesPropsProject.packageVersions) {
207332
- project.packageVersions.push(pkgVer);
207231
+ currentProject.packageVersions.push(pkgVer);
207333
207232
  }
207334
207233
  for (const [name, property] of directoryPackagesPropsProject.properties) {
207335
- project.properties.set(name, property);
207234
+ currentProject.properties.set(name, property);
207336
207235
  }
207337
207236
  }
207338
- await extractProjectElements(project, validateFile);
207339
- return project;
207237
+ await extractProjectElements(currentProject, mainProject, visited, validateFile);
207238
+ return currentProject;
207340
207239
  }
207341
207240
  async function loadPackagesConfig(rootDir, file, validateFile) {
207342
207241
  const validatedConfigPath = validateFile(resolve17(rootDir, file));
@@ -207378,18 +207277,19 @@ function extractPackagesFromXml(xmlDoc, fileContent) {
207378
207277
  }
207379
207278
  return packages;
207380
207279
  }
207381
- async function findDirectoryBuildPropsProjects(project, validateFile) {
207280
+ async function findDirectoryBuildPropsProjects(currentProject, mainProject, visited, validateFile) {
207382
207281
  const projectsReverse = [];
207383
- let currentDir = dirname8(project.validatedProjectPath);
207384
- while (currentDir.startsWith(project.rootDir) && currentDir !== dirname8(currentDir)) {
207282
+ let currentDir = dirname8(currentProject.validatedProjectPath);
207283
+ while (currentDir.startsWith(currentProject.rootDir) && currentDir !== dirname8(currentDir)) {
207385
207284
  const unvalidatedPath = join12(currentDir, "Directory.Build.props");
207386
207285
  const validatedPath = validateFile(unvalidatedPath);
207387
- if (validatedPath && validatedPath !== project.validatedProjectPath) {
207388
- const directoryBuildPropsProject = await loadNuGetProject(
207389
- project.rootDir,
207286
+ if (validatedPath && validatedPath !== currentProject.validatedProjectPath) {
207287
+ const directoryBuildPropsProject = await loadNuGetProjectOrTarget(
207288
+ currentProject.rootDir,
207390
207289
  unvalidatedPath,
207391
- validateFile,
207392
- project.visited
207290
+ mainProject,
207291
+ visited,
207292
+ validateFile
207393
207293
  );
207394
207294
  if (directoryBuildPropsProject) {
207395
207295
  projectsReverse.push(directoryBuildPropsProject);
@@ -207399,53 +207299,93 @@ async function findDirectoryBuildPropsProjects(project, validateFile) {
207399
207299
  }
207400
207300
  return projectsReverse.reverse();
207401
207301
  }
207402
- async function findDirectoryPackagesPropsProjects(project, validateFile) {
207403
- let currentDir = dirname8(project.validatedProjectPath);
207404
- while (currentDir.startsWith(project.rootDir) && currentDir !== dirname8(currentDir)) {
207302
+ async function findDirectoryPackagesPropsProject(currentProject, mainProject, visited, validateFile) {
207303
+ let currentDir = dirname8(currentProject.validatedProjectPath);
207304
+ while (currentDir.startsWith(currentProject.rootDir) && currentDir !== dirname8(currentDir)) {
207405
207305
  const unvalidatedPath = join12(currentDir, "Directory.Packages.props");
207406
207306
  const validatedPath = validateFile(unvalidatedPath);
207407
207307
  if (validatedPath) {
207408
- return validatedPath !== project.validatedProjectPath ? await loadNuGetProject(project.rootDir, unvalidatedPath, validateFile, project.visited) : void 0;
207308
+ return validatedPath !== currentProject.validatedProjectPath ? await loadNuGetProjectOrTarget(currentProject.rootDir, unvalidatedPath, mainProject, visited, validateFile) : void 0;
207409
207309
  }
207410
207310
  currentDir = dirname8(currentDir);
207411
207311
  }
207412
207312
  return void 0;
207413
207313
  }
207414
- async function extractProjectElements(project, validateFile) {
207415
- const projectElement = project.xml.children.filter((child) => child instanceof import_parse_xml3.XmlElement).find((child) => child.name === "Project");
207314
+ function addReservedMSBuildProperties(currentProject, mainProject) {
207315
+ const reservedProperties = [
207316
+ // MSBuildProject* properties - always reference the main project file
207317
+ ["MSBuildProjectDirectory", normalizeMSBuildPath(dirname8(mainProject.validatedProjectPath))],
207318
+ [
207319
+ "MSBuildProjectDirectoryNoRoot",
207320
+ normalizeMSBuildPath(dirname8(mainProject.validatedProjectPath)).replace(/^[A-Za-z]:/, "")
207321
+ ],
207322
+ ["MSBuildProjectExtension", extname(mainProject.validatedProjectPath)],
207323
+ ["MSBuildProjectFile", basename4(mainProject.validatedProjectPath)],
207324
+ ["MSBuildProjectFullPath", normalizeMSBuildPath(mainProject.validatedProjectPath)],
207325
+ ["MSBuildProjectName", basename4(mainProject.validatedProjectPath, extname(mainProject.validatedProjectPath))],
207326
+ // MSBuildThisFile* properties - reference the current project being processed
207327
+ ["MSBuildThisFile", basename4(currentProject.validatedProjectPath)],
207328
+ ["MSBuildThisFileDirectory", normalizeMSBuildPath(dirname8(currentProject.validatedProjectPath)) + "/"],
207329
+ [
207330
+ "MSBuildThisFileDirectoryNoRoot",
207331
+ (normalizeMSBuildPath(dirname8(currentProject.validatedProjectPath)) + "/").replace(/^[A-Za-z]:/, "")
207332
+ ],
207333
+ ["MSBuildThisFileExtension", extname(currentProject.validatedProjectPath)],
207334
+ ["MSBuildThisFileFullPath", normalizeMSBuildPath(currentProject.validatedProjectPath)],
207335
+ [
207336
+ "MSBuildThisFileName",
207337
+ basename4(currentProject.validatedProjectPath, extname(currentProject.validatedProjectPath))
207338
+ ]
207339
+ ];
207340
+ for (const [propertyName, propertyValue] of reservedProperties) {
207341
+ currentProject.properties.set(propertyName, {
207342
+ project: currentProject,
207343
+ text: propertyValue
207344
+ });
207345
+ }
207346
+ }
207347
+ async function extractProjectElements(currentProject, mainProject, visited, validateFile) {
207348
+ const projectElement = currentProject.xml.children.filter((child) => child instanceof import_parse_xml3.XmlElement).find((child) => child.name === "Project");
207416
207349
  if (!projectElement) return;
207350
+ addReservedMSBuildProperties(currentProject, mainProject);
207417
207351
  for (const element of projectElement.children.filter((child) => child instanceof import_parse_xml3.XmlElement)) {
207418
207352
  switch (element.name) {
207419
207353
  case "Import":
207420
- await handleImportElement(project, element, validateFile);
207354
+ await handleImportElement(currentProject, element, mainProject, visited, validateFile);
207421
207355
  break;
207422
207356
  case "ItemGroup":
207423
- handleItemGroupElement(project, element);
207357
+ handleItemGroupElement(currentProject, element);
207424
207358
  break;
207425
207359
  case "PropertyGroup":
207426
- handlePropertyGroupElement(project, element);
207360
+ handlePropertyGroupElement(currentProject, element);
207427
207361
  break;
207428
207362
  }
207429
207363
  }
207430
207364
  }
207431
- async function handleImportElement(project, importElement, validateFile) {
207432
- const projectValue = extractTextAndOffsetFromElementOrAttribute(project.sourceText, importElement, "Project");
207365
+ async function handleImportElement(currentProject, importElement, mainProject, visited, validateFile) {
207366
+ const projectValue = extractTextAndOffsetFromElementOrAttribute(currentProject.sourceText, importElement, "Project");
207433
207367
  if (!projectValue) return;
207434
- const importPath = evaluate2(projectValue.text, project);
207368
+ const importPath = evaluate2(projectValue.text, currentProject);
207435
207369
  if (!importPath) return;
207436
- const resolvedPath = resolve17(dirname8(project.validatedProjectPath), normalizeMSBuildPath(importPath));
207370
+ const resolvedPath = resolve17(dirname8(currentProject.validatedProjectPath), normalizeMSBuildPath(importPath));
207437
207371
  const validatedPath = validateFile(resolvedPath);
207438
207372
  if (!validatedPath || !existsSync11(validatedPath)) return;
207439
- const importedProject = await loadNuGetProject(project.rootDir, resolvedPath, validateFile, project.visited);
207373
+ const importedProject = await loadNuGetProjectOrTarget(
207374
+ currentProject.rootDir,
207375
+ resolvedPath,
207376
+ mainProject,
207377
+ visited,
207378
+ validateFile
207379
+ );
207440
207380
  if (!importedProject) return;
207441
207381
  for (const pkgRef of importedProject.packageReferences) {
207442
- project.packageReferences.push(pkgRef);
207382
+ currentProject.packageReferences.push(pkgRef);
207443
207383
  }
207444
207384
  for (const pkgVer of importedProject.packageVersions) {
207445
- project.packageVersions.push(pkgVer);
207385
+ currentProject.packageVersions.push(pkgVer);
207446
207386
  }
207447
207387
  for (const [name, property] of importedProject.properties) {
207448
- project.properties.set(name, property);
207388
+ currentProject.properties.set(name, property);
207449
207389
  }
207450
207390
  }
207451
207391
  function handleItemGroupElement(project, parent2) {
@@ -207504,14 +207444,11 @@ function handlePropertyGroupElement(project, propertyGroup) {
207504
207444
  const propertyName = propertyElement.name;
207505
207445
  const propertyValue = propertyElement.text;
207506
207446
  if (propertyValue) {
207507
- const openTagEnd = project.sourceText.indexOf(">", propertyElement.start) + 1;
207508
- const closeTagStart = project.sourceText.lastIndexOf("<", propertyElement.end);
207509
- const textRange = [openTagEnd, closeTagStart];
207510
207447
  project.properties.set(propertyName, {
207511
207448
  project,
207512
207449
  parent: propertyGroup,
207513
207450
  text: propertyValue,
207514
- offset: textRange?.[0]
207451
+ offset: propertyElement.start + 2 + propertyName.length
207515
207452
  });
207516
207453
  }
207517
207454
  }
@@ -207548,34 +207485,18 @@ function findPatchLocation2(file, textAndOffset, project) {
207548
207485
  }
207549
207486
  return chase(file, textAndOffset.text, textAndOffset.offset, 0);
207550
207487
  }
207551
- function findAncestorPackageReferenceContexts(project, ancestors) {
207552
- const contexts = [];
207553
- for (const ancestor of ancestors) {
207554
- const ancestorPackageReferences = project.packageReferences.filter(
207488
+ function findAncestorPackageReferenceDeclarations(project, ancestors) {
207489
+ return ancestors.flatMap(
207490
+ (ancestor) => project.packageReferences.filter(
207555
207491
  (pkg) => evaluate2(pkg.name.text, project).toLowerCase() === ancestor.name.toLowerCase() && ancestor.version !== void 0 && (pkg.version === void 0 || versionSatisfiesSpecifier("NUGET", ancestor.version, evaluate2(pkg.version.text, project)))
207556
- );
207557
- for (const ancestorPackageReference of ancestorPackageReferences) {
207558
- contexts.push(i3(ancestorPackageReference, ["project", "parent", "condition"]));
207559
- }
207560
- }
207561
- return m(
207562
- contexts,
207563
- (a5, b) => a5.project.validatedProjectPath.toLocaleLowerCase() === b.project.validatedProjectPath.toLocaleLowerCase() && a5.parent === b.parent && a5.condition?.toLocaleLowerCase() === b.condition?.toLocaleLowerCase()
207492
+ )
207564
207493
  );
207565
207494
  }
207566
- function findAncestorPackageVersionContexts(project, ancestors) {
207567
- const contexts = [];
207568
- for (const ancestor of ancestors) {
207569
- const ancestorPackageVersions = project.packageVersions.filter(
207495
+ function findAncestorPackageVersionDeclarations(project, ancestors) {
207496
+ return ancestors.flatMap(
207497
+ (ancestor) => project.packageVersions.filter(
207570
207498
  (pkg) => ancestor.version !== void 0 && evaluate2(pkg.name.text, project).toLowerCase() === ancestor.name.toLowerCase() && versionSatisfiesSpecifier("NUGET", ancestor.version, evaluate2(pkg.version.text, project))
207571
- );
207572
- for (const ancestorPackageVersion of ancestorPackageVersions) {
207573
- contexts.push(i3(ancestorPackageVersion, ["project", "parent", "condition"]));
207574
- }
207575
- }
207576
- return m(
207577
- contexts,
207578
- (a5, b) => a5.project.validatedProjectPath.toLocaleLowerCase() === b.project.validatedProjectPath.toLocaleLowerCase() && a5.parent === b.parent && a5.condition?.toLocaleLowerCase() === b.condition?.toLocaleLowerCase()
207499
+ )
207579
207500
  );
207580
207501
  }
207581
207502
  function evaluate2(expression, project) {
@@ -207593,7 +207514,7 @@ function evaluate2(expression, project) {
207593
207514
  if (property) {
207594
207515
  return evaluateWithContext(property.text, depth + 1);
207595
207516
  } else {
207596
- logger.warn(
207517
+ logger.debug(
207597
207518
  `Unknown property ${propertyName} for project ${relative9(project.rootDir, project.validatedProjectPath)}`
207598
207519
  );
207599
207520
  return match2;
@@ -207663,7 +207584,7 @@ var NuGetSocketUpgradeManager = class {
207663
207584
  lockFileMatcher = (0, import_picomatch2.default)("packages.lock.json");
207664
207585
  truthyValues = ["true", "yes", "on"];
207665
207586
  async applySocketArtifactUpgrades(manifestFiles, upgrades, artifacts, rangeStyle) {
207666
- if (manifestFiles.find((f5) => this.lockFileMatcher(basename4(f5)))) {
207587
+ if (manifestFiles.find((f5) => this.lockFileMatcher(basename5(f5)))) {
207667
207588
  throw Error(`Upgrading dependencies currently not supporte for NuGet projets with lockfiles`);
207668
207589
  }
207669
207590
  const caseInsensitiveManifestFileMap = new TransformMap((key) => key.toLowerCase());
@@ -207699,7 +207620,7 @@ var NuGetSocketUpgradeManager = class {
207699
207620
  async collectPreparePatches(manifestFiles, validateFile) {
207700
207621
  const patches = [];
207701
207622
  for (const manifestFile of manifestFiles) {
207702
- if (this.projectMatcher(basename4(manifestFile))) {
207623
+ if (this.projectMatcher(basename5(manifestFile))) {
207703
207624
  const project = await loadNuGetProject(this.rootDir, manifestFile, validateFile);
207704
207625
  if (project) {
207705
207626
  for (const patch of await this.handleProjectPrepare(project)) {
@@ -207712,7 +207633,7 @@ var NuGetSocketUpgradeManager = class {
207712
207633
  reason: `Manifest file not valid for updates: ${manifestFile}`
207713
207634
  });
207714
207635
  }
207715
- } else if (this.packagesConfigMatcher(basename4(manifestFile))) {
207636
+ } else if (this.packagesConfigMatcher(basename5(manifestFile))) {
207716
207637
  const packagesConfig = await loadPackagesConfig(this.rootDir, manifestFile, validateFile);
207717
207638
  if (packagesConfig) {
207718
207639
  for (const patch of await this.handlePackagesConfigPrepare(packagesConfig)) {
@@ -207767,12 +207688,12 @@ var NuGetSocketUpgradeManager = class {
207767
207688
  }
207768
207689
  }
207769
207690
  } else {
207770
- const patch = createPropertyPatch(
207691
+ const patch = centralPackageManagementProperty.parent ? createPropertyPatch(
207771
207692
  centralPackageManagementProperty.project,
207772
207693
  centralPackageManagementProperty.parent,
207773
207694
  "CentralPackageTransitivePinningEnabled",
207774
207695
  "true"
207775
- );
207696
+ ) : void 0;
207776
207697
  if (patch) {
207777
207698
  patches.push({
207778
207699
  success: true,
@@ -207793,61 +207714,22 @@ var NuGetSocketUpgradeManager = class {
207793
207714
  const patches = [];
207794
207715
  return patches;
207795
207716
  }
207796
- /**
207797
- * Collect patches for direct dependencies and Directory.Packages.props central management
207798
- * This prioritizes updating existing dependencies and using central package management
207799
- * Handles both direct dependencies (update existing) and transitive dependencies (add to Directory.Packages.props)
207800
- */
207801
207717
  async collectUpdatePatches(upgrades, artifacts, rangeStyle, validateFile) {
207802
207718
  const patches = [];
207803
207719
  for (const upgrade of upgrades) {
207804
207720
  const artifact = artifacts[upgrade.idx];
207805
- const directManifestFiles = i(artifact.manifestFiles?.map((ref) => ref.file) ?? []);
207806
- for (const manifestFile of directManifestFiles) {
207807
- if (this.projectMatcher(basename4(manifestFile))) {
207808
- const project = await loadNuGetProject(this.rootDir, manifestFile, validateFile);
207809
- if (project) {
207810
- for (const patch of await this.handleProject(project, upgrade, artifact, rangeStyle, "DIRECT")) {
207811
- patches.push(patch);
207812
- }
207813
- } else {
207814
- patches.push({
207815
- success: false,
207816
- upgrades: [upgrade],
207817
- reason: `Manifest file not valid for updates: ${manifestFile}`
207818
- });
207819
- }
207820
- } else if (this.packagesConfigMatcher(basename4(manifestFile))) {
207821
- const packagesConfig = await loadPackagesConfig(this.rootDir, manifestFile, validateFile);
207822
- if (packagesConfig) {
207823
- for (const patch of await this.handlePackagesConfig(packagesConfig, upgrade, artifact, "DIRECT")) {
207824
- patches.push(patch);
207825
- }
207826
- } else {
207827
- patches.push({
207828
- success: false,
207829
- upgrades: [upgrade],
207830
- reason: `Manifest file not valid for updates: ${manifestFile}`
207831
- });
207832
- }
207833
- } else {
207834
- patches.push({
207835
- success: false,
207836
- upgrades: [upgrade],
207837
- reason: `File does not match supported patterns: ${manifestFile}`
207838
- });
207839
- }
207840
- }
207841
- const ancestorManifestFiles = i(
207842
- artifact.toplevelAncestors?.flatMap(
207843
- (ancestorId) => artifacts.find((a5) => a5.id === ancestorId)?.manifestFiles?.map((m3) => m3.file) ?? []
207844
- ) ?? []
207721
+ const manifestFilesForArtifact = i(
207722
+ (artifact.manifestFiles?.map((ref) => ref.file) ?? []).concat(
207723
+ artifact.toplevelAncestors?.flatMap(
207724
+ (ancestorId) => artifacts.find((a5) => a5.id === ancestorId)?.manifestFiles?.map((m3) => m3.file) ?? []
207725
+ ) ?? []
207726
+ )
207845
207727
  );
207846
- for (const manifestFile of ancestorManifestFiles) {
207847
- if (this.projectMatcher(basename4(manifestFile))) {
207728
+ for (const manifestFile of manifestFilesForArtifact) {
207729
+ if (this.projectMatcher(basename5(manifestFile))) {
207848
207730
  const project = await loadNuGetProject(this.rootDir, manifestFile, validateFile);
207849
207731
  if (project) {
207850
- for (const patch of await this.handleProject(project, upgrade, artifact, rangeStyle, "ANCESTOR")) {
207732
+ for (const patch of await this.handleProject(project, upgrade, artifact, rangeStyle)) {
207851
207733
  patches.push(patch);
207852
207734
  }
207853
207735
  } else {
@@ -207857,10 +207739,10 @@ var NuGetSocketUpgradeManager = class {
207857
207739
  reason: `Manifest file not valid for updates: ${manifestFile}`
207858
207740
  });
207859
207741
  }
207860
- } else if (this.packagesConfigMatcher(basename4(manifestFile))) {
207742
+ } else if (this.packagesConfigMatcher(basename5(manifestFile))) {
207861
207743
  const packagesConfig = await loadPackagesConfig(this.rootDir, manifestFile, validateFile);
207862
207744
  if (packagesConfig) {
207863
- for (const patch of await this.handlePackagesConfig(packagesConfig, upgrade, artifact, "ANCESTOR")) {
207745
+ for (const patch of await this.handlePackagesConfig(packagesConfig, upgrade, artifact)) {
207864
207746
  patches.push(patch);
207865
207747
  }
207866
207748
  } else {
@@ -207881,7 +207763,7 @@ var NuGetSocketUpgradeManager = class {
207881
207763
  }
207882
207764
  return patches;
207883
207765
  }
207884
- async handleProject(project, upgrade, artifact, rangeStyle, kind) {
207766
+ async handleProject(project, upgrade, artifact, rangeStyle) {
207885
207767
  const patches = [];
207886
207768
  assert5(artifact.name);
207887
207769
  assert5(artifact.version);
@@ -207978,18 +207860,10 @@ var NuGetSocketUpgradeManager = class {
207978
207860
  }
207979
207861
  });
207980
207862
  }
207981
- if (kind === "DIRECT" && patches.length === 0) {
207982
- patches.push({
207983
- success: false,
207984
- upgrades: [upgrade],
207985
- reason: "Could not find patchable version location for direct dependency"
207986
- });
207987
- }
207988
207863
  return patches;
207989
207864
  }
207990
- async handlePackagesConfig(packagesConfig, upgrade, artifact, kind) {
207865
+ async handlePackagesConfig(packagesConfig, upgrade, artifact) {
207991
207866
  const patches = [];
207992
- if (kind === "ANCESTOR") return patches;
207993
207867
  assert5(artifact.name);
207994
207868
  assert5(artifact.version);
207995
207869
  const packageName = artifact.name;
@@ -208016,22 +207890,8 @@ var NuGetSocketUpgradeManager = class {
208016
207890
  });
208017
207891
  }
208018
207892
  });
208019
- if (patches.length === 0) {
208020
- patches.push({
208021
- success: false,
208022
- upgrades: [upgrade],
208023
- reason: `Could not find patchable version location for packages.config file ${relative10(packagesConfig.rootDir, packagesConfig.validatedConfigPath)}`
208024
- });
208025
- }
208026
207893
  return patches;
208027
207894
  }
208028
- /**
208029
- * Collect fallback patches for remaining upgrades
208030
- * This handles:
208031
- * 1. Creating new PackageVersion entries in Directory.Packages.props for transitive dependencies
208032
- * 2. Promoting remaining transitive dependencies to direct dependencies as a last resort
208033
- * Groups multiple upgrades per manifest file for efficiency
208034
- */
208035
207895
  async collectFallbackPatches(upgrades, artifacts, rangeStyle, validateFile) {
208036
207896
  const patches = [];
208037
207897
  for (const upgrade of upgrades) {
@@ -208039,7 +207899,7 @@ var NuGetSocketUpgradeManager = class {
208039
207899
  const ancestors = (artifact.toplevelAncestors ?? []).map((ancestorId) => artifacts.find((a5) => a5.id === ancestorId)).filter((a5) => a5 !== void 0);
208040
207900
  const ancestorManifestFiles = i(ancestors.flatMap((a5) => a5.manifestFiles?.map((m3) => m3.file) ?? []) ?? []);
208041
207901
  for (const manifestFile of ancestorManifestFiles) {
208042
- if (this.projectMatcher(basename4(manifestFile))) {
207902
+ if (this.projectMatcher(basename5(manifestFile))) {
208043
207903
  const project = await loadNuGetProject(this.rootDir, manifestFile, validateFile);
208044
207904
  if (project) {
208045
207905
  for (const patch of await this.handleProjectFallback(project, upgrade, artifact, ancestors, rangeStyle)) {
@@ -208052,7 +207912,7 @@ var NuGetSocketUpgradeManager = class {
208052
207912
  reason: `Manifest file not valid for updates: ${manifestFile}`
208053
207913
  });
208054
207914
  }
208055
- } else if (this.packagesConfigMatcher(basename4(manifestFile))) {
207915
+ } else if (this.packagesConfigMatcher(basename5(manifestFile))) {
208056
207916
  const packagesConfig = await loadPackagesConfig(this.rootDir, manifestFile, validateFile);
208057
207917
  if (packagesConfig) {
208058
207918
  for (const patch of await this.handlePackagesConfigFallback(packagesConfig, upgrade, artifact)) {
@@ -208080,16 +207940,19 @@ var NuGetSocketUpgradeManager = class {
208080
207940
  const patches = [];
208081
207941
  const centralPackageManagementProperty = project.properties.get("ManagePackageVersionsCentrally");
208082
207942
  const centralPackageManagementEnabled = centralPackageManagementProperty && this.truthyValues.includes(evaluate2(centralPackageManagementProperty.text, project).toLowerCase());
208083
- const [findAncestorContexts, createPatch] = centralPackageManagementEnabled ? [findAncestorPackageVersionContexts, createPackageVersionPatch] : [findAncestorPackageReferenceContexts, createPackageReferencePatch];
207943
+ const [findAncestorDeclarations, createPatch] = centralPackageManagementEnabled ? [findAncestorPackageVersionDeclarations, createPackageVersionPatch] : [findAncestorPackageReferenceDeclarations, createPackageReferencePatch];
208084
207944
  assert5(artifact.name);
208085
207945
  assert5(artifact.version);
208086
207946
  const nuGetVersion = NuGetVersion.parse(upgrade.upgradeVersion);
208087
207947
  const nuGetRangePinned = new NuGetRange(nuGetVersion, true, nuGetVersion, true);
208088
207948
  const versionSpec = rangeStyle === "pin" ? nuGetRangePinned.toString() : nuGetVersion.toString();
208089
- const ancestorContexts = findAncestorContexts(project, ancestors);
208090
- if (ancestorContexts.length > 0) {
208091
- for (const context2 of ancestorContexts) {
208092
- const patch = createPatch(context2.project, context2.parent, artifact.name, versionSpec, context2.condition);
207949
+ const ancestorDeclarations = m(
207950
+ findAncestorDeclarations(project, ancestors),
207951
+ (a5, b) => a5.project.validatedProjectPath.toLocaleLowerCase() === b.project.validatedProjectPath.toLocaleLowerCase() && a5.parent === b.parent && a5.condition?.toLocaleLowerCase() === b.condition?.toLocaleLowerCase()
207952
+ );
207953
+ if (ancestorDeclarations.length > 0) {
207954
+ for (const decl of ancestorDeclarations) {
207955
+ const patch = createPatch(decl.project, decl.parent, artifact.name, versionSpec, decl.condition);
208093
207956
  if (patch) {
208094
207957
  patches.push({
208095
207958
  success: true,
@@ -208108,7 +207971,7 @@ var NuGetSocketUpgradeManager = class {
208108
207971
  patches.push({
208109
207972
  success: false,
208110
207973
  upgrades: [upgrade],
208111
- reason: `Could not find direct dependencies for transitive dependency in ${relative10(project.rootDir, project.validatedProjectPath)}`
207974
+ reason: `Could not find declaration for top-level ancestor of transitive dependency in ${relative10(project.rootDir, project.validatedProjectPath)}`
208112
207975
  });
208113
207976
  }
208114
207977
  return patches;
@@ -208142,7 +208005,7 @@ var NuGetSocketUpgradeManager = class {
208142
208005
  };
208143
208006
 
208144
208007
  // ../fixing-management/src/fixing-management/rust/cargo-socket-upgrade-manager.ts
208145
- import { basename as basename5, dirname as dirname9, join as join13, resolve as resolve19 } from "node:path";
208008
+ import { basename as basename6, dirname as dirname9, join as join13, resolve as resolve19 } from "node:path";
208146
208009
  var import_toml_eslint_parser2 = __toESM(require_lib10(), 1);
208147
208010
  var import_picomatch3 = __toESM(require_picomatch2(), 1);
208148
208011
  var import_semver3 = __toESM(require_semver2(), 1);
@@ -208161,7 +208024,7 @@ var CargoSocketUpgradeManager = class {
208161
208024
  const successfulPatches = extractSuccessfulPatches(tomlPatches.concat(lockPatches));
208162
208025
  await applySocketPatchResults("RUST", this.rootDir, successfulPatches);
208163
208026
  await asyncForEach(
208164
- i(successfulPatches.map((p3) => p3.patch.file)).filter((file) => this.cargoLockMatcher(basename5(file))),
208027
+ i(successfulPatches.map((p3) => p3.patch.file)).filter((file) => this.cargoLockMatcher(basename6(file))),
208165
208028
  async (lockFile) => {
208166
208029
  const success = await execAndLogOnFailure(cmdt`cargo fetch`, dirname9(resolve19(this.rootDir, lockFile)));
208167
208030
  if (!success) {
@@ -208180,7 +208043,7 @@ var CargoSocketUpgradeManager = class {
208180
208043
  assert6(artifact.version);
208181
208044
  const directManifestFiles = i(artifact.manifestFiles?.map((ref) => ref.file) ?? []);
208182
208045
  return await asyncFlatMap(
208183
- directManifestFiles.filter((manifestFile) => this.cargoTomlMatcher(basename5(manifestFile))),
208046
+ directManifestFiles.filter((manifestFile) => this.cargoTomlMatcher(basename6(manifestFile))),
208184
208047
  async (manifestFile) => this.handleCargoToml(manifestFile, upgrade, artifact, rangeStyle)
208185
208048
  );
208186
208049
  });
@@ -208201,7 +208064,7 @@ var CargoSocketUpgradeManager = class {
208201
208064
  )
208202
208065
  );
208203
208066
  return asyncFlatMap(
208204
- ancestorManifestFiles.filter((manifestFile) => this.cargoTomlMatcher(basename5(manifestFile))).map((tomlFile) => join13(dirname9(tomlFile), "Cargo.lock")).filter((lockFile) => existsSync12(resolve19(this.rootDir, lockFile))),
208067
+ ancestorManifestFiles.filter((manifestFile) => this.cargoTomlMatcher(basename6(manifestFile))).map((tomlFile) => join13(dirname9(tomlFile), "Cargo.lock")).filter((lockFile) => existsSync12(resolve19(this.rootDir, lockFile))),
208205
208068
  async (lockFile) => this.handleCargoLock(lockFile, upgrade, artifact)
208206
208069
  );
208207
208070
  });
@@ -208485,7 +208348,7 @@ var import_lodash5 = __toESM(require_lodash(), 1);
208485
208348
  var import_micromatch = __toESM(require_micromatch(), 1);
208486
208349
  import { existsSync as existsSync13 } from "fs";
208487
208350
  import { access as access2, cp, readdir as readdir3, stat as stat2 } from "fs/promises";
208488
- import { basename as basename6, join as join14, relative as relative11, resolve as resolve20 } from "path";
208351
+ import { basename as basename7, join as join14, relative as relative11, resolve as resolve20 } from "path";
208489
208352
  var { uniq } = import_lodash5.default;
208490
208353
  var { isMatch } = import_micromatch.default;
208491
208354
  function* parents(dir) {
@@ -208498,7 +208361,7 @@ function* parents(dir) {
208498
208361
  }
208499
208362
  function findParent(dir, predicate, wholePath) {
208500
208363
  for (const parent2 of parents(dir))
208501
- if (predicate(wholePath ? parent2 : basename6(parent2)))
208364
+ if (predicate(wholePath ? parent2 : basename7(parent2)))
208502
208365
  return parent2;
208503
208366
  }
208504
208367
 
@@ -209381,7 +209244,7 @@ var import_lodash8 = __toESM(require_lodash(), 1);
209381
209244
  var import_micromatch2 = __toESM(require_micromatch(), 1);
209382
209245
  import { existsSync as existsSync16 } from "fs";
209383
209246
  import { access as access3, cp as cp2, readdir as readdir4, stat as stat3 } from "fs/promises";
209384
- import { basename as basename7, join as join19, relative as relative12, resolve as resolve22 } from "path";
209247
+ import { basename as basename8, join as join19, relative as relative12, resolve as resolve22 } from "path";
209385
209248
  var { uniq: uniq2 } = import_lodash8.default;
209386
209249
  var { isMatch: isMatch2 } = import_micromatch2.default;
209387
209250
  function* parents2(dir) {
@@ -209394,7 +209257,7 @@ function* parents2(dir) {
209394
209257
  }
209395
209258
  function findParent2(dir, predicate, wholePath) {
209396
209259
  for (const parent2 of parents2(dir))
209397
- if (predicate(wholePath ? parent2 : basename7(parent2))) return parent2;
209260
+ if (predicate(wholePath ? parent2 : basename8(parent2))) return parent2;
209398
209261
  }
209399
209262
  async function getFilesRelative(dir, excludeDirs) {
209400
209263
  async function helper(subDir, arrayOfFiles) {
@@ -212120,7 +211983,7 @@ var DEFAULT_REPORT_FILENAME_BASE = "coana-report";
212120
211983
  // dist/internal/exclude-dirs-from-configuration-files.js
212121
211984
  import { existsSync as existsSync20 } from "fs";
212122
211985
  import { readFile as readFile26 } from "fs/promises";
212123
- import { basename as basename8, resolve as resolve29 } from "path";
211986
+ import { basename as basename9, resolve as resolve29 } from "path";
212124
211987
  var import_yaml2 = __toESM(require_dist11(), 1);
212125
211988
  async function inferExcludeDirsFromConfigurationFiles(rootWorkingDir) {
212126
211989
  const socketYmlConfigFile = resolve29(rootWorkingDir, "socket.yml");
@@ -212140,7 +212003,7 @@ async function inferExcludeDirsFromSocketConfig(socketConfigFile) {
212140
212003
  return void 0;
212141
212004
  if (ignorePaths.some((ignorePath) => ignorePath.includes("!")))
212142
212005
  return void 0;
212143
- logger.info(`Inferring paths to exclude based on Socket config file: ${basename8(socketConfigFile)}`);
212006
+ logger.info(`Inferring paths to exclude based on Socket config file: ${basename9(socketConfigFile)}`);
212144
212007
  return config3.projectIgnorePaths;
212145
212008
  } catch (e) {
212146
212009
  return void 0;
@@ -212249,12 +212112,12 @@ function transformToVulnChainNode(dependencyTree) {
212249
212112
  // dist/internal/socket-mode-helpers-socket-dependency-trees.js
212250
212113
  var import_packageurl_js = __toESM(require_packageurl_js(), 1);
212251
212114
  var import_picomatch4 = __toESM(require_picomatch2(), 1);
212252
- import { basename as basename9, dirname as dirname12, join as join25, sep as sep5 } from "path";
212115
+ import { basename as basename10, dirname as dirname12, join as join25, sep as sep5 } from "path";
212253
212116
  var REQUIREMENTS_FILES_SEARCH_DEPTH2 = 3;
212254
212117
  function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonProjects) {
212255
212118
  switch (ecosystem) {
212256
212119
  case "NPM": {
212257
- const base = basename9(manifestPath);
212120
+ const base = basename10(manifestPath);
212258
212121
  const dir = dirname12(manifestPath);
212259
212122
  return base === "package.json" ? dir || "." : void 0;
212260
212123
  }
@@ -212262,7 +212125,7 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
212262
212125
  return ".";
212263
212126
  }
212264
212127
  case "PIP": {
212265
- const base = basename9(manifestPath);
212128
+ const base = basename10(manifestPath);
212266
212129
  const dir = dirname12(manifestPath);
212267
212130
  const workspaceDir = dir === "" ? "." : dir;
212268
212131
  if (properPythonProjects.includes(workspaceDir)) {
@@ -212288,7 +212151,7 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
212288
212151
  return dirname12(manifestPath) || ".";
212289
212152
  }
212290
212153
  case "GO": {
212291
- const base = basename9(manifestPath);
212154
+ const base = basename10(manifestPath);
212292
212155
  const dir = dirname12(manifestPath);
212293
212156
  return base === "go.mod" ? dir || "." : void 0;
212294
212157
  }
@@ -212300,7 +212163,7 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
212300
212163
  function inferProjectFromManifestPath(ecosystem, manifestPath) {
212301
212164
  switch (ecosystem) {
212302
212165
  case "NPM": {
212303
- const filename = basename9(manifestPath);
212166
+ const filename = basename10(manifestPath);
212304
212167
  if (["package-lock.json", "pnpm-lock.yaml", "pnpm-lock.yml", "yarn.lock"].includes(filename)) {
212305
212168
  return dirname12(manifestPath) || ".";
212306
212169
  }
@@ -212366,7 +212229,7 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash,
212366
212229
  ];
212367
212230
  const allFiles = await getFilesRelative(rootWorkingDirectory, venvExcludes);
212368
212231
  for (const file of allFiles) {
212369
- const base = basename9(file);
212232
+ const base = basename10(file);
212370
212233
  const workspaceDir = dirname12(file) || ".";
212371
212234
  if (base === "pyproject.toml" || base === "setup.py" && await isSetupPySetuptools(join25(rootWorkingDirectory, file))) {
212372
212235
  if (!properPythonProjects.includes(workspaceDir)) {
@@ -212390,11 +212253,11 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash,
212390
212253
  const manifestFiles = [];
212391
212254
  switch (ecosystem) {
212392
212255
  case "MAVEN": {
212393
- manifestFiles.push(...(await getFilesRelative(rootWorkingDirectory)).filter((file) => (0, import_picomatch4.default)("{{*-*.,}pom{.xml,},gradle.lockfile}")(basename9(file))));
212256
+ manifestFiles.push(...(await getFilesRelative(rootWorkingDirectory)).filter((file) => (0, import_picomatch4.default)("{{*-*.,}pom{.xml,},gradle.lockfile}")(basename10(file))));
212394
212257
  break;
212395
212258
  }
212396
212259
  case "NUGET": {
212397
- manifestFiles.push(...(await getFilesRelative(rootWorkingDirectory)).filter((file) => (0, import_picomatch4.default)("{*.csproj,packages.lock.json}")(basename9(file))));
212260
+ manifestFiles.push(...(await getFilesRelative(rootWorkingDirectory)).filter((file) => (0, import_picomatch4.default)("{*.csproj,packages.lock.json}")(basename10(file))));
212398
212261
  break;
212399
212262
  }
212400
212263
  case "PIP": {
@@ -227595,7 +227458,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
227595
227458
  }
227596
227459
 
227597
227460
  // dist/version.js
227598
- var version2 = "14.12.28";
227461
+ var version2 = "14.12.29";
227599
227462
 
227600
227463
  // dist/cli-core.js
227601
227464
  var { mapValues, omit, partition, pick } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.12.28",
3
+ "version": "14.12.29",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {