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

jsbatchrun

v0.1.0

Published

batchbuild javascript projects

Downloads

4

Readme

jsbatchrun

batchrun javascript commands

npm version License: MIT jsdoc Built with Grunt codecov Build Status dependencies

While grunt.js is a great tool for managing vertical tasks within a project, its capabilities to do the same jobs automated and repeatedly for more than one project are limited.
jsbatchrun is a cli for running horizontal jobs, which means repeatedly calling predefined tasks for a number of projects (directories with a package.json file).
All of jsbatchruns predefined tasks are packaged into 'plugins' which are simply called with options and arguments, that can be passed in to jsbatchrun manually or they can be read from a configuration file or 'generated' on the fly.
Currently all jsbatchrun plugins utilize grunt.js to be platform independent.

content

getting started

install

This guide assumes, that you are familiar with the use of npm.

npm install jsbatchrun --save

prerequisites

jsbatchrun and its plugins utilize grunt plugins.
In case your own projects make use of grunt as well, it's not recommended to install jsbatchrun globally. You might be better off creating a jsbatchrun project.

usage

syntax

All jobs follow one scheme:

# Note: jsbr is an alias for 'jsbatchrun'
> jsbr [command] [options and flags] [--] [ argument, ...]

commands

The first value in the list of process.argv is interpreted as command.
It will be used for looking up a "matching" plugin.

# lookup plugin 'npm'
> jsbr npm

There is (as always) one exception: 'help'
Help is a valid command, but it's no plugin. Instead 'help' is used to invoke help on a plugin (which must be named next in the list of process.argv).

# invoke help on 'nothing' => this will list all registered 'plugins' (aka commands)
> jsbr help

# invoke help on plugin 'npm' => this will list all subcommands of plugin 'npm'
> jsbr help npm

using configuration files

Configuration files provide a way to

--config path

path may be an absolute path to a configuration file or it must be relative to the current working directory (cwd) or (cwd)/.conf/jsbatchrun/

Read more on configuration files (Follow the link)

options and flags

Parsing of options and flags is done by invoking minimist on the 'rest' of process.argv after all commands have been stripped away.

Tip:
Pass in 'flags' (options with no values) first, to avoid interference with arguments or use the "--" switch to signal the end of options and the beginning of arguments to 'minimist'

# will result in args.flag === "path1" and args._ === [ "path2", "path3" ]
> jsbr command subcommand --flag path1 path2 path3

# will result in args.flag === true and args._ === [ "path1", "path2", "path3" ]
> jsbr command subcommand --flag -- path1 path2 path3

injecting options

You might want to look at the list of special options

jsbatchrun aims to reduce manual work with monkeyjobs. Therefor it provides a way to inject options (create them on the fly) with predefined values:

--env:opt:[propertyname]:[optionname]

# in case there is a configfile at 'path1' which provides a property named 'foo'
# that has a value 'douchebag', the following will result in calling the
# 'subcommand' of 'command' with the option --bar "douchebag"
> jsbr command subcommand --env:opt:foo:bar --config path1

# The above would be equal to:
> jsbr command subcommand --bar "douchebag"

This shows its true power in conjunction with jsbatchruns capability to inject arguments from properties, defined in a configuration file.

arguments

All values which are no commands and no options are passed to commands as part of the list of arguments. Simple as that, jsbatchrun provides special options to 'narrow down' or 'widen' the list of arguments.

injecting arguments

You might want to look at the list of special options
jsbatchrun provides three ways of injecting values as arguments.

  1. inject arguments if no arguments are provided via the commandline:

--env:args:use:[propertyname]

# this expects the default configuration file to exist and to provide a
# property named 'directorylist'. All values of 'directorylist' will be
# passed as arguments to subcommand.
> jsbr command subcommand --env:args:use:directorylist

# The following will fail, because arguments are already provided!
> jsbr command subcommand --env:args:use:directorylist -- ~/projects/project-00 ...
  1. append arguments to the list of arguments:

--env:args:append:[propertyname]

# this expects the default configuration file to exist and to provide a
# property named 'directorylist'. All values of 'directorylist' will be
# passed as arguments to subcommand.
> jsbr command subcommand --env:args:append:directorylist

# The following will not fail. All values of 'directorylist' will follow
# after the arguments already provided
> jsbr command subcommand --env:args:append:directorylist -- ~/projects/project-00 ...
  1. prepend arguments to the list of arguments:

--env:args:prepend:[propertyname]

# this expects the default configuration file to exist and to provide a
# property named 'directorylist'. All values of 'directorylist' will be
# passed as arguments to subcommand.
> jsbr command subcommand --env:args:append:directorylist

# All values of 'directorylist' will be inserted before the arguments already
# provided
> jsbr command subcommand --env:args:prepend:directorylist -- ~/projects/project-00 ...

narrowing of arguments

In case your previous command failed with argument (project) no. X in your list of arguments. Would you like to retype your command with the remaining number of n arguments?

To avoid that, arguments can be narrowed, no matter how many arguments have been prepended to, used by or appended to your list of arguments.

You might want to look at the list of special options

  1. Start argument processing at a given position:

--args:from

# this will pass all arguments to subcommand, starting with and including the
# seventh argument, up to the last argument of the list of arguments.
> jsbr command subcommand --args:from 7 --env:args:[type]:[property] [more arguments]

# Note: in case there are less then "7" arguments, nothing will happen ;-)
  1. Stop processing arguments at a given position:

--args:to

# this will pass all arguments to subcommand, starting with the first argument of the
# list of arguments and stopping at but including the seventh argument.
> jsbr command subcommand --args:to 7 --env:args:[type]:[property] [more arguments]

# Note: in case there are less then "7" arguments, only the available number of arguments
#       can and will be processed.
  1. Start and stop processing arguments at a given position:
> jsbr command subcommand --args:from 3 --args:to 7 --env:args:[type]:[property] [more arguments]
  1. Process an argument at a given position:
> jsbr command subcommand --args:index 3 --env:args:[type]:[property] [more arguments]