{"id":23379255,"url":"https://github.com/caiquegaspar/directory-tree-generator","last_synced_at":"2025-04-08T05:51:07.163Z","repository":{"id":268952712,"uuid":"905970796","full_name":"caiquegaspar/directory-tree-generator","owner":"caiquegaspar","description":"A Bash script that generates a directory tree structure of a project, while ignoring files and folders listed in the .gitignore file.","archived":false,"fork":false,"pushed_at":"2025-01-22T19:58:22.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T04:18:27.826Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caiquegaspar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-19T22:11:09.000Z","updated_at":"2025-01-22T19:58:27.000Z","dependencies_parsed_at":"2025-01-10T23:22:50.725Z","dependency_job_id":"7008c171-d92f-4554-b255-065b4feeb058","html_url":"https://github.com/caiquegaspar/directory-tree-generator","commit_stats":null,"previous_names":["caiquegaspar/directory-tree-generator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiquegaspar%2Fdirectory-tree-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiquegaspar%2Fdirectory-tree-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiquegaspar%2Fdirectory-tree-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiquegaspar%2Fdirectory-tree-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caiquegaspar","download_url":"https://codeload.github.com/caiquegaspar/directory-tree-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247785942,"owners_count":20995644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T19:17:20.143Z","updated_at":"2025-04-08T05:51:07.137Z","avatar_url":"https://github.com/caiquegaspar.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Directory Tree Generator\n\nThis is a Bash script that generates a directory tree structure of a project, similar to the `tree` command, but with enhanced functionality. It respects files and directories listed in `.gitignore` and `.generatetreeignore`. The generated structure is saved in a file called `project_structure.txt`. Additionally, you can optionally include the contents of the listed files in the output and enable a debug mode for detailed script execution.\n\n## Download\n\nYou can download directly using the link below:\n\n- [Download File](https://github.com/caiquegaspar/directory-tree-generator/releases/download/v1.0.0/generate_tree.sh)\n\n## Features\n\n- **Ignores files and directories**: Respects patterns specified in `.gitignore` and `.generatetreeignore`.\n- **Custom ignore rules**: Allows additional exclusion rules via `.generatetreeignore`.\n- **Generates directory tree**: Creates a hierarchical directory structure.\n- **Output to file**: Saves the generated structure to `project_structure.txt`.\n- **File contents (optional)**: Includes the contents of each file in the directory structure with the `--print-content` parameter.\n- **Debug mode (optional)**: Provides detailed script execution messages using the `--debug` parameter.\n\n## How to Use\n\n### Prerequisites\n\n- Bash environment (Linux, macOS, or Git Bash on Windows).\n- A `.gitignore` or `.generatetreeignore` file to define ignored files and directories (optional).\n\n### Steps\n\n1. Place the `generate_tree.sh` script in the root directory of your project.\n2. Run the script:\n\n   ```bash\n   chmod +x generate_tree.sh\n\n   ./generate_tree.sh\n   ```\n\n3. The generated structure will be saved in `project_structure.txt`.\n\n   - To include file contents, use the `--print-content` argument:\n\n     ```bash\n     ./generate_tree.sh --print-content\n     ```\n\n   - To enable debug mode and see detailed script execution messages, use the `--debug` argument:\n\n     ```bash\n     ./generate_tree.sh --debug\n     ```\n\n   - You can combine both `--print-content` and `--debug` arguments. The order does not matter:\n\n     ```bash\n     ./generate_tree.sh --print-content --debug\n     ```\n\n     or\n\n     ```bash\n     ./generate_tree.sh --debug --print-content\n     ```\n\n### Using `.generatetreeignore`\n\nTo add custom exclusions beyond `.gitignore`, create a `.generatetreeignore` file in the root of your project. The syntax is the same as `.gitignore`.\n\n#### Example `.generatetreeignore` File:\n\n```bash\n# Ignore all `.log` files\n*.log\n\n# Ignore specific folders\ntemp/\n```\n\nPatterns in `.generatetreeignore` will be processed in addition to `.gitignore`.\n\n### Example Output\n\n#### Without `--print-content` and `--debug`\n\nThe `project_structure.txt` file will contain a directory structure similar to:\n\n```\n--- 📁 Project Structure ---\n\n/\n├── .github/\n│   └── workflows/\n│       └── docker-image.yml\n├── docker/\n│   ├── Dockerfile\n│   └── start.sh\n├── prisma/\n│   ├── migrations/\n│   │   └── 0001_initial/\n│   │   │   └── migration.sql\n│   └── schema.prisma\n...\n```\n\n#### With `--print-content`\n\nRunning the script with `--print-content` will append the contents of each file listed in the structure:\n\n```\n--- 📁 Project Structure ---\n\n/\n├── .github/\n│   └── workflows/\n│       └── docker-image.yml\n├── docker/\n│   ├── Dockerfile\n│   └── start.sh\n├── prisma/\n│   ├── migrations/\n│   │   └── 0001_initial/\n│   │   │   └── migration.sql\n│   └── schema.prisma\n...\n\n--- 📄 File Contents ---\n\n--- File: .github/workflows/docker-image.yml ---\n\nname: Docker Image CI\n\non:\n  push:\n    branches:\n      - \"**\"\n  pull_request:\n    branches:\n      - \"**\"\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout Repository\n        uses: actions/checkout@v4\n\n      - name: Set up Docker Buildx\n        uses: docker/setup-buildx-action@v3\n\n      - name: Build Docker Image\n        run: docker buildx build --file docker/Dockerfile --tag my-project-image:${{ github.sha }} --tag my-project-image:latest --load .\n```\n\n#### With `--debug`\n\nRunning the script with `--debug` will output detailed messages about the script's execution in your terminal, such as loaded ignore patterns and file matching processes. This output will appear alongside the regular output unless redirected.\n\n### How It Works\n\n1. **Loading Ignore Patterns**:\n\n   - Loads exclusion patterns from `.gitignore` and `.generatetreeignore`.\n   - Combines patterns from both files for a unified exclusion list.\n\n2. **Exclusion Check**:\n\n   - Each file and directory is checked against the combined list of patterns to determine if it should be ignored.\n\n3. **Generating the Directory Tree**:\n\n   - Recursively scans the directory structure to create a hierarchical tree.\n\n4. **Saving the Output**:\n\n   - The directory tree is saved in `project_structure.txt`.\n\n5. **Including File Contents (Optional)**:\n\n   - If `--print-content` is specified, the contents of non-ignored files are appended to the output.\n\n6. **Debug Mode (Optional)**:\n   - If `--debug` is specified, detailed messages about the script's execution are printed to the console.\n\n## Contributing\n\nContributions are welcome! Feel free to open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiquegaspar%2Fdirectory-tree-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaiquegaspar%2Fdirectory-tree-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiquegaspar%2Fdirectory-tree-generator/lists"}