{"id":13602806,"url":"https://github.com/jamiebuilds/scritch","last_synced_at":"2025-03-15T13:31:15.452Z","repository":{"id":41081576,"uuid":"168433070","full_name":"jamiebuilds/scritch","owner":"jamiebuilds","description":"A small CLI to help you write sharable scripts for your team","archived":false,"fork":false,"pushed_at":"2022-06-28T09:49:09.000Z","size":27,"stargazers_count":85,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T21:02:52.000Z","etag":null,"topics":["bash","bin","build","cli","javascript","python","scripting","scripts","share","shell"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamiebuilds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-30T23:46:20.000Z","updated_at":"2024-07-09T15:48:47.000Z","dependencies_parsed_at":"2022-09-26T21:10:39.439Z","dependency_job_id":null,"html_url":"https://github.com/jamiebuilds/scritch","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Fscritch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Fscritch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Fscritch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Fscritch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamiebuilds","download_url":"https://codeload.github.com/jamiebuilds/scritch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735843,"owners_count":20339536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bin","build","cli","javascript","python","scripting","scripts","share","shell"],"created_at":"2024-08-01T18:01:38.504Z","updated_at":"2025-03-15T13:31:14.997Z","avatar_url":"https://github.com/jamiebuilds.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","cli"],"sub_categories":[],"readme":"# Scritch\n\n\u003e Easily create a tiny CLI to help you write sharable scripts for your team\n\n- Write scripts in any scripting language (JavaScript, Bash, Python, etc)\n- Share your scripts as a CLI via npm\n- Depend on other CLIs/libraries distributed via npm\n- Injects useful environment variables into your script\n- Strips ANSI escape codes in CI\n\n## Install\n\n```sh\nnpm install scritch\n```\n\n## Guide\n\nCreate a new npm package:\n\n```sh\ngit init company-cli \u0026\u0026 cd company-cli\nnpm init\n```\n\nCreate a `cli.js` file and call Scritch inside:\n\n```sh\n#!/usr/bin/env node\nrequire('scritch')(__dirname)\n```\n\nThen make it executable:\n\n```sh\nchmod +x ./cli.js\n```\n\nAdd `cli.js` as your `package.json#bin`:\n\n```json\n{\n  \"bin\": \"./cli.js\"\n}\n```\n\nNext create a `scripts` folder:\n\n```sh\nmkdir scripts\n```\n\nThen start adding scripts in your favorite scripting language:\n\n```sh\ntouch scripts/build.sh\n```\n\n```sh\n#!/bin/sh\nset -e\n\nstart=$(date +%s)\necho \"Building files...\"\n\nfor i in $(seq 1 10); do\n  sleep 0.1\n  echo \"- File $i built.\"\ndone\n\nend=$(date +%s)\ntotal=$((end-start))\n\necho \"10 files built in $((total))s.\"\n```\n\nWhen you're done, make sure all the scripts you write are executable:\n\n```sh\nchmod +x ./scripts/*\n```\n\n## Usage\n\n### Package Structure\n\nYour package structure should look like this:\n\n```\n/company-cli/\n  package.json\n  cli.js (executable)\n  /scripts/\n    build.sh (executable)\n    lint.js (executable)\n    test.py (executable)\n```\n\n\u003e **Note:** Scripts inside of `scripts/*` can be written in any scripting\n\u003e language.\n\nIn order to make the appropriate files executable you can run:\n\n```sh\nchmod +x ./cli.js\nchmod +x ./scripts/*\n```\n\nYour `package.json` file should have the following fields:\n\n```json\n{\n  \"name\": \"company-cli\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Our company's CLI\",\n  \"bin\": \"cli.js\",\n  \"dependencies\": {\n    \"scritch\": \"*\"\n  }\n}\n```\n\n### API Usage\n\nThe simplest usage of scritch is the following `cli.js` file:\n\n```js\n#!/usr/bin/env node\nrequire('scritch')(__dirname)\n```\n\nBut scritch accepts other options:\n\n```js\n#!/usr/bin/env node\nrequire('scritch')(__dirname, {\n  // An alternate path to where your scripts are located\n  scriptsPath: 'build/scripts',\n\n  // Additional help content, great for examples\n  help: `\n    Examples\n      Build all files:\n      $ company-cli build\n\n      Lint all files:\n      $ company-cli lint\n\n      Run all tests:\n      $ company-cli test\n  `,\n  // Additional environment variables you would like to pass to all scripts\n  env: {\n    HELPER_ENV_VARIABLE: 'some value'\n  }\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiebuilds%2Fscritch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamiebuilds%2Fscritch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiebuilds%2Fscritch/lists"}