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的項目:
麻省理工學院