Skip to content

By Weng Fei Fung. Lets you figure out the structure of your app by showing a tree of module dependencies. This works for any programming language because with regular expression you can look for any tokens, for example: require (nodeJS), import (ES6), include (PHP). Just provide the entry point file and the regular expression to match the module…

Notifications You must be signed in to change notification settings

Siphon880gh/module-tree-viewer

Repository files navigation

Tree module

By Weng Fei Fung

Lets you figure out the structure of your app by showing a tree of module dependencies. This works for any programming language because with regular expression you can look for any tokens, for example: require (nodeJS), import (ES6), include (PHP). Just provide the entry point file and the regular expression to match the module filenames in lines recursively. Regular expression examples for different languages are in the ReadMe.

You can also match for a descriptive comment on the same line of the module. Then the tree would show descriptions next to each module.

Mandatory:
--entry fileNameHere
--pattern regExpHere

Optional:
--comment regExpHere
--help

Example

@test-php/index.php
- test-php/plugin.php ( main plugin)
-- test-php/child_plugin.php
-- test-php/child_plugin.php

Hints

PHP

module-tree-viewer --entry test-php/index.php --pattern "include\(.(.*).\)" --comment "//\s?(.*)

Node JS

module-tree-viewer --entry test-nodejs/index.php --pattern "require\(.(.*).\)" --comment "//\s?(.*)"

ES

module-tree-viewer --entry test-es/index.php --pattern "from .(.*)." --comment "//\s?(.*)"

Troubleshooting: Does not run?

Try installing globally
sudo npm install -g module-tree-viewer

Then testing with
module-tree-viewer --help

If this fails, then most likely your npm is not setup correctly. See if $NODE_PATH is empty:
echo $NODE_PATH

Then find out where your node_modules is by finding the directory of npm
npm which

For example, that command shows my npm directory is
/usr/local/lib/node_modules/npm

So the node_modules directory is one level up:
/usr/local/lib/node_modules

Finally, export your NODE_PATH to configure node correctly. In my case, it is:
export NODE_PATH='/usr/local/lib/node_modules/'

About

By Weng Fei Fung. Lets you figure out the structure of your app by showing a tree of module dependencies. This works for any programming language because with regular expression you can look for any tokens, for example: require (nodeJS), import (ES6), include (PHP). Just provide the entry point file and the regular expression to match the module…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published