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

commands-runner

v1.1.4

Published

a cli tool to run a bunch of commands command

Downloads

10

Readme

commands-runner

npm npm David GitHub issues

commands-runner is a cli tool to run commands that can be used to any thing

YOU MUST READ THIS IMPORT_NOTES

like creating a command to realise something or whatever

if you have issues, miss-understanding, questions or recommendation post an issue here

installation

via npm:

npm i -g commands-runner

NOTE: don't install this module with yarn

how to use

first create a file with you commandName followed by .cmr.json

.cmr.json files should follow the Commands type bellow:

interface Option {
  title: string; // the title of the option (required)
  // NOTE: you must provide one of this properties
  script?: string; // the node file you want to run (optional)
  template?: string; // the template zip file you want to extract (optional)
  commands?: commandItem[]; // the commands you want to run (optional)
}
interface AskItem {
  ask: string; // the question
  multiple?: boolean; // if you want to make the user able to choose multiple items
  options: Option[]; // the options
}
interface TemplateItem {
  template: string; // the template zip file you want to extract (required)
}
interface ScriptItem {
  script: string; // the script you want to run (required)
  scriptName: string; // ignore this
}
type commandItem = string | ScriptItem | TemplateItem | AskItem;

type Commands = commandItem | commandItem[];

example 1:

making a command that do the following

  1. creating a git repo
  2. making some template
  3. running a file called foo.js
[
  "git init", // running git init
  {
    template: "./template.zip", // extracting a file called template.zip
  },
  {
    script: "./print_hello_world.js", // running print_hello_world.js
  },
];

NOTE: the file name should include the extension (.cmr.json)

  1. run commands-runner add $fileName
  2. run commands-runner start $fileName

and it will run the commands as needed

example 2: for providing a list for the user to choose what to do

[
  {
    ask: "choose something from the following", // the qeustion you want to ask
    multiple: true, // if true make the user able to choose multiple options
    options: [
      // the options
      {
        title: "extract the template", // the title of the option
        template: "./template.zip", // to extract a template
      },
      {
        title: "run a file",
        script: "foo.js", // to run a js file
      },
      {
        title: "run some commands",
        commands: [
          // to run some commands
          "echo hello world",
          { script: "bar.js" },
          // ...
        ],
      },
    ],
  },
];

example 3: for using value option

{
  "ask": "what's the type of sandwich you want?", // the question
  "multiple": true, // if you want to make the user able to use multiple options
  "options": [ // the options
    {
      "title": "hot dog", // the title of the option
      "value": "hot dog" // the value of it
    },
    {
      "title": "cheese burger",
      "value": "cheese burger"
    },
    {
      "title": "chicken burger",
      "value": "cheese burger"
    }
  ],
  "script": "./script.js" // the script you want to run after user choses options
}

when a user a select an option it will be passed in to the script as process arguments

if you use multiple it will be a JSON.stringifyed array

for example:

// script.js
console.log(process.argv[2]); // will console log the value of  option user selected

important-Notes

  1. the script name of any of the commands should include the extension (.cmr.json)

  2. when you use a script it get bundled so you probably won't be able to use any resources except json files (this might change in future versions)

  3. any template or script name changes to a random hash

cli

you can use commands-runner or cmr to run this commands

start

start <script>

starts a script you already installed

add

add <script>

adds a script of commands for you to be able to use

delete

delete <script>

delete a script from the installed script

overwrite

overwrite <scriptToOverWrite> <script>

overwrite an installed script

config

config

a command to run the configuration file with VSCode

the config file should follow the type Config below:

import { Spinner, SpinnerName } from "cli-spinners";

interface Config {
  "spinner-options": {
    spinner: SpinnerName | Spinner;
    color: string;
    indent: number;
    indentBeforeOutput: number;
    succeedColor: string;
    failColor: string;
  };
  "install-path": string; // the installation path
}

install-path

the path you want to install your script

the default is your home directory + "/commands-runner"

spinner-options

the spinner options

spinner

the spinner you want to choose for example: dots or ``runner`

@default dots

color

the color of the spinner while it's running

it could be any valid chalk color

@default cyan

indent

indent the spinner with a given number of spaces

@default 0

indentBeforeOutput

indent the output of the command or script you're running with a given number of spaces

@default 3

succeedColor

the color of the spinner when it's done successfully

@default green

failColor

the color of the spinner when it fails

@default red

License

MIT License

Copyright (c) 2019 AliBasicCoder