rad 💯

a general purpose build tool.

statically typed, programmable, transparent, batteries included. shell, function based, and make-style task support.

usage

$ rad <task-name> [--help]

// rad.ts - your buildfile
import { Tasks } from "https://raw.githubusercontent.com/cdaringe/rad/master/src/mod.ts";

// command tasks
const format = `prettier --write`
const test = `deno test`

// function tasks
const compile = {
  dependsOn: [format],
  fn({ sh, ...toolkit }) => sh('tsc')
}

// make-style tasks
const transpile = {
  target: "phony",
  prereqs: ["p1", "p2"],
  async onMake({ logger }, { prereqs, getChangedPrereqFilenames }) {
    const babel = await import("https://my.cdn/babel/7.js")
    for await (const req of prereqs) {
      logger.info(`req: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi><mi>e</mi><mi>q</mi><mi mathvariant="normal">.</mi><mi>f</mi><mi>i</mi><mi>l</mi><mi>e</mi><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">{req.filename} </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">re</span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord">.</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal">nam</span><span class="mord mathnormal">e</span></span></span></span></span>{JSON.stringify(req.info)}`);
    }
    const changed = await getChangedPrereqFilenames();
    logger.info(`changed: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>c</mi><mi>h</mi><mi>a</mi><mi>n</mi><mi>g</mi><mi>e</mi><mi>d</mi></mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">{changed} (</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="mord mathnormal">han</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span></span><span class="mopen">(</span></span></span></span>{changed.length})`);
  },
}

export const tasks: Tasks = {
  compile,
  format,
  test
}

install

there are a few formal ways to use rad:

usage install-method install-steps
cli deno deno install rad https://github.com/cdaringe/rad/blob/master/src/bin.ts
cli docker docker pull cdaringe/rad 1
cli curl+sh `curl .sh
library deno import * as rad from https://github.com/cdaringe/rad/blob/master/src/mod.ts

1For docker users, consider making a nice shell alias

# shell profile, e.g. .bash_profile
function rad() {
  docker run --rm -v <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mi>W</mi><mi>D</mi><mo>:</mo><mi mathvariant="normal">/</mi><mi>r</mi><mi>a</mi><mi>d</mi><mi>c</mi><mi>d</mi><mi>a</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>e</mi><mi mathvariant="normal">/</mi><mi>r</mi><mi>a</mi><mi>d</mi><mi mathvariant="normal">&quot;</mi></mrow><annotation encoding="application/x-tex">PWD:/rad cdaringe/rad &quot;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mord mathnormal" style="margin-right:0.02778em;">D</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">a</span><span class="mord mathnormal">d</span><span class="mord mathnormal">c</span><span class="mord mathnormal">d</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">e</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">a</span><span class="mord mathnormal">d</span><span class="mord">&quot;</span></span></span></span>@";
}

what is it

  • bottom-up, make-style build targets
    • fast builds, skip redundant tasks when inputs haven’t changed!
  • pipeline style builds
    • easy to understand, declarative build steps
  • highly portable. build automation for any language or project, in many environments
  • generic package management
  • great UX is priority 1 (after priorities 0.33 works, 0.66 correct, & 0.99 fast-enough :))

why

no build tools in 2018 2019 2020 have a complete feature set that the average polyglot programmer needs without coercing it or piling on extraneous complexity.

see why not just use

features

  • stop using make and bash. use a modern syntax and a real scripting language
    • <ref to why bash is not fit for general purpose scripting>
  • no DSL. your build is code–tasks are POJOs with a verified interface
  • debuggable. 🐛 halt the runtime, inspect your data, tasks, or even rad itself
  • beautiful.
  • take it anywhere.
    • osx, linux, windows!
      • help us support other architectures
  • no dependencies.
    • e.g. you don’t need bash, or java, this lib, that lib, etc. we bundle everything we need, courtesy of deno bundle!