Skip to content
/ bs Public

The simplest possible build system using executables

Notifications You must be signed in to change notification settings

jaandrle/bs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs: Build system based on executables

This is just an extension (backwards compatible) of labaneilers/bs: The simplest possible build system using bash.

Still just simple bash scripts are probably good enough in most cases. However, for some situations it can be useful to use scripts in different language.

This leads to, in root of your project create bs directory and put there any executable (chmod +x + shellbang):

bs
├───build.js
├───install.sh
├───run
└───test.py

Some shellbangs for example:

#!/usr/bin/env node
#!/usr/bin/env nodejsscript
#!/usr/bin/env -S npx nodejsscript
#!/usr/bin/env python3
#!/usr/bin/env bash

Why?

See labaneilers/bs#why.

Usage

Your working directory should contain bs directory with building scrips/executables. You can use bs utility with auto-find feature.

Executing scripts

Now you can run and lists your build options like:

  • raw:
    • run command: bs/build.js some-argument
    • lists commands: ls bs, find bs/** -executable, find bs -type f -executable, …
    • see structure: tree bs
    • create folder: mkdir bs, mkdir -p bs, touch README.md, …
    • (optional, see below) list commands with commnets: cat bs/README.md, bat bs/README.md, …
  • using bs:
    • run command: bs build some-argument, bs .run build some-argument
    • lists commands: bs, bs .ls, bs .ls filter
    • see structure: tree bs
    • create folder: bs .mkdir
    • cat README: bs .cat, bs .cat filter

Organizing scripts

There are no rules, it is all up to you. But definitely we can put together some suggestions to work with bs more happily.

  1. prefers short names without unnecessary special characters (spaces, brackets, …)
  2. provide --help options for your scripts
  3. use subdirectories for subtasks
  4. use dots in names for non-scripts (like .config.js, .common.js, .utils.js, …)
  5. provide README.md to comment your build scripts
bs/
├───build.js
├───build/
│   ├───html.js
│   └───sass.js
├───run.js
├───publish.js
├───.config.js
└───README.md

PS: You can create alias for task with:

ln -rfs bs/target bs/alias

Build flows

Now focus on creating building flows. For parallel tasts, you can use this pattern:

#!/usr/bin/env bash
set -eou pipefail
(
	trap 'kill 0' SIGINT ;
	bs/taskA &
	bs/taskB &
	bs/taskC &
	wait
)

For serial tasks:

#!/usr/bin/env bash
set -eou pipefail
bs/taskA &&
bs/taskB &&
bs/taskC

…pipe tasks:

#!/usr/bin/env bash
set -eou pipefail
cat src/*.js | manipulate > index.js

bs

This is just a simple helper providing nice outputs and make some operations easier.

Installation

For now for early adapaters.

You can find binaries on Release page.

Or use: npm install https://github.com/jaandrle/bs --location=global

Config/Info files Using README.md

This feature has been removed in version 0.8. It seems to be better to use bs/README.md for comment your build scripts. See example for current project bs/README.md.

You can than use cat bs/README.md to get quick overview of available commands.

bs synopsis

See bs.js (line ≥41).

bs completions

To allow completions just add eval "$(bs .completion bash)" to your .bashrc.

Ideas

You can use Git - Submodules to share your build scrips across your projects.

WIP

  • provide bs via npm
  • docs for coexistence with others (such as npm run)

Acknowledgments