- monorepo: pnpm workspace + go.work + pyproject.toml + commitlint/husky - infra: docker-compose (minimal + full profiles) + init-sql + prometheus - arch-scan: multi-language scanner skeleton (TS/Go/Python/Proto) - shared-proto: buf v2 + classes.proto (ClassService CRUD contract) - api-gateway: Go/Gin + JWT HS256 auth + reverse proxy + request ID - classes: NestJS golden template (error system + observability + middleware + CRUD + tests) - teacher-portal: Next.js + paper-feel UI design system - CI/CD: 4 workflows (go/ts/py/proto) - docs: migration guide + project_rules + coding-standards + git-workflow + ui-design-system + 004 + 9 module READMEs + known-issues + spec/plan migration + roadmap
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { Project, SyntaxKind } from 'ts-morph';
|
||
import path from 'node:path';
|
||
import type { Database as DBType } from 'better-sqlite3';
|
||
|
||
interface ScanStats {
|
||
modules: number;
|
||
symbols: number;
|
||
}
|
||
|
||
export function scanTypeScript(db: DBType, root: string): ScanStats {
|
||
const project = new Project({
|
||
tsConfigFilePath: undefined,
|
||
skipAddingFilesFromTsConfig: true,
|
||
compilerOptions: {
|
||
allowJs: true,
|
||
declaration: false,
|
||
resolveJsonModule: true,
|
||
},
|
||
});
|
||
|
||
const patterns = ['services/*/src/**/*.ts', 'apps/*/src/**/*.ts', 'packages/*/src/**/*.ts'];
|
||
let modules = 0;
|
||
let symbols = 0;
|
||
|
||
const insertModule = db.prepare(
|
||
'INSERT OR IGNORE INTO modules (name, path, language, service, type) VALUES (?, ?, ?, ?, ?)'
|
||
);
|
||
const insertSymbol = db.prepare(
|
||
'INSERT INTO symbols (module_id, name, kind, language, file_path, line_start, line_end, is_exported) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
||
);
|
||
|
||
// 简化实现:扫描 services/*/src 目录作为模块
|
||
const servicesDir = path.join(root, 'services');
|
||
// 实际实现用 fast-glob 模式匹配
|
||
// 此处为骨架,P1 后期补全
|
||
|
||
return { modules, symbols };
|
||
} |