MCPcopy
hub / github.com/ThatGuySam/doesitarm / buildReadmeAppList

Function buildReadmeAppList

helpers/build-app-list.js:81–234  ·  view source on GitHub ↗
({ readmeContent, scanListMap, commits })

Source from the content-addressed store, hash-verified

79
80
81export function buildReadmeAppList ({ readmeContent, scanListMap, commits }) {
82
83 // Parse markdown
84 const result = md.parse(readmeContent)
85
86 // console.log('results', result.length)
87 // console.log('results', result)
88
89
90 // Find the end of our list
91 // const endOfListIndex = getEndOfListIndex( result )
92
93 const appListTokens = getReadmeTokenList( result )
94
95 const appList = []
96
97 let categorySlug = 'start'
98 let categoryTitle = 'Start'
99 let isHeading = false
100 let isParagraph = false
101
102 for (const token of appListTokens) {
103 // On heading close switch off heading mode
104 if (token.type.includes('heading_')) isHeading = !isHeading
105
106 // On heading close switch off heading mode
107 if (token.type.includes('paragraph_')) isParagraph = !isParagraph
108
109 if (isHeading && token.type === 'inline') {
110 categoryTitle = token.content
111 categorySlug = makeSlug( token.content )
112
113 // appList[categorySlug] = []
114 }
115
116
117 if ( isParagraph && token.type === 'inline' && token.content.includes(' - ') ) {
118
119 const [ link, text ] = token.content.split(' - ').map(string => string.trim())
120
121 const [ name, url ] = link.substring(1, link.length-1).split('](')
122
123 const bundleIds = []
124 let tags = []
125 let aliases = []
126 const relatedLinksMap = new Map( getTokenLinks(token.children).map( link => [ link.href, link ] ) )
127
128 // Search for this app in the scanList and remove duplicates
129 scanListMap.forEach( ( scannedApp, key ) => {
130
131 for ( const alias of scannedApp.aliases ) {
132 // console.log( key, alias, name, eitherMatches(alias, name) )
133
134 if ( eitherMatches(alias, name) ) {
135 // If we don't have any bundleIds yet
136 // Add this app's bundleId to the list
137 if ( !bundleIds.includes( scannedApp.bundleIds[0] ) ) { bundleIds.push(scannedApp.bundleIds[0]) }
138

Callers 2

index.test.jsFile · 0.90
build-app-list.jsFile · 0.85

Calls 8

makeSlugFunction · 0.90
eitherMatchesFunction · 0.90
getAppEndpointFunction · 0.90
getReadmeTokenListFunction · 0.85
getTokenLinksFunction · 0.85
lookForLastUpdatedFunction · 0.85
parseDateFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected