Skip to content

mountain-pass/hooked

Repository files navigation

🪝🪝 @mountainpass/hooked (aka "j") 🪝🪝

Install

npm i -g @mountainpass/hooked-cli

If cached, you may need to force download:

npm i -g --prefer-online --force @mountainpass/hooked-cli

Rationale

I want to be able to setup advanced build server scripts, that can be run:

  • by anyone
  • with no project knowledge
  • anywhere (locally or remotely)
  • anytime

When executing the scripts, it must be:

  • consistent
  • intuitive
  • forgiving
  • suggestive
  • simple

Existing tools

🔨 tool 🔨 🚨 cons 🚨 ✅ pros ✅
NPM
  • not cli discoverable
  • primarily a package manager
  • scripting changes affects (docker) build caching
  • scripting has to be escaped (json)
  • cannot do multiline scripts
  • has access to self install cli tools
Makefile
  • not cli discoverable
  • ugly
  • non intuitive
  • feels brittle
  • not bash
  • odd env resolution behaviour
  • familiarity amonst seasoned devs
Javascript
  • needlessly verbose
  • can't switch to native shell easily
  • cross platform
Shell Scripts
  • not cli discoverable
  • have to jump between files
  • not cross platform
  • familiarity

I want something simpler and more easy to use...

✅ pros of hooked ✅

  • less context switching - one file for all scripts (or multiple, choose your own adventure!).
  • more readable - because of "smart" completion, script names can be more verbose (symbols!).
  • less environment configuration - only required environment variables are resolved, meaning non-admins don't need a full environment setup.
  • more extensible - supports more generic, reusable, parameterised scripts.
  • less typing - using j _logs_, users can rebuild/redeploy (almost) handsfree.
  • scripts reuse - scripts that call other scripts = easy pipelines.
  • scripts for documentation - scripts can print out information, or be used to open websites e.g. open https://somewebsite.com

Usage

j --help

(the 'j' is a fishing hook!)


Getting started

Just type --init, and it'll ask to choose a sample hooked.yaml config file to start with.

j --init

Preconfigured environments

Use --env to specify the global environment/s you'd like to use.

j --env <yourenv1,yourenv2,etc>

Rerunnable commands

Here is some example output:

Using environment: default
? What is your name? Bob
? Please select a script say
? Please select a script hello
Using script: say hello
rerun: j say hello -e default -in '{"FIRSTNAME":"Bob"}'
Hello world, Bob (nickpersonal)!
git commit is -> (279e8b9)

Note the rerun: ... output? You can use that, to rerun a command, with all inputs predefined:

j say hello --env default --stdin '{"FIRSTNAME":"Bob"}'

Copy other people

Similar to the rerun output, you can see (and copy) what others have run recently:

j --log

Suggested scripts

Don't worry, if you can't remember the full script path, you'll be prompted. Try this:

j

Smart complete scripts

Feeling lazy efficient? Try typing some prefix characters of the script or environment. As long as it's enough to uniquely identify your script, the tool will do the rest!

Example: shorthand for run "say hello --env spanish

j s hel --env sp

Don't forget to commit hooked.yaml and .hooked_history.log files to source control, for the next person!

Configuration

This deserves it's own section... check it out.

We are adding Plugins too... check out the ABI Plugin here

Impatient? Checkout the hooked.yaml config we use!

Backlog

More here.

About

A tool for executing preconfigured scripts via multiple channels (e.g. REST, CLI, WEB).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages