All Projects → jamiebuilds → Scritch

jamiebuilds / Scritch

Licence: mit
A small CLI to help you write sharable scripts for your team

Programming Languages

javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects
bash
514 projects
scripting
82 projects

Projects that are alternatives of or similar to Scritch

Mbt
The most flexible build tool for monorepo
Stars: ✭ 184 (+148.65%)
Mutual labels:  build, cli
Zeus
An Electrifying Build System
Stars: ✭ 176 (+137.84%)
Mutual labels:  scripts, build
Mhy
🧩 A zero-config, out-of-the-box, multi-purpose toolbox and development environment
Stars: ✭ 128 (+72.97%)
Mutual labels:  build, cli
article
It’s Your Life. Share it. Celebrate it. Build it. AND HAVE FUN!
Stars: ✭ 33 (-55.41%)
Mutual labels:  share, build
defold-deployer
Universal build && deploy script for Defold projects
Stars: ✭ 23 (-68.92%)
Mutual labels:  build, scripts
Bashmultitool
A library for bash shell program containing useful functions. Can be imported into scripts to create colourful and functional scripts and TUIs.
Stars: ✭ 27 (-63.51%)
Mutual labels:  scripts, cli
Nps
NPM Package Scripts -- All the benefits of npm scripts without the cost of a bloated package.json and limits of json
Stars: ✭ 1,285 (+1636.49%)
Mutual labels:  scripts, cli
Examples
An complete examples and related support for various popular projects, and more.
Stars: ✭ 22 (-70.27%)
Mutual labels:  build, scripts
vsSolutionBuildEvent
🎛 Event-Catcher with variety of advanced Actions to service projects, libraries, build processes, runtime environment of the Visual Studio, MSBuild Tools, and …
Stars: ✭ 66 (-10.81%)
Mutual labels:  build, scripts
U3d
U3d is a cross-platform set of tools to interact with Unity3D from command line.
Stars: ✭ 309 (+317.57%)
Mutual labels:  build, cli
Npm Build Boilerplate
A collection of packages that build a website using npm scripts.
Stars: ✭ 963 (+1201.35%)
Mutual labels:  build, cli
Angular Cli Webpack
Webpack configuration modifier for @angular/cli
Stars: ✭ 72 (-2.7%)
Mutual labels:  cli
Vbb Cli
A CLI for Berlin & Brandenburg public transport.
Stars: ✭ 70 (-5.41%)
Mutual labels:  cli
Cols Agent Tasks
Colin's ALM Corner Custom Build Tasks
Stars: ✭ 70 (-5.41%)
Mutual labels:  build
Elasticsearch Cli
Command line interface for ElasticSearch
Stars: ✭ 70 (-5.41%)
Mutual labels:  cli
Github Files Fetcher
Download a specific folder or file from a GitHub repo through command line
Stars: ✭ 73 (-1.35%)
Mutual labels:  cli
Conget
A CLI app for downloading file concurrently.
Stars: ✭ 72 (-2.7%)
Mutual labels:  cli
The forge
Our groundbreaking, lightning fast PWA CLI tool
Stars: ✭ 70 (-5.41%)
Mutual labels:  cli
Homebrew Gh
Homebrew tap for the GitHub CLI
Stars: ✭ 70 (-5.41%)
Mutual labels:  cli
Hopp Doc Gen
📔 API documentation generator CLI for https://hoppscotch.io
Stars: ✭ 70 (-5.41%)
Mutual labels:  cli

Scritch

Easily create a tiny CLI to help you write sharable scripts for your team

  • Write scripts in any scripting language (JavaScript, Bash, Python, etc)
  • Share your scripts as a CLI via npm
  • Depend on other CLIs/libraries distributed via npm
  • Injects useful environment variables into your script
  • Strips ANSI escape codes in CI

Install

npm install scritch

Guide

Create a new npm package:

git init company-cli && cd company-cli
npm init

Create a cli.js file and call Scritch inside:

#!/usr/bin/env node
require('scritch')(__dirname)

Then make it executable:

chmod +x ./cli.js

Add cli.js as your package.json#bin:

{
  "bin": "./cli.js"
}

Next create a scripts folder:

mkdir scripts

Then start adding scripts in your favorite scripting language:

touch scripts/build.sh
#!/bin/sh
set -e

start=$(date +%s)
echo "Building files..."

for i in $(seq 1 10); do
  sleep 0.1
  echo "- File $i built."
done

end=$(date +%s)
total=$((end-start))

echo "10 files built in $((total))s."

When you're done, make sure all the scripts you write are executable:

chmod +x ./scripts/*

Usage

Package Structure

Your package structure should look like this:

/company-cli/
  package.json
  cli.js (executable)
  /scripts/
    build.sh (executable)
    lint.js (executable)
    test.py (executable)

Note: Scripts inside of scripts/* can be written in any scripting language.

In order to make the appropriate files executable you can run:

chmod +x ./cli.js
chmod +x ./scripts/*

Your package.json file should have the following fields:

{
  "name": "company-cli",
  "version": "1.0.0",
  "description": "Our company's CLI",
  "bin": "cli.js",
  "dependencies": {
    "scritch": "*"
  }
}

API Usage

The simplest usage of scritch is the following cli.js file:

#!/usr/bin/env node
require('scritch')(__dirname)

But scritch accepts other options:

#!/usr/bin/env node
require('scritch')(__dirname, {
  // An alternate path to where your scripts are located
  scriptsPath: 'build/scripts',

  // Additional help content, great for examples
  help: `
    Examples
      Build all files:
      $ company-cli build

      Lint all files:
      $ company-cli lint

      Run all tests:
      $ company-cli test
  `,
  // Additional environment variables you would like to pass to all scripts
  env: {
    HELPER_ENV_VARIABLE: 'some value'
  }
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].