66
77// Ignore Spelling: Jfrog
88
9+ using ArtifactoryUploader . Constants ;
910using CycloneDX . Models ;
1011using LCT . APICommunications ;
1112using LCT . APICommunications . Model ;
@@ -36,6 +37,7 @@ public static class UploadToArtifactory
3637 private const string Conan = "CONAN" ;
3738 private const string Cargo = "CARGO" ;
3839 private const string Debian = "DEBIAN" ;
40+ private const string NPM = "NPM" ;
3941
4042 #endregion
4143
@@ -150,7 +152,7 @@ private static string GetComponentType(Component item)
150152 }
151153 if ( item . Purl . Contains ( "npm" , StringComparison . OrdinalIgnoreCase ) )
152154 {
153- return " NPM" ;
155+ return NPM ;
154156 }
155157 else if ( item . Purl . Contains ( "nuget" , StringComparison . OrdinalIgnoreCase ) )
156158 {
@@ -172,7 +174,7 @@ private static string GetComponentType(Component item)
172174 {
173175 return Debian ;
174176 }
175- else if ( item . Purl . Contains ( "cargo" , StringComparison . OrdinalIgnoreCase ) )
177+ else if ( item . Purl . Contains ( ArtifactoryConstant . Cargo , StringComparison . OrdinalIgnoreCase ) )
176178 {
177179 return Cargo ;
178180 }
@@ -191,7 +193,7 @@ private static string GetComponentType(Component item)
191193 public static string GetJfrogRepPath ( ComponentsToArtifactory component )
192194 {
193195 string jfrogRepPath = string . Empty ;
194- if ( component . ComponentType == " NPM" )
196+ if ( component . ComponentType == NPM )
195197 {
196198 jfrogRepPath = $ "{ component . DestRepoName } /{ component . Path } /{ component . PypiOrNpmCompName } ";
197199 }
@@ -255,7 +257,7 @@ private static string GetDestinationRepo(Component item, CommonAppSettings appSe
255257 return GetRepoName ( packageType , appSettings . Conan . ReleaseRepo , appSettings . Conan . DevDepRepo , appSettings . Conan . Artifactory . ThirdPartyRepos . FirstOrDefault ( x => x . Upload ) ? . Name ) ;
256258 case "debian" :
257259 return GetRepoName ( packageType , appSettings . Debian . ReleaseRepo , appSettings . Debian . DevDepRepo , appSettings . Debian . Artifactory . ThirdPartyRepos . FirstOrDefault ( x => x . Upload ) ? . Name ) ;
258- case "cargo" :
260+ case ArtifactoryConstant . Cargo :
259261 return GetRepoName ( packageType , appSettings . Cargo . ReleaseRepo , appSettings . Cargo . DevDepRepo , appSettings . Cargo . Artifactory . ThirdPartyRepos . FirstOrDefault ( x => x . Upload ) ? . Name ) ;
260262 }
261263 }
@@ -273,7 +275,7 @@ private static string GetPackagePath(ComponentsToArtifactory component, AqlResul
273275 {
274276 switch ( component . ComponentType )
275277 {
276- case " NPM" :
278+ case NPM :
277279 if ( aqlResult != null )
278280 {
279281 return $ "{ aqlResult . Path } ";
@@ -317,7 +319,7 @@ private static string GetPackagePath(ComponentsToArtifactory component, AqlResul
317319 public static string GetCopyURL ( ComponentsToArtifactory component )
318320 {
319321 string url = string . Empty ;
320- if ( component . ComponentType == " NPM" )
322+ if ( component . ComponentType == NPM )
321323 {
322324 url = $ "{ component . JfrogApi } { ApiConstant . CopyPackageApi } { component . SrcRepoPathWithFullName } " +
323325 $ "?to=/{ component . DestRepoName } /{ component . Path } /{ component . PypiOrNpmCompName } ";
@@ -371,7 +373,7 @@ public static string GetCopyURL(ComponentsToArtifactory component)
371373 public static string GetMoveURL ( ComponentsToArtifactory component )
372374 {
373375 string url = string . Empty ;
374- if ( component . ComponentType == " NPM" )
376+ if ( component . ComponentType == NPM )
375377 {
376378 url = $ "{ component . JfrogApi } { ApiConstant . MovePackageApi } { component . SrcRepoPathWithFullName } " +
377379 $ "?to=/{ component . DestRepoName } /{ component . Path } /{ component . PypiOrNpmCompName } ";
@@ -426,7 +428,7 @@ private static string GetJfrogPackageName(ComponentsToArtifactory component)
426428 {
427429 return component . ComponentType switch
428430 {
429- " NPM" => component . PypiOrNpmCompName ,
431+ NPM => component . PypiOrNpmCompName ,
430432 Nuget => $ "{ component . PackageName } .{ component . Version } { ApiConstant . NugetExtension } ",
431433 Choco => $ "{ component . PackageName } .{ component . Version } { ApiConstant . NugetExtension } ",
432434 Debian => $ "{ component . PackageName } _{ component . Version . Replace ( ApiConstant . DebianExtension , "" ) + "*" } ",
@@ -465,7 +467,7 @@ private static void AddUnknownComponentToDisplayList(string projectType, Compone
465467 {
466468 switch ( projectType )
467469 {
468- case " NPM" :
470+ case NPM :
469471 displayPackagesInfo . UnknownPackagesNpm . Add ( component ) ;
470472 break ;
471473 case Nuget :
@@ -566,9 +568,9 @@ public async static Task<AqlResult> GetSrcRepoDetailsForComponent(Component item
566568 return GetArtifactoryRepoName ( aqlResultList , item ) ;
567569 }
568570 }
569- else if ( item . Purl . Contains ( "cargo" , StringComparison . OrdinalIgnoreCase ) )
571+ else if ( item . Purl . Contains ( ArtifactoryConstant . Cargo , StringComparison . OrdinalIgnoreCase ) )
570572 {
571- var aqlResultList = await GetPackageTypeBased_ListOfComponentsFromRepo ( new string [ ] { item . Properties . Find ( x => x . Name == Dataconstant . Cdx_ArtifactoryRepoName ) ? . Value } , JFrogService , "cargo" ) ;
573+ var aqlResultList = await GetPackageTypeBased_ListOfComponentsFromRepo ( new string [ ] { item . Properties . Find ( x => x . Name == Dataconstant . Cdx_ArtifactoryRepoName ) ? . Value } , JFrogService , ArtifactoryConstant . Cargo ) ;
572574
573575 if ( aqlResultList . Count > 0 )
574576 {
@@ -605,7 +607,7 @@ public static async Task<List<AqlResult>> GetPackageTypeBased_ListOfComponentsFr
605607 repoCache [ repo ] = componentRepoData ;
606608 aqlResultList . AddRange ( componentRepoData ) ;
607609 }
608- else if ( packageType == "cargo" )
610+ else if ( packageType == ArtifactoryConstant . Cargo )
609611 {
610612 var componentRepoData = await jFrogService . GetCargoComponentDataByRepo ( repo ) ?? new List < AqlResult > ( ) ;
611613 repoCache [ repo ] = componentRepoData ;
@@ -666,7 +668,7 @@ private static AqlResult GetArtifactoryRepoName(List<AqlResult> aqlResultList, C
666668 x . Properties . Any ( p => p . Key == "npm.name" && p . Value == jfrogpackageName ) &&
667669 x . Properties . Any ( p => p . Key == "npm.version" && p . Value == component . Version ) ) ;
668670 }
669- else if ( component . Purl . Contains ( "cargo" , StringComparison . OrdinalIgnoreCase ) )
671+ else if ( component . Purl . Contains ( ArtifactoryConstant . Cargo , StringComparison . OrdinalIgnoreCase ) )
670672 {
671673 return aqlResultList . Find ( x => x . Properties != null &&
672674 x . Properties . Any ( p => p . Key == "crate.name" && p . Value == jfrogpackageName ) &&
0 commit comments