Skip to content

Commit

Permalink
Changes for multipleversions
Browse files Browse the repository at this point in the history
  • Loading branch information
ragavareddychalapala committed Jan 12, 2025
1 parent 752d992 commit 9754855
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/LCT.PackageIdentifier/ConanProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,20 @@ private static void CreateFileForMultipleVersions(List<Component> componentsWith
{
MultipleVersions multipleVersions = new MultipleVersions();
IFileOperations fileOperations = new FileOperations();
string bomFileName = $"{appSettings.SW360.ProjectName}_Bom.cdx.json";
string outputFolderPath = appSettings.Directory.OutputFolder;
string[] files = System.IO.Directory.GetFiles(outputFolderPath);

bool fileExists = files.Length > 0 && files.Any(file => Path.GetFileName(file).Equals(bomFileName, StringComparison.OrdinalIgnoreCase));
string bomFullPath= $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_Bom.cdx.json";

string filename = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_{FileConstant.multipleversionsFileName}";
if (string.IsNullOrEmpty(appSettings.Directory.OutputFolder) || (!File.Exists(filename)))
if (fileExists || (!File.Exists(filename)))
{
multipleVersions.Conan = new List<MultipleVersionValues>();
foreach (var conanPackage in componentsWithMultipleVersions)
{

conanPackage.Description = !string.IsNullOrEmpty(bomFullPath) ? bomFullPath : conanPackage.Description;
MultipleVersionValues jsonComponents = new MultipleVersionValues();
jsonComponents.ComponentName = conanPackage.Name;
jsonComponents.ComponentVersion = conanPackage.Version;
Expand Down
9 changes: 8 additions & 1 deletion src/LCT.PackageIdentifier/NpmProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,19 @@ private static void CreateFileForMultipleVersions(List<Component> componentsWith
{
MultipleVersions multipleVersions = new MultipleVersions();
IFileOperations fileOperations = new FileOperations();
string bomFileName = $"{appSettings.SW360.ProjectName}_Bom.cdx.json";
string outputFolderPath = appSettings.Directory.OutputFolder;
string[] files = System.IO.Directory.GetFiles(outputFolderPath);

bool fileExists = files.Length > 0 && files.Any(file => Path.GetFileName(file).Equals(bomFileName, StringComparison.OrdinalIgnoreCase));
string bomFullPath = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_Bom.cdx.json";
string filename = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_{FileConstant.multipleversionsFileName}";
if (string.IsNullOrEmpty(appSettings.Directory.OutputFolder) || (!File.Exists(filename)))
if (fileExists || (!File.Exists(filename)))
{
multipleVersions.Npm = new List<MultipleVersionValues>();
foreach (var npmpackage in componentsWithMultipleVersions)
{
npmpackage.Description = !string.IsNullOrEmpty(bomFullPath) ? bomFullPath : npmpackage.Description;
MultipleVersionValues jsonComponents = new MultipleVersionValues();
jsonComponents.ComponentName = npmpackage.Name;
jsonComponents.ComponentVersion = npmpackage.Version;
Expand Down
9 changes: 8 additions & 1 deletion src/LCT.PackageIdentifier/NugetProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,19 @@ private static void CreateFileForMultipleVersions(List<Component> componentsWith
{
MultipleVersions multipleVersions = new MultipleVersions();
IFileOperations fileOperations = new FileOperations();
string bomFileName = $"{appSettings.SW360.ProjectName}_Bom.cdx.json";
string outputFolderPath = appSettings.Directory.OutputFolder;
string[] files = System.IO.Directory.GetFiles(outputFolderPath);

bool fileExists = files.Length > 0 && files.Any(file => Path.GetFileName(file).Equals(bomFileName, StringComparison.OrdinalIgnoreCase));
string bomFullPath = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_Bom.cdx.json";
string filename = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_{FileConstant.multipleversionsFileName}";
if (string.IsNullOrEmpty(appSettings.Directory.OutputFolder) || (!File.Exists(filename)))
if (fileExists || (!File.Exists(filename)))
{
multipleVersions.Nuget = new List<MultipleVersionValues>();
foreach (var nugetPackage in componentsWithMultipleVersions)
{
nugetPackage.Description = !string.IsNullOrEmpty(bomFullPath) ? bomFullPath : nugetPackage.Description;
MultipleVersionValues jsonComponents = new MultipleVersionValues();
jsonComponents.ComponentName = nugetPackage.Name;
jsonComponents.ComponentVersion = nugetPackage.Version;
Expand Down

0 comments on commit 9754855

Please sign in to comment.