A tool for salvation and exploration of your beloved Angular app. It is what's inside that matters; NgFate will provide your app's inside, app structure, component routes, dependencies and relations. Made by CodeOmelet with love and a bunch of sleepless nights using dotnet csharp. In this article, we will walk you through, what, why and how of NgFate so that you can deep dive inside your Angular app.
Album Post:
For quick read. Checkout this amazing album!
When our Angular app grows it brings a lot of modules and components to manage and keep track of. One of the problems which I personally face when I start working on any new Angular app is getting the hold on the structure of the application. It is challenging to understand a project who's who quickly and it takes a good amount of time. To address this problem once it for all, I thought why not we just create a tool that shows a hierarchy and relation between the modules and components. This tool will tell whether the component is routed or not, where it's been referred and used, how many components are there in a module etc.
For this I have taken an oath to create a tool that will put a full stop to this suffering and help me and other fellow developers to get a relief. Introducing NgFate tool, built using .NET 6 and C#, providing you bunch of options to view your project structure and hierarchy (JSON, HTML, CLI, etc.).
In this article we will go through below points to explore NgFate:
Download and dotnet Run
Run Application
Limitations
Algorithm and Data Structure
Future Scope
1. Download and dotnet Run
The tool is published to GitHub repository NgFate. Below shows the download and dotnet run steps:
Download the app from the latest Releases section.
Unzip the project in the directory of your choice.
If you want a .json file as an output select first option.
If you want a .html file as an output select second option.
If you want output in the terminal it self select third option.
If you want all of the above select fourth option.
Output Folder Path: Path to your directory where you want all the output files to be generated.
Below shows recording of the above performed steps:
3. Limitations
Currently the NgFate is rookie and have to evolve a lot. For starter the tool is looking for some ideal structuring of the Angular project as per the Angular official document.
Check and verify if your app is adhering to these limitations:
NgFate doesn't support standalone components yet.
The module and component naming must follow Angular guide.
Each module and component files must ends with the convention *.module.ts and *.component.ts.
Properly formatted declarations of components within @NgModule decorator (either in single line or new line).
Properly formatted routes configurations (path and component properties).
Prefix must be provided while providing the input to NgFate (it is case sensitive).
4. Algorithm and Data Structure
The NgFate is working on below base algorithm right now:
get all '.module.ts' files
get all 'declarations' array data from NgModules
decompose fileName based on camelCasing of name
get file path by search fileName in the directory
read '*-routing.module.ts' file and search name of component if existed
get the path name while searching for component in routing file
search for 'header.component.html' file in entire project and get the .html parent files
decompose fileName from name
To support the above algorithm below data structure is at core of the tool:
[// 1. get all '.module.ts' files{name:'AppModule',fileName:'app.module.ts',components:[// 2. get all 'declarations' array data from NgModules{name:'LoginComponent',fileName:'login.component.ts',// 3. decompose fileName based on camelCasing of namefilePath:'src/app/pages/login.component.ts',// 4. get file path by search fileName in the directoryrouted:true,// 5. read '*-routing.module.ts' file and search name of component if existedroutePath:'login',// 6. get the path name while searching for component in routing fileparents:[],},{name:'HeaderComponent',fileName:'header.component.ts',filePath:'src/app/components/header.component.ts',routed:false,// 5. read '*-routing.module.ts' file and search name of component if existedroutePath:null,parents:[// 7. search for 'header.component.html' file in entire project and get the .html parent files{name:'MainComponent',fileName:'main.component.ts',// 8. decompose fileName from namefilePath:'src/app/components/main.component.ts',// 4. get file path by search fileName in the directory},],},],},];
5. Future Scope
For the interstellar travel of NgFate below are some key features considered as a future scope for the tool:
Diagrams:
Dependency graph in .html report.
Routing graph in .html report.
Pipes and directives considerations.
Version Support: Adhering to the latest releases of Angular.