Demonstrate how just
can be used like package.json scripts.
npm
has the concept of scripts that developers use to provide common tasks such as "build" and "run". But when you're not in that ecosystem such as with terraform
or docker
then you find having to provide readme with quite complicated build commands or custom scripts. just
allows a simple DSL to provide this functionality.
NOTES:
- It seems very fast at executing.
- It's a good alternative to using
package.json
just
always runs in the directory of the just file.
brew info just
# install
brew install just
brew upgrade just
just --version
just --help
You can cheat putting a shebang at the top of the justfile to make it executable.
# the shebang works
./justfile echovars
# run echo with defaults
./justfile echo
# run echo with parameters
./justfile echo parameter1 parameter2
Simple example to demonstrate a few concepts.
# list recipes
just -f ./example.justfile
# run silentecho
just -f ./example.justfile echo parameter1 parameter2
# run silentecho
just -f ./example.justfile silentecho
# show envvars
just -f ./example.justfile echovars
# checks and confirmation
just -f ./example.justfile folders
Use just
to script building and running containers.
# list recipes
just -f ./docker.justfile
# run list-images
just -f ./docker.justfile docker-images
# build container
just -f ./docker.justfile docker-build processor
# run container
just --timestamp -f ./docker.justfile docker-run processor
# testing internal functions
just --timestamp -f functions.justfile functions
Try to show some timing on tasks.
REF: 19_timing_operations/README.md
# testing internal functions
just --timestamp -f timing.justfile mytask
# you can wrap the whole operation in time.
time just --timestamp -f timing.justfile mytask
just -f ./multiline.justfile multiline1
just -f ./multiline.justfile multiline2
just -f ./import.justfile docker-build
just -f loops.justfile counter
just -f loops.justfile directory-listing