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

scripts-cli

v2.2.2

Published

CLI to run package json scripts and any other scripts in an npm project.

Downloads

136

Readme

Scripts CLI

This package aims to take out the step of remembering all of the scripts in your package.json file and remove the need to put all utility scripts into package.json.

Example use

Installation

npm

npm install --save-dev scripts-cli

yarn

yarn add --dev scripts-cli

Config

By default scripts-cli will include all scripts in package.json. By selecting a script in package.json it will run:

npm run <selected script>

In order to change the behaviour of package.json scripts and add any other scripts for the project you can create a .scriptscli.config.mjs file.

type Options =
  | {
      args?: boolean
      argumentsLabel?: string
      exec?: string
    }
  | {
      options: Options
    }

type Config = {
  exclude: string[]
  options: Options
}

For each option entry you can provide the following:

| key | description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | args | default ( false ). When true the cli will allow arguments to be provided and passed to final command. | | argsLabel | default ( Arguments ). When provided this will be used in the CLI as a label for the arguments input. | | options | default ( {} ). This allows for nested options. The object supplied has the same options as the top level. | | exec | default ( undefined ). For a script in package.json if a value is provided here it will override the script. This string will be provided to the shell to run. |

Example Package.json

{
  "scripts": {
    "test": "echo \"Running tests\"",
    "dev": "ts-node . -w",
    "db:migrate:latest": "echo \"Running latest migrations\"",
    "db:create:migration": "echo \"Creating migration$1\"",
    "scripts": "scripts-cli"
  }
}

Example .scriptscli.config.json

/** @type { import("scripts-cli").Config } */

export default {
  // This list will exclude scripts with this name from being added at the top level by default.
  // Adding them manually to the options will allow them to still be selected.
  // excludes can also be globs where a single `*` is treated as a wildcard
  exclude: ['scripts', 'db:*'],
  // These are the options to be presented.
  // For package.json scripts the key needs to be the same as in package.json
  options: {
    test: {
      args: true, // This will ask the user to provide arguments then run 'npm run test' followed by any provided arguments.
    },
    'Create test file': {
      args: true, // This will ask the user for any arguments
      argsLabel: 'File name', // This will be the label used when asking for arguments input.
      exec: './scripts/create-testfile.sh', // This will then run ./script/create-testfile.sh followed by any arguments provided.
    },
    db: {
      options: {
        // This will mean whenever 'db' is selected from the list nothing will be run
        // but a new list consisting of 'create migration' and 'db:migrate:latest' will show.
        'create migration': {
          args: true,
          exec: 'npm run db:create:migration',
        },
        'db:migrate:latest': {}, // As this key matches a script in package.json selecting this will run 'npm run db:migrate:latest'
      },
    },
  },
}