(app)
| 13 | })[m]); |
| 14 | |
| 15 | const generateDemoIndex = (app) => { |
| 16 | const demoList = fg.sync(['src/**/demo/html/*.html', 'src/**/demo/html/**/*.html'], { cwd: __dirname }); |
| 17 | const sortedDemos = demoList.reduce((acc, link) => { |
| 18 | const type = link.split('/')[1]; |
| 19 | |
| 20 | if (!acc[type]) { |
| 21 | acc[type] = []; |
| 22 | } |
| 23 | |
| 24 | acc[type].push(link); |
| 25 | |
| 26 | return acc; |
| 27 | }, {}); |
| 28 | |
| 29 | const lists = Object.keys(sortedDemos).map( |
| 30 | type => ` |
| 31 | <h2>${type}</h2> |
| 32 | <ul> |
| 33 | ${sortedDemos[type].map(link => `<li>${type !== 'core' ? `<strong>${escapeHtml(link.split('/')[2])}</strong> - ` : ''}<a href="${escapeHtml(link)}">${escapeHtml(path.basename(link))}</a></li>`).join('') |
| 34 | } |
| 35 | </ul>` |
| 36 | ).join(''); |
| 37 | const html = ` |
| 38 | <!DOCTYPE html> |
| 39 | <html lang="en"> |
| 40 | <head> |
| 41 | <meta charset="UTF-8"> |
| 42 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 43 | <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
| 44 | <title>Demos</title> |
| 45 | </head> |
| 46 | <body> |
| 47 | ${lists} |
| 48 | </body> |
| 49 | </html> |
| 50 | `; |
| 51 | |
| 52 | app.get('/', (_, res) => res.send(html)) |
| 53 | }; |
| 54 | |
| 55 | function create(entries, tsConfig, outDir = ".") { |
| 56 | const resolvedEntries = Object.fromEntries(Object.entries(entries).map(([k, v]) => [k, path.resolve(__dirname, v)])); |
no test coverage detected
searching dependent graphs…