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

enex

v0.0.6

Published

A minimalist command runner for npm packages, with a focus on developer ergonomics.

Downloads

28

Readme

A minimalist command runner for npm packages, with a focus on developer ergonomics.

 ______    __    __    ______    __  __
/\  ___\  /\ `. /\ \  /\  ___\  /\_\_\_\
\ \  ___\ \ \  `. \ \ \ \  ___\ \/_/\_\/_
 \ \_____\ \ \_\ `.\_\ \ \_____\  /\_\/\_\
  \/_____/  \/_/  \/_/  \/_____/  \/_/\/_/  n(pm) execute

shellcheck latest release npm package license

enex lets you interact with any NPM package — that is, anything with a package.json — in as few keystrokes as you want (or as possible!). It's eminently configurable, but with a default setup of source $HOME/enex/enex.sh in your dotfile of choice, it will add these aliases to any shell:

n <cmd>     ->  npm <cmd> OR npm run <cmd> # enex intelligently adds `run`
                                           # only when necessary, but you
ns <opts>   ->  npm run start <opts>       # may use it if you prefer
nb <opts>   ->  npm run build <opts>
nf <opts>   ->  npm run format <opts>
nt <opts>   ->  npm run test <opts>
ntw <opts>  ->  npm run test -- --watch <opts>

ni <opts>   ->  npm install <opts>
nu <opts>   ->  npm uninstall <opts>
nis <opts>  ->  npm install --save <opts>
nus <opts>  ->  npm uninstall --save <opts>
nid <opts>  ->  npm install --save-dev <opts>
nud <opts>  ->  npm uninstall --save-dev <opts>

enex is only 60 lines of code (with comments!) — if you're interested in knowing exactly what will be running on your system, peruse it here. Any project that touts minimalism should strive to be understood completely within a few minutes; this is, and will remain, a goal of enex.

Setup

npm install -g enex
which enex
> /some/path/to/node_modules/.bin/enex.sh

# add to your .bashrc / .zshrc / etc. ->
source "/some/path/to/node_modules/.bin/enex.sh"

Or if you prefer, install by checking out the repository manually:

git clone https://github.com/evnp/enex.git

# add to your .bashrc / .zshrc / etc. ->
source "$HOME/enex/enex.sh"

# or if you didn't check the repository in $HOME directory:
source "/your/path/to/repository/enex/enex.sh"

Open a new shell instance and enex will have initialized these aliases:

alias n="enex"  # -> contextually equivalent to `npm ...` or `npm run ...`

alias ns="enex start"      # -> npm start
alias nt="enex test"       # -> npm test; also ntw -> npm run test -- --watch
alias nb="enex build"      # -> npm run build
alias nf="enex format"     # -> npm run format
alias ni="enex install"    # -> npm install
alias nu="enex uninstall"  # -> npm uninstall
# also nis, nid, nus, nud for install/uninstall --save/--save-dev combinations, see above

If you'd like to opt out of these default aliases or customize them, use env vars when initializing enex to configure:

# to opt out of `n` alias and simply use the full command `enex`:
ENEX_COMMAND=0 source "$HOME/enex/enex.sh"

# to opt out of enex aliasing altogether:
ENEX_COMMAND=0 ENEX_ALIASES=0 source "$HOME/enex/enex.sh"

# to use the custom command `myencmd` to invoke enex instead of `n`:
ENEX_COMMAND=myencmd source "$HOME/enex/enex.sh"
> alias myencmd="enex"

# to define your own custom set of enex aliases:
ENEX_ALIASES=build,push,deploy source "$HOME/enex/enex.sh"
> alias n="enex"
> alias nb="enex build"
> alias np="enex push"
> alias nd="enex deploy"
# note: this overrides the set of default aliases entirely, so you
#       will need to redefine them explicitly if some are desired

By default, if enex does not detect a package.json file within the directory it is being invoked from, it will search for one within directories up to 2 levels below, and arbitary levels above, exiting immediately if it reaches your home directory. This allows you to run enex commands from anywhere within a project with this very common directory structure, or similar project structures:

$HOME/
 └─project/
   ├─backend/
   │ └─dir/
   └─frontend/
     ├─src/
     └─dir/

Normally, you'd need to first navigate to the frontend/ before invoking any npm command; enex handles this step invisibly for you in a subshell, so that you remain in the same directory you started in after the operation is complete.

If for any reason you prefer to skip this "auto-find" step, add the following env var to your enex configuration:

ENEX_FIND=0 source "$HOME/enex/enex.sh"

While sorting out configuration, it may be useful to have enex output the complete set of aliases that are generated when a new shell session begins. To do so, add:

ENEX_VERBOSE=1 source "$HOME/enex/enex.sh"

That's it!

License

MIT