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

shellboard

v0.0.3

Published

ShellBoard - a simple web server to execute shell commands

Downloads

3

Readme

ShellBoard

npm version build Status Conventional Commits

What is it?

ShellBoard is a simple web server with REST API to execute shell commands for quick monitor or dev automation. The commands are configured statically and not editable outside.

Why?

Sometimes it is need to have an ad-hoc web server:

  • for monitoring a system state by shell commands;
  • for triggering system actions during development or integration testing.

ShellBoard covers urgent needs to automate some actions by triggering HTTP API.

Features

  • Simple configuration;
  • Simple REST API;
  • Optional Basic Authentication for API requests.

Usage

Disclaimer: By default, ShellBoard listen requests only from localhost. It is a responsibility of a server administrator to configure the tool properly and use it securely.

Quick start

Create shellboard.json file in a current directory:

{
  "commands": [
    "echo Hello World!",
    "date"
  ]
}

Start the server:

npx shellboard
# or: yarn shellboard
# or: node node_modules/.bin/shellboard

Trigger API endpoints:

# List commands
curl http://localhost:3000/api/commands
{"commands":["echo Hello World!","date"]}

# Execute a command
curl -X POST http://localhost:3000/api/commands/0
{"command":"echo Hello World!","exitStatus":0,"stdout":"Hello World!\n","stderr":""}

curl -X POST http://localhost:3000/api/commands/1
{"command":"date","exitStatus":0,"stdout":"Sat Jan 19 21:56:30 +07 2019\n","stderr":""}

Installation

ShellBoard can be installed as a global tool:

npm install --global shellboard

As a development dependency of a project:

npm install --save-dev --save-exact shellboard
# or:  yarn add --dev --exact shellboard

ShellBoard can be run without installation using npx command of npm:

npx shellboard

Configuration

ShellBoard is configured by environment variables and a configuration file.

Environment variables

The tool uses dotenv library to optionally load environment variables from .env file in a current working directory. See .env.defaults file as an example.

Variables and default values:

  • SHELLBOARD_CONFIG – A path to a configuration file. Default value: shellboard.json.
  • SERVER_HOST – Configures HTTP server to listen a specified network interface. Default value: localhost. To accept external requests from all network interfaces set it to 0.0.0.0.
  • SERVER_PORT – Configures HTTP server to listen a specified port. Default value: 3000.
  • HTTP_LOG_FORMAT – Defines a log format for HTTP requests. Default value: common. Other values: combined, common, dev, short, tiny. Check documentation of morgan library to define custom formats.
  • BASIC_AUTH – Enables Basic Authentication for API endpoints if it is specified. Value format: username:password.

Configuration file

By default ShellBoard looks for shellboard.json file in a current working directory. File path can be changed by SHELLBOARD_CONFIG environment variable.

This file declares an array of shell commands which will be available via API.

{
  "commands": [
    "ls",
    "free -h",
    "df -u ."
  ]
}

See shellboard-example.json as an example.

REST API

GET /api/commands

Returns a list of available commands.

Response:

{
  "commands": [
    "echo Hello World!",
    "date"
  ]
}

GET /api/commands/:index

Returns details about a command specified by an index of commands list.

Response:

{
  "command": "echo Hello World!"
}

POST /api/commands/:index

Executes a command specified by an index of commands list.

Response:

{
  "command": "echo Hello World!",
  "exitStatus": 0,
  "stdout": "Hello World!\n", 
  "stderr": ""
}

Development

Yarn is used as package and build manager.

Development scripts:

  • yarn start – runs a development server in watching mode.
  • yarn lint – checks source code by static analysis tools.
  • yarn test – runs unit tests.
  • yarn check-format – check formats of source code.
  • yarn format – formats source code by prettier tool.
  • yarn check-commit – runs all necessary checks, tests and builds to ensure the commit will be green.

Build scripts:

  • yarn build – compiles sources.
  • yarn dist – makes an app bundle in /dist directory.

Release (for maintainers):

git checkout master; git pull origin master
yarn check-commit
yarn dist-build
yarn check-release
yarn release
git push --follow-tags origin master
npm publish

License

MIT