So the other day I was helping a team of developers at work dig up an old version of an ERP software running on our internal network. The thing was so old…… no one even remembered where the source code was, let alone what is in it! Now since the developers who wrote the thing were long gone, we had some digging to do. Eventually, we found the source in an old git repository and set about compiling the code. We needed to breakdown this big pile of code and the only way to do it is to dive in. Trying to piece together all the different projects so we had a whole system was no mean feat. Light bulb moment - A thought came to me that if we could understand the dependencies and references of all the projects - we could draw a graph that will show us which projects are the root projects and which were not. This saved us time by showing which projects we should build first and so on. With that in mind I wrote a little tool that clones the repository, reads and parse all the csproj files and creates a dependency graph.
To make it more accessible, I hacked and butchered a web client in Vue. Hey, I'm a backend developer, all this CSS stuff is very annoying. I used force-graph-3d.js to display the graph in the browser so the developers can view it from their workstations.
The actions the server is executing:
Clone the git repository as a local repository. Works only on C# projects (for now?). Cloning takes a while depending on the size of the repository that is being cloned. I am using an animated gif image of a "downloading" hourglass animation and a status text to let the user know what is going on on the server side. As I said, UI is not really my thing.
Read and parse all the *.csproj files
Create links between projects, NuGets and external libraries/files
Send the graph's data to the client
A demo video
I went to GitHub to look for projects to map for the demo. I did a search for "C#" and then filtered the results using the languages filter (I set it to "C#"). I just went down the list a picked projects that looked interesting. After 3 projects I decided to tackle a BIG repository, so I went after the AspNetCore.Docs repository (~850Mb). I spared you the download time and skipped to the graph creation.
Source code:
I have plans for this little project.
If I can map it I should be able to build it, I mean all the build instructions are there just need to figure out the build steps...
If I can build it I maybe the program could also deploy it, it knows the type of products that are built so it could figure out how to deploy them (just need a destination).
Of course this is over simplifying it, will probably need some assistance from the developers but even if I can automate a significant percent of the work it would be very helpful.
So, if all the above are achievable this is a very promising path to taking a pile of code, dump it in a folder and tell the application to "build this and deploy it over there". Well, one can only dream :)