| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const fs = require('fs');
- const path = require('path');
- function walk(dir) {
- let r = [];
- fs.readdirSync(dir).forEach(f => {
- const p = path.join(dir, f);
- fs.statSync(p).isDirectory() ? r = r.concat(walk(p)) : r.push(p);
- });
- return r;
- }
- // 1. Collect all saasadminui API paths
- const files = walk('src/api').filter(f => f.endsWith('.js'));
- const allPaths = [];
- files.forEach(f => {
- let c = fs.readFileSync(f, 'utf8');
- const re = /url:\s*['"]([^'"]+)['"]/g;
- let m;
- while ((m = re.exec(c)) !== null) {
- allPaths.push({ file: f, url: m[1] });
- }
- });
- // 2. Group by top-2 prefix
- const prefixes = new Map();
- const prefixPaths = new Map();
- allPaths.forEach(({ url }) => {
- const parts = url.split('/').filter(Boolean);
- if (parts.length >= 2) {
- const prefix = parts.slice(0, 2).join('/');
- if (!prefixes.has(prefix)) prefixes.set(prefix, 0);
- prefixes.set(prefix, prefixes.get(prefix) + 1);
- if (!prefixPaths.has(prefix)) prefixPaths.set(prefix, []);
- prefixPaths.get(prefix).push(url);
- }
- });
- console.log('Total API URL entries:', allPaths.length);
- console.log('Unique paths:', new Set(allPaths.map(x => x.url)).size);
- console.log('\nPath prefixes (sorted by count):');
- const sorted = [...prefixes.entries()].sort((a, b) => b[1] - a[1]);
- sorted.forEach(([k, v]) => console.log(` ${k} (${v})`));
|