This script generates a dependency graph and list for a given repository based on its composer.json file. The output includes:
- A Mermaid.js chart visualizing dependencies.
- A markdown file (
DEPENDENCIES.md) containing the chart and a detailed list of dependencies.
- Supports GitHub, GitLab, and Drupal's GitLab instance (
https://git.drupalcode.org). - Dynamically detects the default branch for repositories.
- Fetches and processes
composer.jsonfiles recursively for all dependencies. - Outputs:
- A Mermaid.js graph.
- A markdown file with the chart and a human-readable dependency list.
- Python 3.6+
- Internet access to fetch
composer.jsonfiles and repository information. - The following Python libraries:
requests
- Clone the repository containing this script.
- Ensure Python is installed on your system.
- Install dependencies:
pip install requests
Run the script with the following command:
python dependgen.py <repository_url> [branch]<repository_url>: The URL of the repository (GitHub, GitLab, or Drupal's GitLab instance).[branch](optional): The branch to use. Defaults tomainif not specified.
For a GitHub repository:
python dependgen.py https://github.com/kanopi/saplingsFor a Drupal repository:
python dependgen.py https://git.drupalcode.org/project/seo_checklist 5.2.xThe script creates a DEPENDENCIES.md file in the current working directory. This file contains:
- A Mermaid.js chart of dependencies.
- A detailed list of dependencies with links to their repositories.
graph TB
repo-name((repo-name)) --> dependency-one
repo-name --> dependency-two
- Type: drupal-module
- The script stops execution if a
composer.jsonfile is not found. - Invalid or unsupported URLs will result in an error message and script termination.
- Assumes that all dependencies either reside on GitHub, GitLab, or Drupal's GitLab instance.
- Does not process repositories without a
composer.jsonfile.
Feel free to open issues or submit pull requests to improve the script. Contributions are welcome!
This script is available under the GNU General Public License v3.0. See the LICENSE file for details.
Made with ❤️ on Cape Cod.