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

trucker

v1.1.2

Published

Hauls your files around without breaking your imports

Downloads

220

Readme

NPM Version

trucker

Trucker is a tool that helps manage dependencies between javascript files

It has three main functions:

  1. Show all inbound and outbound dependencies for javascript and coffeescript source files. (trucker --info filename.js or trucker -i filename.js)

  2. Move/rename source files while fixing up the paths used in requires. (trucker --move source destination or trucker -m source destination)

  3. Find unused files (files that are not required by any other files). (trucker --unused or trucker -u)

Why is it called trucker? Because it hauls your files around without breaking them.

Support

Languages

  • Javascript, as parsed by babel (up to ES7)

  • Coffeescript

  • Typescript

Module systems

  • CommonJS 6 - i.e. module.exports and require().

  • ECMAScript 6 - i.e. export and import.

  • TypeScript - i.e. export and import.

Installation

npm install -g trucker

Trucker runs on node.js 10 or greater.

Usage

Move files

To move files:

trucker --move [flags] source [additional sources...] destination

Get dependency info about files

To get info about files:

trucker --info [optional file paths]

If no paths are passed, trucker will spit out information for all files in the base path (see options below).

Build a graph of dependencies using graphviz

(experimental)

To get info about files:

trucker --info --format dot [optional file paths]

This will output a graphviz-compatible dot file that can be rendered into an image file by the dot tool that is part of graphviz.

For example:

trucker -i -f dot > ./build/dependencies.dot
dot -Tpng -o ./build/dependencies.png ./build/dependencies.dot
open ./build/dependencies.png

Here's a graph of trucker's internal structure, generated by the following command:

dot -Tsvg -o ./trucker-graph.svg <(trucker --exclude test --exclude examples --info --format dot)

Trucker Graph

Find unused files

Find files that are not required by any other source files in given path

trucker --unused [path]

Examples

in the examples directory (provided), you can try the following (add -n for dry run mode if desired):

  • Get info about all dependencies in the current directory and all sub directories trucker --info

  • Get dependencies for just one subdirectory trucker -i stark/

  • Move a single file: trucker --move stark/eddard.js deceased/

  • Move a single file, specifying destination path: trucker -m stark/eddard.js deceased/ned.js

  • Move multiple files explicitly trucker -m stark/eddard.js tully/catelyn.js deceased/

  • Move a directory: trucker -m stark deceased/stark

  • Paths are automatically created: trucker -m stark/eddard.js deceased/in/book1/

Options

-h, --help prints the help

-n, --dry-run tells trucker not to move any files, but to instead print out a list of all of the changes that would have been made if this option was not set.

-s, --scope can be used to expand or contract the set of files that trucker searches for dependencies. This defaults to the present working directory. If you have a very large project you may wish to constrain the scope for performance reasons (analysis takes time), or in some cases you may wish to expand the scope beyond the current directory. Use --scope for this.

-q, --quiet suppress output

-e, --exclude Add file glob pattern to ignore to those found in the .gitignore file. Repeat this options to add many patterns.

Ignored files

Trucker ignores files using the first .gitignore it finds, starting from the base directory (usually cwd), and ascending to the root.

See too the --exclude option above.

Limitations

Tested on OSX

Should also work on other platforms. Let me know if you have a problem.

require syntax

Trucker only recognizes basic require syntax.

Trucker doesn't recognize this, for example:

var x = '../foo/bar';
var y = require(x);