-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-graph.ts
More file actions
57 lines (51 loc) · 1.68 KB
/
Copy pathgenerate-graph.ts
File metadata and controls
57 lines (51 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import fs from 'fs';
import path from 'path';
const ROOT = path.resolve(__dirname, '..');
const PACKAGES_DIR = path.join(ROOT, 'packages');
interface PackageInfo {
name: string;
path: string;
version: string;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
}
function getPackages(): PackageInfo[] {
if (!fs.existsSync(PACKAGES_DIR)) return [];
return fs.readdirSync(PACKAGES_DIR).filter(p => {
return fs.statSync(path.join(PACKAGES_DIR, p)).isDirectory();
}).map(p => {
const pkgJsonPath = path.join(PACKAGES_DIR, p, 'package.json');
if (fs.existsSync(pkgJsonPath)) {
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
return {
name: pkg.name,
path: `packages/${p}`,
version: pkg.version,
dependencies: pkg.dependencies,
devDependencies: pkg.devDependencies
} as PackageInfo;
}
return null;
}).filter((p): p is PackageInfo => p !== null);
}
const graph = {
generatedAt: new Date().toISOString(),
root: ROOT,
packages: getPackages(),
docs: fs.existsSync(path.join(ROOT, 'docs'))
? fs.readdirSync(path.join(ROOT, 'docs')).filter(f => f.endsWith('.md') || f.endsWith('.json'))
: [],
criticalFiles: [
'README.md',
'AGENTS.md',
'apo.config.json',
'.cursorrules',
'PROJECT_GRAPH.json',
'CONTRIBUTING.md'
].filter(f => fs.existsSync(path.join(ROOT, f)))
};
fs.writeFileSync(
path.join(ROOT, 'PROJECT_GRAPH.json'),
JSON.stringify(graph, null, 2)
);
console.log('Generated PROJECT_GRAPH.json');