import axios from 'axios' ; import { serverEndpoint } from './api' ; const githubEndpoint = "https://raw.githubusercontent.com/" ; async function fetch_requirements ( vendor , name ) { let requirments = await axios . get ( githubEndpoint + vendor + "/" + name + "/master/requirements.txt" ) ; return requirments . data . split ( "=" ) . join ( "\n" ) . split ( "\n" ) . filter ( function ( each ) { if ( isNaN ( each ) && each !== "" && ! each . includes ( "." ) ) { return true ; } return false ; } ) ; } async function fetch_github_summary ( packageId ) { return await ( await axios . get ( serverEndpoint + "model/meta/" + packageId ) ) . data ; } async function analyseGithubRepo ( vendor , name , packageId ) { let requirements = await fetch_requirements ( vendor , name ) ; let githubSummary = await fetch_github_summary ( packageId ) ; return { 'requirements' : requirements , 'summary' : githubSummary } ; } export { analyseGithubRepo } ;