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

dep-list-cli

v1.0.0

Published

[![npm version](https://img.shields.io/npm/v/dep-list-cli.svg)](https://www.npmjs.com/package/dep-list-cli) [![license](https://img.shields.io/npm/l/dep-list-cli.svg)](https://github.com/LayerDynamics/dep-list-cli/blob/main/LICENSE)

Downloads

68

Readme

dep-list-cli

npm version license

A CLI tool to list npm packages used in your project files. It scans your JavaScript and TypeScript files to extract dependencies, categorizes them into regular and dev dependencies, and outputs them in a readable format or as npm install commands.

Table of Contents

Features

  • Scans JavaScript (.js, .jsx) and TypeScript (.ts, .tsx) files.
  • Extracts dependencies from import, require, and dynamic imports.
  • Categorizes dependencies into regular and dev dependencies.
  • Respects .gitignore and internal ignore patterns.
  • Outputs dependencies in a readable list or as npm install commands.
  • Supports monorepos with multiple package.json files.

Installation

You can install dep-list-cli globally using npm:

npm install -g dep-list-cli

Or use it directly with npx without installation:

npx dep-list-cli

Usage

Basic Usage

Run the CLI in the root directory of your project:

dep-list-cli

This will output the dependencies found in your project files, categorized into regular and dev dependencies.

As NPM Install Commands

If you want the output as npm install commands, use the --command or -c option:

dep-list-cli --command

This will output commands that you can run to install the dependencies:

npm install package1 package2
npm install -D dev-package1 dev-package2

Using NPX

You can use dep-list-cli without installing it globally by using npx:

npx dep-list-cli

Or with the --command option:

npx dep-list-cli --command

Examples

Example 1: Basic Usage

Running dep-list-cli in a project:

dep-list-cli

Output:

Project: my-awesome-project
Regular Dependencies:
- express
- mongoose
- react
- redux

Dev Dependencies:
- jest
- eslint

Example 2: Output as NPM Install Commands

Running dep-list-cli with the --command option:

dep-list-cli --command

Output:

Project: my-awesome-project
Regular Dependencies:
 npm install express mongoose react redux

Dev Dependencies:
 npm install -D jest eslint

Example 3: Using NPX

Using npx to run the CLI without installation:

npx dep-list-cli --command

Output:

Project: my-awesome-project
Regular Dependencies:
 npm install express mongoose react redux

Dev Dependencies:
 npm install -D jest eslint

How It Works

  1. Scanning Files:

    • The tool scans all .js, .jsx, .ts, and .tsx files in your project directories, excluding those specified in .gitignore and internal ignore patterns (like node_modules, dist, etc.).
  2. Extracting Dependencies:

    • It parses each file's Abstract Syntax Tree (AST) to find dependencies imported using import, require, and dynamic imports.
  3. Categorizing Dependencies:

    • Dependencies are categorized into:
      • Regular Dependencies: Used in your application's main code.
      • Dev Dependencies: Used in development files like tests and scripts.
  4. Outputting Results:

    • The tool outputs the dependencies either as a list or as npm install commands, depending on the options used.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository: LayerDynamics/dep-list-cli
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Create a new Pull Request

For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.


If you have any questions or need assistance, feel free to contact the author:

Happy coding!