import { EMPTY , Observable } from "rxjs" ; import { fetchSourceFactsFromGitHub } from "../github" ; import { fetchSourceFactsFromGitLab } from "../gitlab" ; /**
 * Repository facts for repositories
 */ export interface RepositoryFacts { stars ? : number ; forks ? : number ; version ? : string ; } /**
 * Repository facts for organizations
 */ export interface OrganizationFacts { repositories ? : number ; } /**
 * Repository facts
 */ export type SourceFacts = RepositoryFacts | OrganizationFacts ; param url returns export function fetchSourceFacts ( url ) { const [ type ] = url . match ( /(git(?:hub|lab))/i ) || [ ] ; switch ( type . toLowerCase ( ) ) { case "github" : const [ , user , repo ] = url . match ( /^.+github\.com\/([^/]+)\/?([^/]+)?/i ) ! ; return fetchSourceFactsFromGitHub ( user , repo ) ; case "gitlab" : const [ , base , slug ] = url . match ( /^.+?([^/]*gitlab[^/]+)\/(.+?)\/?$/i ) ! ; return fetchSourceFactsFromGitLab ( base , slug ) ; default : return EMPTY ; } }