@coana-tech/cli 14.12.105 → 14.12.106

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
@@ -215280,7 +215280,7 @@ function resolveConflicts(ecosystem, patches, ctxt) {
215280
215280
  while (conflict.length > 0) {
215281
215281
  conflict.sort((a4, b) => {
215282
215282
  if (a4.artifacts.length !== b.artifacts.length) {
215283
- return b.artifacts.length - a4.artifacts.length;
215283
+ return a4.artifacts.length - b.artifacts.length;
215284
215284
  }
215285
215285
  const aHighestVersion = getHighestVersionInPatch(ecosystem, a4, ctxt);
215286
215286
  const bHighestVersion = getHighestVersionInPatch(ecosystem, b, ctxt);
@@ -217780,16 +217780,8 @@ function extractManagedDependenciesFromElement(pom, element) {
217780
217780
  (child) => child instanceof import_parse_xml2.XmlElement && child.name === "dependency"
217781
217781
  )) {
217782
217782
  const dependency = extractDependencyFromElement(pom, depChild);
217783
- if (dependency?.version) {
217784
- managedDependencies.push({
217785
- groupId: dependency.groupId,
217786
- artifactId: dependency.artifactId,
217787
- type: dependency.type,
217788
- classifier: dependency.classifier,
217789
- version: dependency.version,
217790
- scope: dependency.scope,
217791
- pom: dependency.pom
217792
- });
217783
+ if (dependency) {
217784
+ managedDependencies.push(dependency);
217793
217785
  }
217794
217786
  }
217795
217787
  return managedDependencies;
@@ -217812,6 +217804,7 @@ function extractDependencyFromElement(pom, depElement) {
217812
217804
  type,
217813
217805
  classifier,
217814
217806
  scope,
217807
+ element: depElement,
217815
217808
  pom
217816
217809
  };
217817
217810
  }
@@ -217940,6 +217933,26 @@ function getDependencyXml(pom, dependency, parentIndentLevel) {
217940
217933
  ${parentIndent}`;
217941
217934
  return dependenciesXml;
217942
217935
  }
217936
+ function getVersionPatch(dep, version4, elementIndentLevel) {
217937
+ if (dep.version) {
217938
+ if (dep.version.offset === void 0) {
217939
+ return void 0;
217940
+ }
217941
+ return {
217942
+ file: dep.pom.validatedPomFile,
217943
+ offset: dep.version.offset,
217944
+ length: dep.version.text.length,
217945
+ text: version4
217946
+ };
217947
+ }
217948
+ const versionXml = `${indent2(1, dep.pom.indentation)}<version>${version4}</version>
217949
+ ${indent2(elementIndentLevel, dep.pom.indentation)}`;
217950
+ return {
217951
+ file: dep.pom.validatedPomFile,
217952
+ offset: getInsertPos(dep.element),
217953
+ text: versionXml
217954
+ };
217955
+ }
217943
217956
  function getManagedDependenciesPatch(pom, dependencies) {
217944
217957
  const projectElement = pom.xml.children.filter((child) => child instanceof import_parse_xml2.XmlElement).find((child) => child.name === "project");
217945
217958
  if (!projectElement) {
@@ -217949,7 +217962,11 @@ function getManagedDependenciesPatch(pom, dependencies) {
217949
217962
  const dependenciesElement = dependencyManagementElement?.children.filter((child) => child instanceof import_parse_xml2.XmlElement).find((child) => child.name === "dependencies");
217950
217963
  const indentL1 = indent2(1, pom.indentation);
217951
217964
  const indentL2 = indent2(2, pom.indentation);
217952
- const depXmls = dependencies.map((dep) => getDependencyXml(pom, dep, 2)).join("");
217965
+ const uniqueDependencies = T2(
217966
+ dependencies,
217967
+ (dep) => `${dep.groupId}:${dep.artifactId}:${dep.type ?? "jar"}:${dep.classifier ?? ""}`
217968
+ );
217969
+ const depXmls = uniqueDependencies.map((dep) => getDependencyXml(pom, dep, 2)).join("");
217953
217970
  if (!dependencyManagementElement) {
217954
217971
  return {
217955
217972
  file: pom.validatedPomFile,
@@ -217984,7 +218001,11 @@ function getDependenicesPatch(pom, dependencies) {
217984
218001
  }
217985
218002
  const dependenciesElement = projectElement.children.filter((child) => child instanceof import_parse_xml2.XmlElement).find((child) => child.name === "dependencies");
217986
218003
  const indentL1 = indent2(1, pom.indentation);
217987
- const depXmls = dependencies.map((dep) => getDependencyXml(pom, dep, 1)).join("");
218004
+ const uniqueDependencies = T2(
218005
+ dependencies,
218006
+ (dep) => `${dep.groupId}:${dep.artifactId}:${dep.type ?? "jar"}:${dep.classifier ?? ""}`
218007
+ );
218008
+ const depXmls = uniqueDependencies.map((dep) => getDependencyXml(pom, dep, 1)).join("");
217988
218009
  if (!dependenciesElement) {
217989
218010
  return {
217990
218011
  file: pom.validatedPomFile,
@@ -218157,7 +218178,8 @@ var MavenFixingManager = class {
218157
218178
  const foundManagedDependencies = [];
218158
218179
  for (const [profileId, profile] of pom.profiles) {
218159
218180
  const profileManagedDependencies = profile.managedDependencies.filter(
218160
- (managedDep) => groupId === evaluate(managedDep.groupId.text, pom, profileId) && artifactId === evaluate(managedDep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(managedDep.type?.text ?? "jar", pom, profileId) && classifier === (managedDep.classifier && evaluate(managedDep.classifier.text, pom, profileId)) && (evaluate(managedDep.version.text, pom, profileId) === void 0 || versionSatisfiesSpecifier("MAVEN", version4, evaluate(managedDep.version.text, pom, profileId)))
218181
+ (managedDep) => groupId === evaluate(managedDep.groupId.text, pom, profileId) && artifactId === evaluate(managedDep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(managedDep.type?.text ?? "jar", pom, profileId) && classifier === (managedDep.classifier && evaluate(managedDep.classifier.text, pom, profileId)) && // Either no version (we'll insert one) or version matches
218182
+ (!managedDep.version || evaluate(managedDep.version.text, pom, profileId) === void 0 || versionSatisfiesSpecifier("MAVEN", version4, evaluate(managedDep.version.text, pom, profileId)))
218161
218183
  );
218162
218184
  for (const dep of profileManagedDependencies) {
218163
218185
  foundManagedDependencies.push({ dep, profileId });
@@ -218165,29 +218187,55 @@ var MavenFixingManager = class {
218165
218187
  }
218166
218188
  if (foundManagedDependencies.length) {
218167
218189
  for (const { dep: foundManagedDependency, profileId } of foundManagedDependencies) {
218168
- const patchLocation = findPatchLocation(
218169
- foundManagedDependency.pom.validatedPomFile,
218170
- foundManagedDependency.version,
218171
- pom,
218172
- profileId
218173
- );
218174
- if (patchLocation?.offset !== void 0) {
218175
- patches.push({
218176
- success: true,
218177
- fixes: [fix],
218178
- patch: {
218179
- file: patchLocation.file,
218180
- offset: patchLocation.offset,
218181
- oldText: patchLocation.text,
218182
- newText: fix.fixedVersion
218183
- }
218184
- });
218185
- foundExistingDependency = true;
218190
+ if (foundManagedDependency.version) {
218191
+ const patchLocation = findPatchLocation(
218192
+ foundManagedDependency.pom.validatedPomFile,
218193
+ foundManagedDependency.version,
218194
+ pom,
218195
+ profileId
218196
+ );
218197
+ if (patchLocation?.offset !== void 0) {
218198
+ patches.push({
218199
+ success: true,
218200
+ fixes: [fix],
218201
+ patch: {
218202
+ file: patchLocation.file,
218203
+ offset: patchLocation.offset,
218204
+ oldText: patchLocation.text,
218205
+ newText: fix.fixedVersion
218206
+ }
218207
+ });
218208
+ foundExistingDependency = true;
218209
+ } else {
218210
+ patches.push({
218211
+ success: false,
218212
+ fixes: [fix]
218213
+ });
218214
+ }
218186
218215
  } else {
218187
- patches.push({
218188
- success: false,
218189
- fixes: [fix]
218190
- });
218216
+ const insertPatch = getVersionPatch(
218217
+ foundManagedDependency,
218218
+ fix.fixedVersion,
218219
+ 3
218220
+ // parentIndentLevel: project > dependencyManagement > dependencies > dependency
218221
+ );
218222
+ if (insertPatch) {
218223
+ patches.push({
218224
+ success: true,
218225
+ fixes: [fix],
218226
+ patch: {
218227
+ file: insertPatch.file,
218228
+ offset: insertPatch.offset,
218229
+ newText: insertPatch.text
218230
+ }
218231
+ });
218232
+ foundExistingDependency = true;
218233
+ } else {
218234
+ patches.push({
218235
+ success: false,
218236
+ fixes: [fix]
218237
+ });
218238
+ }
218191
218239
  }
218192
218240
  }
218193
218241
  }
@@ -218274,7 +218322,8 @@ var MavenFixingManager = class {
218274
218322
  const foundManagedDependencies = [];
218275
218323
  for (const [profileId, profile] of pom.profiles) {
218276
218324
  const profileManagedDependencies = profile.managedDependencies.filter(
218277
- (managedDep) => groupId === evaluate(managedDep.groupId.text, pom, profileId) && artifactId === evaluate(managedDep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(managedDep.type?.text ?? "jar", pom, profileId) && classifier === (managedDep.classifier && evaluate(managedDep.classifier.text, pom, profileId)) && managedDep.version && (evaluate(managedDep.version?.text, pom, profileId) === void 0 || versionSatisfiesSpecifier("MAVEN", version4, evaluate(managedDep.version.text, pom, profileId)))
218325
+ (managedDep) => groupId === evaluate(managedDep.groupId.text, pom, profileId) && artifactId === evaluate(managedDep.artifactId.text, pom, profileId) && (type ?? "jar") === evaluate(managedDep.type?.text ?? "jar", pom, profileId) && classifier === (managedDep.classifier && evaluate(managedDep.classifier.text, pom, profileId)) && // Either no version (we'll insert one) or version matches
218326
+ (!managedDep.version || evaluate(managedDep.version.text, pom, profileId) === void 0 || versionSatisfiesSpecifier("MAVEN", version4, evaluate(managedDep.version.text, pom, profileId)))
218278
218327
  );
218279
218328
  for (const dep of profileManagedDependencies) {
218280
218329
  foundManagedDependencies.push({ dep, profileId });
@@ -218282,29 +218331,55 @@ var MavenFixingManager = class {
218282
218331
  }
218283
218332
  if (foundManagedDependencies.length) {
218284
218333
  const { dep: foundManagedDependency, profileId } = foundManagedDependencies[foundManagedDependencies.length - 1];
218285
- const patchLocation = findPatchLocation(
218286
- foundManagedDependency.pom.validatedPomFile,
218287
- foundManagedDependency.version,
218288
- pom,
218289
- profileId
218290
- );
218291
- if (patchLocation?.offset !== void 0) {
218292
- patches.push({
218293
- success: true,
218294
- fixes: [fix],
218295
- patch: {
218296
- file: patchLocation.file,
218297
- offset: patchLocation.offset,
218298
- oldText: patchLocation.text,
218299
- newText: fix.fixedVersion
218300
- }
218301
- });
218302
- foundExistingManagedDependency = true;
218334
+ if (foundManagedDependency.version) {
218335
+ const patchLocation = findPatchLocation(
218336
+ foundManagedDependency.pom.validatedPomFile,
218337
+ foundManagedDependency.version,
218338
+ pom,
218339
+ profileId
218340
+ );
218341
+ if (patchLocation?.offset !== void 0) {
218342
+ patches.push({
218343
+ success: true,
218344
+ fixes: [fix],
218345
+ patch: {
218346
+ file: patchLocation.file,
218347
+ offset: patchLocation.offset,
218348
+ oldText: patchLocation.text,
218349
+ newText: fix.fixedVersion
218350
+ }
218351
+ });
218352
+ foundExistingManagedDependency = true;
218353
+ } else {
218354
+ patches.push({
218355
+ success: false,
218356
+ fixes: [fix]
218357
+ });
218358
+ }
218303
218359
  } else {
218304
- patches.push({
218305
- success: false,
218306
- fixes: [fix]
218307
- });
218360
+ const insertPatch = getVersionPatch(
218361
+ foundManagedDependency,
218362
+ fix.fixedVersion,
218363
+ 3
218364
+ // fieldIndentLevel: project > dependencyManagement > dependencies > dependency > version
218365
+ );
218366
+ if (insertPatch) {
218367
+ patches.push({
218368
+ success: true,
218369
+ fixes: [fix],
218370
+ patch: {
218371
+ file: insertPatch.file,
218372
+ offset: insertPatch.offset,
218373
+ newText: insertPatch.text
218374
+ }
218375
+ });
218376
+ foundExistingManagedDependency = true;
218377
+ } else {
218378
+ patches.push({
218379
+ success: false,
218380
+ fixes: [fix]
218381
+ });
218382
+ }
218308
218383
  }
218309
218384
  }
218310
218385
  if (!foundExistingManagedDependency) {
@@ -218414,7 +218489,7 @@ var PomUpgradeHandler = class {
218414
218489
  async (validatedManifestFile) => {
218415
218490
  const res = await this.getDirectDependencyPatches(validatedManifestFile, idx, upgradeVersion, ctxt);
218416
218491
  patches.push(...res.patches ?? []);
218417
- if (res.managedDependencies) {
218492
+ if (res.managedDependencies?.length) {
218418
218493
  if (!managedDependenciesToAdd.has(validatedManifestFile)) {
218419
218494
  managedDependenciesToAdd.set(validatedManifestFile, { artifacts: [], dependencies: [] });
218420
218495
  }
@@ -218433,7 +218508,7 @@ var PomUpgradeHandler = class {
218433
218508
  async (validatedManifestFile) => {
218434
218509
  const res = await this.getTransitiveDependencyPatches(validatedManifestFile, idx, upgradeVersion, ctxt);
218435
218510
  patches.push(...res.patches ?? []);
218436
- if (res.managedDependencies) {
218511
+ if (res.managedDependencies?.length) {
218437
218512
  if (!managedDependenciesToAdd.has(validatedManifestFile)) {
218438
218513
  managedDependenciesToAdd.set(validatedManifestFile, { artifacts: [], dependencies: [] });
218439
218514
  }
@@ -218681,41 +218756,62 @@ var PomUpgradeHandler = class {
218681
218756
  continue;
218682
218757
  }
218683
218758
  if (managedClassifier !== classifier) continue;
218684
- const version4 = evaluate(managedDep.version.text, pom);
218685
- if (version4 === void 0) {
218686
- ctxt.statusUpdater?.({
218687
- status: "error",
218688
- file: manifestFile,
218689
- artifacts: [idx],
218690
- message: `Could not evaluate version for managed dependency`
218691
- });
218692
- continue;
218693
- }
218694
- const existingVersionRange = VersionRange.createFromVersionSpec(version4);
218695
- if (existingVersionRange.restrictions.length > 0 ? !existingVersionRange.containsVersion(existingMavenVersion) : existingVersionRange?.recommendedVersion?.compareTo(existingMavenVersion) !== 0) {
218696
- continue;
218697
- }
218698
- const patchLocation = findPatchLocation(
218699
- managedDep.pom.validatedPomFile,
218700
- managedDep.version,
218701
- pom,
218702
- profileId
218703
- );
218704
- if (patchLocation?.offset !== void 0) {
218705
- patches.push({
218706
- artifacts: [idx],
218707
- file: patchLocation.file,
218708
- offset: patchLocation.offset,
218709
- length: patchLocation.text.length,
218710
- text: ctxt.rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
218711
- });
218759
+ if (managedDep.version) {
218760
+ const version4 = evaluate(managedDep.version.text, pom);
218761
+ if (version4 === void 0) {
218762
+ ctxt.statusUpdater?.({
218763
+ status: "error",
218764
+ file: manifestFile,
218765
+ artifacts: [idx],
218766
+ message: `Could not evaluate version for managed dependency`
218767
+ });
218768
+ continue;
218769
+ }
218770
+ const existingVersionRange = VersionRange.createFromVersionSpec(version4);
218771
+ if (existingVersionRange.restrictions.length > 0 ? !existingVersionRange.containsVersion(existingMavenVersion) : existingVersionRange?.recommendedVersion?.compareTo(existingMavenVersion) !== 0) {
218772
+ continue;
218773
+ }
218774
+ const patchLocation = findPatchLocation(
218775
+ managedDep.pom.validatedPomFile,
218776
+ managedDep.version,
218777
+ pom,
218778
+ profileId
218779
+ );
218780
+ if (patchLocation?.offset !== void 0) {
218781
+ patches.push({
218782
+ artifacts: [idx],
218783
+ file: patchLocation.file,
218784
+ offset: patchLocation.offset,
218785
+ length: patchLocation.text.length,
218786
+ text: ctxt.rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
218787
+ });
218788
+ } else {
218789
+ ctxt.statusUpdater?.({
218790
+ status: "error",
218791
+ file: manifestFile,
218792
+ artifacts: [idx],
218793
+ message: `Failed to create patch for managed dependency`
218794
+ });
218795
+ }
218712
218796
  } else {
218713
- ctxt.statusUpdater?.({
218714
- status: "error",
218715
- file: manifestFile,
218716
- artifacts: [idx],
218717
- message: `Failed to create patch for managed dependency`
218718
- });
218797
+ const insertPatch = getVersionPatch(
218798
+ managedDep,
218799
+ ctxt.rangeStyle === "pin" ? upgradeMavenRangePinned.toString() : upgradeMavenVersion.toString(),
218800
+ 3
218801
+ );
218802
+ if (insertPatch) {
218803
+ patches.push({
218804
+ artifacts: [idx],
218805
+ ...insertPatch
218806
+ });
218807
+ } else {
218808
+ ctxt.statusUpdater?.({
218809
+ status: "error",
218810
+ file: manifestFile,
218811
+ artifacts: [idx],
218812
+ message: `Failed to create version insertion patch for managed dependency`
218813
+ });
218814
+ }
218719
218815
  }
218720
218816
  }
218721
218817
  }
@@ -218781,36 +218877,57 @@ var PomUpgradeHandler = class {
218781
218877
  continue;
218782
218878
  }
218783
218879
  if (managedArtifactId !== artifactId) continue;
218784
- const version4 = evaluate(managedDep.version.text, pom);
218785
- if (version4 === void 0) {
218786
- ctxt.statusUpdater?.({
218787
- status: "error",
218788
- file: manifestFile,
218789
- artifacts: [idx],
218790
- message: `Could not evaluate version for managed dependency`
218791
- });
218792
- continue;
218793
- }
218794
- const existingVersionRange = VersionRange.createFromVersionSpec(version4);
218795
- if (existingVersionRange.restrictions.length > 0 ? !existingVersionRange.containsVersion(existingMavenVersion) : existingVersionRange?.recommendedVersion?.compareTo(existingMavenVersion) !== 0) {
218796
- continue;
218797
- }
218798
- const patchLocation = findPatchLocation(managedDep.pom.validatedPomFile, managedDep.version, pom, profileId);
218799
- if (patchLocation?.offset !== void 0) {
218800
- patches.push({
218801
- artifacts: [idx],
218802
- file: patchLocation.file,
218803
- offset: patchLocation.offset,
218804
- length: patchLocation.text.length,
218805
- text: ctxt.rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
218806
- });
218880
+ if (managedDep.version) {
218881
+ const version4 = evaluate(managedDep.version.text, pom);
218882
+ if (version4 === void 0) {
218883
+ ctxt.statusUpdater?.({
218884
+ status: "error",
218885
+ file: manifestFile,
218886
+ artifacts: [idx],
218887
+ message: `Could not evaluate version for managed dependency`
218888
+ });
218889
+ continue;
218890
+ }
218891
+ const existingVersionRange = VersionRange.createFromVersionSpec(version4);
218892
+ if (existingVersionRange.restrictions.length > 0 ? !existingVersionRange.containsVersion(existingMavenVersion) : existingVersionRange?.recommendedVersion?.compareTo(existingMavenVersion) !== 0) {
218893
+ continue;
218894
+ }
218895
+ const patchLocation = findPatchLocation(managedDep.pom.validatedPomFile, managedDep.version, pom, profileId);
218896
+ if (patchLocation?.offset !== void 0) {
218897
+ patches.push({
218898
+ artifacts: [idx],
218899
+ file: patchLocation.file,
218900
+ offset: patchLocation.offset,
218901
+ length: patchLocation.text.length,
218902
+ text: ctxt.rangeStyle === "pin" || !existingVersionRange.containsVersion(upgradeMavenVersion) ? upgradeMavenRangePinned.toString() : existingVersionRange.hasRestrictions() ? upgradeMavenRange.restrict(existingVersionRange).toString() : upgradeMavenVersion.toString()
218903
+ });
218904
+ } else {
218905
+ ctxt.statusUpdater?.({
218906
+ status: "error",
218907
+ file: manifestFile,
218908
+ artifacts: [idx],
218909
+ message: `Failed to create patch for managed dependency`
218910
+ });
218911
+ }
218807
218912
  } else {
218808
- ctxt.statusUpdater?.({
218809
- status: "error",
218810
- file: manifestFile,
218811
- artifacts: [idx],
218812
- message: `Failed to create patch for managed dependency`
218813
- });
218913
+ const insertPatch = getVersionPatch(
218914
+ managedDep,
218915
+ ctxt.rangeStyle === "pin" ? upgradeMavenRangePinned.toString() : upgradeMavenVersion.toString(),
218916
+ 3
218917
+ );
218918
+ if (insertPatch) {
218919
+ patches.push({
218920
+ artifacts: [idx],
218921
+ ...insertPatch
218922
+ });
218923
+ } else {
218924
+ ctxt.statusUpdater?.({
218925
+ status: "error",
218926
+ file: manifestFile,
218927
+ artifacts: [idx],
218928
+ message: `Failed to create version insertion patch for managed dependency`
218929
+ });
218930
+ }
218814
218931
  }
218815
218932
  }
218816
218933
  }
@@ -250583,7 +250700,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
250583
250700
  }
250584
250701
 
250585
250702
  // dist/version.js
250586
- var version3 = "14.12.105";
250703
+ var version3 = "14.12.106";
250587
250704
 
250588
250705
  // dist/cli-core.js
250589
250706
  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.105",
3
+ "version": "14.12.106",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {