Skip to content

jaandrle/bs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 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.

Now you can run and lists your build options like:

  • raw:
    • Run command: bs/build.js some-argument
    • Lists commands: find bs -type f -executable (list help texts grep -H help bs/.*.toml bs/*/.*.toml, see below)
  • using bs:
    • Run command: bs build some-argument
    • Lists commands: bs .ls

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

You can create alias for task with:

ln -rfs bs/target bs/alias
# optionaly
ln -rfs bs/.target.toml bs/.alias.toml

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

You can create .command.toml file to describe command and add additional configuration. Example:

buld.sh
.build.toml
#.build.toml
info= "Description of command"
default= true

[completions]
__all= [ "--help", "--version" ]
cmd= []

…all is optional. But:

  • info: this text is listed aside of command name (e.g. bs .ls)
  • default: this changes behavior of plain bs. By default it runs .ls, now it runs marked command
  • completions: provide options for completions bs .run build …/bs build …
    • __all: these options are listed for all sub-commands
    • cmd: registers sub-command and its possible arguments (bs .run build cmd …)

bs synopsis

See bs.js (line ≥24).

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 binary
  • some missing? commands in bs (maybe .init)
  • docs for .command.toml (bs completion)
  • docs for git submodules to share build scripts
  • docs for coexistence with others (such as npm run)
  • examples how to use bash for parallel/serial execution

Acknowledgments