(backend)
| 113 | |
| 114 | // Count lines of code in app dir |
| 115 | function countLoc(backend) { |
| 116 | const resultsDir = path.join(runBaseDir, 'results', backend); |
| 117 | if (!fs.existsSync(resultsDir)) return null; |
| 118 | |
| 119 | const appDirs = fs.readdirSync(resultsDir) |
| 120 | .filter(d => d.startsWith('chat-app-')) |
| 121 | .map(d => path.join(resultsDir, d)) |
| 122 | .filter(d => fs.statSync(d).isDirectory()); |
| 123 | |
| 124 | if (appDirs.length === 0) return null; |
| 125 | const appDir = appDirs.sort().pop(); |
| 126 | |
| 127 | let backendLoc = 0; |
| 128 | let frontendLoc = 0; |
| 129 | |
| 130 | function countLines(dir) { |
| 131 | if (!fs.existsSync(dir)) return 0; |
| 132 | let total = 0; |
| 133 | for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { |
| 134 | if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name === '.vite' || |
| 135 | entry.name === 'module_bindings' || entry.name.startsWith('level-')) continue; |
| 136 | const fullPath = path.join(dir, entry.name); |
| 137 | if (entry.isDirectory()) { |
| 138 | total += countLines(fullPath); |
| 139 | } else if (/\.(ts|tsx|js|jsx)$/.test(entry.name)) { |
| 140 | total += fs.readFileSync(fullPath, 'utf-8').split('\n').length; |
| 141 | } |
| 142 | } |
| 143 | return total; |
| 144 | } |
| 145 | |
| 146 | // SpacetimeDB backend |
| 147 | const stdbBackend = path.join(appDir, 'backend', 'spacetimedb', 'src'); |
| 148 | if (fs.existsSync(stdbBackend)) { |
| 149 | backendLoc = countLines(stdbBackend); |
| 150 | } |
| 151 | |
| 152 | // PostgreSQL backend |
| 153 | const pgServer = path.join(appDir, 'server'); |
| 154 | if (fs.existsSync(pgServer)) { |
| 155 | backendLoc = countLines(pgServer); |
| 156 | } |
| 157 | |
| 158 | // Frontend |
| 159 | const clientSrc = path.join(appDir, 'client', 'src'); |
| 160 | if (fs.existsSync(clientSrc)) { |
| 161 | frontendLoc = countLines(clientSrc); |
| 162 | } |
| 163 | |
| 164 | return { backendLoc, frontendLoc, totalLoc: backendLoc + frontendLoc }; |
| 165 | } |
| 166 | |
| 167 | // ─── Generate report ──────────────────────────────────────────────────────── |
| 168 |
no test coverage detected
searching dependent graphs…