Print-Project
The print-project
command-line tool scans a specified directory and generates a report including the tree structure and content of files that do not match given ignore patterns. It is useful for documenting or analyzing the file layout of projects, especially in development environments.
Installation
You can install print-project
using npm:
npm install -g print-project
Ensure you have Node.js installed on your machine to use this package.
Usage
After installation, the print-project
tool can be run from the command line.
Basic Command
print-project <startPath> [ignorePatterns]
<startPath>
: Required. The path to the directory you want to scan.
e.g., /path/to/project
[ignorePatterns]
: Optional. A comma-separated list of glob patterns to ignore files and directories.
e.g., "node_modules,*.log,dist,coverage,documentation,.prettierrc,.gitignore,dist,scripts,.serverless,.idea,.git,.DS_Store,.husky,package-lock.json"
Examples
-
Print all files and directories:
print-project ./src
-
Ignore specific patterns:
print-project ./src "node_modules,*.log,dist,coverage,documentation,.prettierrc,.gitignore,dist,scripts,.serverless,.idea,.git,.DS_Store,.husky,package-lock.json"
This will ignore all directories and files matching the node_modules
folder and any files ending with .log
.
Features
- Directory Scanning: Recursively scans the provided directory path.
- Ignore Patterns: Supports glob patterns to exclude specific files or directories from the output.
- Output Generation: Creates a text file
project-print.txt
in the current working directory containing:
- The structured list of non-ignored files and directories.
- The content of non-empty files.
How It Works
- Parses the command line arguments for the starting directory path and ignore patterns.
- Scans the specified directory, applying the ignore patterns to filter out unwanted files or directories.
- Builds a tree structure of the directory and captures file content.
- Outputs the directory structure and file content into
project-print.txt
.
Output File Format
The output project-print.txt
includes:
- File Structure: A tree showing the organization of files and directories.
- Project Print: Actual content of non-empty files within the project directory.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome. Please open an issue first to discuss what you would like to change, or directly submit a pull request.