ngast
1.0.0
该库为解析角度项目提供用户友好的API。
$ npm i @angular/core @angular/compiler @angular/compiler-cli ngast --save
ngast建立在常春藤(ngtsc)之上,请确保使用ngcc(运行ng serve,ng build或npx ngcc)编译您的项目。
首先,您需要将WorkspaceSymbols连接到tsconfig.json root:
import { join } from 'path' ;
import { WorkspaceSymbols } from 'ngast' ;
const config = join ( process . cwd ( ) , 'tsconfig.json' ) ;
const workspace = new WorkspaceSymbols ( config ) ;从那里您可以找到项目中的所有装饰课程:
const modules = workspace . getAllModules ( ) ;
const components = workspace . getAllComponents ( ) ;
const directives = workspace . getAllDirectives ( ) ;
const injectables = workspace . getAllInjectable ( ) ;
const pipes = workspace . getAllPipes ( ) ;上述方法中的第一次称为ngast将运行工作空间的分析。
目前的分析很长: >一个小项目的10秒可能会超过2分钟的大型项目。
版本0.4.0建立在ViewEngine之上,您可以在此处查看文档。
使用NGAST的项目:
麻省理工学院