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

npxd

v1.4.1

Published

Seamless command invocation inside Docker container

Downloads

1,666

Readme

npxd

npx for Docker

npxd <command> is like npx <command> but runs command inside Docker container defined in docker-compose.yml.

The main benefit: seamless command invocation from either host machine or inside container:

  • if invoked from host machine - ensures container is running via docker compose up and runs command via docker compose exec
  • if invoked from inside container - just runs command ¯\_(ツ)_/¯

Usage

  1. Ensure you have docker-compose.yml file in your project
  2. Install npxd (details):
    npm i -D npxd
  3. Prepend package.json scripts with npxd:
    "scripts": {
    -  "test": "mocha test/*.js",
    +  "test": "npxd mocha test/*.js",
    },
  4. Run as usual from your host machine:
    npm test
  5. Check results of command executed in container:
    $ npm test
       
    > npxd mocha test/*.js
       
    Recreating example_app_1 ... done
       
      ✓ should add numbers
       
      1 passing (36ms)

See full example code in example directory.

Installation

There are to installation options:

Install from NPM (recommended)

Installing from npm will add npxd executable to node_modules/.bin of your project. You will be able to use npxd command in package.json scripts.

npm i -D npxd

Install from GitHub

Alternatively you can download script directly from GitHub and store it in your project. It allows you to adopt script for your needs (as it's a few lines of code). But in that case you should invoke it as ./npxd.sh not npxd in package.json scripts.

wget -O npxd.sh https://raw.githubusercontent.com/vitalets/npxd/main/npxd.sh
chmod +x npxd.sh

Passing env variables

This will NOT work:

"scripts": {
  "lint": "FOO=42 npxd eslint ./src"
},

But this will work:

"scripts": {
  "lint": "npxd env FOO=42 eslint ./src"
},

Configuring service name

  • if there is single service in docker-compose.yml, commands will automatically run inside it
  • if there are several services in docker-compose.yml, you should create .npxdrc file containing target service name

Example of .npxdrc that runs commands in my_app service:

my_app

Note: when you install npxd directly from GitHub you may just edit ./npxd.sh to set particular service name.

Usage from cli

When invoked not from package.json scripts section you need to use npx in front of npxd (as it is usual executable inside node_modules/.bin):

$ npx npxd eslint ./src

Or if you installed from GitHub, just run script:

$ ./npxd.sh eslint ./src

License

MIT @ Vitaliy Potapov