({ readmeContent, scanListMap, commits })
| 79 | |
| 80 | |
| 81 | export 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 |
no test coverage detected