( routesDir: string, fsPath: string, explicitFileType?: 'Route' | 'Plugin' | 'ServiceWorker' )
| 98 | * `Layout` files are named based on their path (eg. /routes/about/menu.md => AboutMenu) |
| 99 | */ |
| 100 | export function createFileId( |
| 101 | routesDir: string, |
| 102 | fsPath: string, |
| 103 | explicitFileType?: 'Route' | 'Plugin' | 'ServiceWorker' |
| 104 | ) { |
| 105 | const ids: string[] = []; |
| 106 | |
| 107 | for (let i = 0; i < 25; i++) { |
| 108 | let baseName = removeExtension(basename(fsPath)); |
| 109 | |
| 110 | baseName = baseName.replace(/[\W_]+/g, ''); |
| 111 | if (baseName === '') { |
| 112 | baseName = 'Q' + i; |
| 113 | } else if (!isNaN(baseName.charAt(0) as any)) { |
| 114 | baseName = 'Q' + baseName; |
| 115 | } |
| 116 | ids.push(toTitleCase(baseName)); |
| 117 | |
| 118 | fsPath = normalizePath(dirname(fsPath)); |
| 119 | |
| 120 | if (fsPath === routesDir) { |
| 121 | break; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | if (ids.length > 1 && ids[0] === 'Index') { |
| 126 | ids.shift(); |
| 127 | } |
| 128 | |
| 129 | return ids |
| 130 | .reverse() |
| 131 | .join('') |
| 132 | .concat(explicitFileType || ''); |
| 133 | } |
| 134 | |
| 135 | const PAGE_MODULE_EXTS: { [type: string]: boolean } = { |
| 136 | '.tsx': true, |
no test coverage detected
searching dependent graphs…