npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

print-project

v1.0.21

Published

A simple CLI tool to print the project tree structure and file contents

Downloads

496

Readme

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"

Command Aliases

You can use either print-project or pprint to run the tool:

print-project <startPath> [ignorePatterns]

or

pprint <startPath> [ignorePatterns]

Using Default Ignore Patterns

To use the default ignore patterns, add the --ignore-default flag:

print-project <startPath> --ignore-default

You can also combine default patterns with your own:

print-project <startPath> "your,custom,patterns" --ignore-default

Default Ignore Patterns

The following patterns are ignored by default when using the --ignore-default flag:

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

    or

    pprint ./src
  • Ignore specific patterns:

    print-project ./src "node_modules,*.log,dist,coverage"

    or

    pprint ./src "node_modules,*.log,dist,coverage"
  • Use default ignore patterns:

    print-project ./src --ignore-default

    or

    pprint ./src --ignore-default
  • Use default ignore patterns and add custom ones:

    print-project ./src "*.tmp,*.bak" --ignore-default

    or

    pprint ./src "*.tmp,*.bak" --ignore-default

Features

  • Directory Scanning: Recursively scans the provided directory path.
  • Ignore Patterns: Supports glob patterns to exclude specific files or directories from the output.
  • Default Ignore Patterns: Provides a set of commonly ignored patterns for convenience.
  • 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.
  • Command Alias: Can be run using either print-project or pprint for convenience.

How It Works

  1. Parses the command line arguments for the starting directory path and ignore patterns.
  2. Scans the specified directory, applying the ignore patterns to filter out unwanted files or directories.
  3. Builds a tree structure of the directory and captures file content.
  4. 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.