public async Task <RepositoryTypeAndImplementations> DeriveImplementationAsync(string repositoryName) { var files = await ReadFileListAsync(); // Check for ASP.NET based projects var globalAsaxFile = files.FirstOrDefault(file => file.Name == "Global.asax"); if (globalAsaxFile != null) { var typeAndImplementations = new RepositoryTypeAndImplementations(); typeAndImplementations.TypeName = "API"; var implementations = new List <RepositoryImplementation> { new RepositoryImplementation { Name = "ASP.NET" } }; // Can't use .NET path commands due to the unix style paths being used var fileNameRegex = @"[^/]+\Z"; var globalAsaxDirectory = Regex.Replace(globalAsaxFile.FullPath, fileNameRegex, string.Empty); var nuGetDependencies = Dependencies?.Where(depencency => depencency.Source == "NuGet"); var serviceStackDependency = nuGetDependencies.FirstOrDefault(dependency => dependency.RepoPath.Contains(globalAsaxDirectory) && dependency.Name == "ServiceStack"); var webApiDependency = nuGetDependencies.FirstOrDefault(dependency => dependency.RepoPath.Contains(globalAsaxDirectory) && dependency.Name == "Microsoft.AspNet.WebApi"); // Some WebApis bring in servicestack where as the opposite isn't true AFAIK if (serviceStackDependency != null && webApiDependency == null) { implementations.Add(new RepositoryImplementation { Name = "ServiceStack", Version = serviceStackDependency.Version, MajorVersion = serviceStackDependency.Version.GetMajorVersion() }); typeAndImplementations.Implementations = implementations; return(typeAndImplementations); } else if (webApiDependency != null) { implementations.Add(new RepositoryImplementation { Name = "Web Api", Version = webApiDependency.Version, MajorVersion = webApiDependency.Version.GetMajorVersion() }); typeAndImplementations.Implementations = implementations; return(typeAndImplementations); } } return(null); }
public async Task <RepositoryTypeAndImplementations> DeriveImplementationAsync(string repositoryName) { var nugetDependencies = Dependencies?.Where(dependency => dependency.Source == "NuGet"); var aspNetCoreAllDependency = nugetDependencies.FirstOrDefault(dependency => dependency.Name == "Microsoft.AspNetCore.All"); var aspNetCoreAppDependency = nugetDependencies.FirstOrDefault(dependency => dependency.Name == "Microsoft.AspNetCore.App"); // If both are found use the newer metapackage var aspNetCoreDependency = aspNetCoreAppDependency ?? aspNetCoreAllDependency; if (aspNetCoreDependency != null) { var typeAndImplementations = new RepositoryTypeAndImplementations(); typeAndImplementations.TypeName = "API"; typeAndImplementations.Implementations = new List <RepositoryImplementation> { new RepositoryImplementation { Name = "ASP.NET Core - Web API", Version = aspNetCoreDependency.Version, MajorVersion = aspNetCoreDependency.Version.GetMajorVersion() } }; return(typeAndImplementations); } return(null); }
public async Task <RepositoryTypeAndImplementations> DeriveImplementationAsync(string repositoryName) { var bowerAndNpmDependencies = Dependencies?.Where(dependency => dependency.Source == "bower" || dependency.Source == "npm"); // Check for Angular 1.x var angularDependency = bowerAndNpmDependencies.FirstOrDefault(dependency => dependency.Name == "angular"); if (angularDependency == null) { // Check for Angular 2.x and higher angularDependency = bowerAndNpmDependencies.FirstOrDefault(dependency => dependency.Name == "@angular/core"); } if (angularDependency != null) { var typeAndImplementations = new RepositoryTypeAndImplementations(); typeAndImplementations.TypeName = "Web UI"; typeAndImplementations.Implementations = new List <RepositoryImplementation> { new RepositoryImplementation { Name = "Angular", Version = angularDependency.Version, MajorVersion = angularDependency.Version.GetMajorVersion() } }; return(typeAndImplementations); } return(null); }
public async Task <RepositoryTypeAndImplementations> DeriveImplementationAsync(string repositoryName) { var bowerAndNpmDependencies = Dependencies?.Where(dependency => dependency.Source == "bower" || dependency.Source == "npm"); var reactDependency = bowerAndNpmDependencies.FirstOrDefault(dependency => dependency.Name == "react"); if (reactDependency != null) { var typeAndImplementations = new RepositoryTypeAndImplementations(); typeAndImplementations.TypeName = "Web UI"; typeAndImplementations.Implementations = new List <RepositoryImplementation> { new RepositoryImplementation { Name = "React", Version = reactDependency.Version, MajorVersion = reactDependency.Version.GetMajorVersion() } }; return(typeAndImplementations); } return(null); }
private async Task <List <RepositoryTypeAndImplementations> > ScrapeRepositoryTypeAndImplementation(string repositoryName, IEnumerable <RepositoryFile> files, IEnumerable <RepositoryDependency> dependencies, IEnumerable <string> topicNames, BacklogInfo backlogInfo, DateTime?asOf) { var typesAndImplementations = new List <RepositoryTypeAndImplementations>(); foreach (var typeAndImplementationDeriver in typeAndImplementationDerivers) { if (typeAndImplementationDeriver is IRequireDependenciesAccess) { (typeAndImplementationDeriver as IRequireDependenciesAccess).Dependencies = dependencies; } if (typeAndImplementationDeriver is IRequireTopicsAccess) { (typeAndImplementationDeriver as IRequireTopicsAccess).TopicNames = topicNames; } if (typeAndImplementationDeriver is IRequireFilesAccess) { (typeAndImplementationDeriver as IRequireFilesAccess).Files = files; } if (typeAndImplementationDeriver is IRequireBacklogInfoAccess) { (typeAndImplementationDeriver as IRequireBacklogInfoAccess).BacklogInfo = backlogInfo; } RepositoryTypeAndImplementations typeAndImplementationInfo = null; try { logger.LogDebug($"Running Type and Implementation Deriver {typeAndImplementationDeriver.GetType().Name}"); typeAndImplementationInfo = await typeAndImplementationDeriver.DeriveImplementationAsync(repositoryName); } catch (Exception ex) { logger.LogError(ex, $"Exception running {typeAndImplementationDeriver.GetType().Name} Type And Implementations Deriver on repository {repositoryName}"); } if (typeAndImplementationInfo != null) { logger.LogDebug($"Match found for Type and Implementation Deriver {typeAndImplementationDeriver.GetType().Name}"); typesAndImplementations.Add(typeAndImplementationInfo); } } if (!typesAndImplementations.Any()) { typesAndImplementations.Add(new RepositoryTypeAndImplementations { TypeName = "Unknown", Implementations = new List <RepositoryImplementation> { new RepositoryImplementation { Name = "Unknown" } } }); } return(typesAndImplementations); }
public async Task <RepositoryTypeAndImplementations> DeriveImplementationAsync(string repositoryName) { var bowerAndNpmDependencies = Dependencies?.Where(dependency => dependency.Source == "bower" || dependency.Source == "npm"); if (bowerAndNpmDependencies != null && bowerAndNpmDependencies.Any()) { var typeAndImplementations = new RepositoryTypeAndImplementations(); typeAndImplementations.TypeName = "API"; var implementations = new List <RepositoryImplementation>(); var expressDepencency = bowerAndNpmDependencies.FirstOrDefault(dependency => dependency.Name == "express"); var hapiDependency = bowerAndNpmDependencies.FirstOrDefault(dependency => dependency.Name == "hapi"); var koaDependency = bowerAndNpmDependencies.FirstOrDefault(dependency => dependency.Name == "koa"); if (expressDepencency != null) { implementations.Add(new RepositoryImplementation { Name = "Node JS - Express", Version = expressDepencency.Version, MajorVersion = expressDepencency.Version.GetMajorVersion() }); typeAndImplementations.Implementations = implementations; return(typeAndImplementations); } else if (hapiDependency != null) { implementations.Add(new RepositoryImplementation { Name = "Node JS - Hapi", Version = hapiDependency.Version, MajorVersion = hapiDependency.Version.GetMajorVersion() }); typeAndImplementations.Implementations = implementations; return(typeAndImplementations); } else if (koaDependency != null) { implementations.Add(new RepositoryImplementation { Name = "Node JS - Koa", Version = koaDependency.Version, MajorVersion = koaDependency.Version.GetMajorVersion() }); typeAndImplementations.Implementations = implementations; return(typeAndImplementations); } } return(null); }