Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2"
}
68 changes: 68 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [22.x]
os: [ubuntu-latest]
arch: [x64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run test

test-all:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [x64, arm64]
exclude:
- os: windows-latest
arch: arm64
- os: ubuntu-latest
arch: arm64
- os: macos-latest
arch: x64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- if: matrix.node-version == '20.x'
run: node --test
- if: matrix.node-version != '20.x'
run: npm run test
- run: node dist/cli.js ls
- run: node bin/cli.cjs ls
- run: node --import tsx/esm src/cli.ts ls
- run: npx tsx src/cli.ts ls
- run: npm link && runbook ls && rb ls
- run: npm install -g bun
- run: bun test
- run: bun run src/cli.ts -- ls
- shell: bash
run: |
set -eoux pipefail
platform="$(echo "${{ matrix.os }}" | sed -E 's/^ubuntu(-.*)?$/linux/; s/^macos(-.*)?$/darwin/; s/^windows(-.*)?$/windows/;')-${{ matrix.arch }}"
binary="./exec/runbook-$platform"
bun run "build:native:binaries:$platform"
chmod +x "$binary"
"$binary" ls
22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/node_modules/
/dist/
/exec/
/exec/
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"editor.insertSpaces": true,
"editor.tabSize": 2,
"files.autoSave": "off",
"files.insertFinalNewline": true,
"git.inputValidation": true,
"git.inputValidationLength": 72,
"git.inputValidationSubjectLength": 50,
"scm.defaultViewMode": "tree",
"terminal.integrated.scrollback": 100000
}
44 changes: 39 additions & 5 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,38 @@

This document is for developers working on the runbook application *itself*. If you're interested in using runbook, see the [README](README.md).

To run without building first, use:
> [!TIP]
>
> You can get started right away with a GitHub Codespace instead of cloning the repository locally!
>
> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/khalidx/runbook?quickstart=1)

```bash "runbook ls"
npx ts-node src/cli.ts ls # or any other runbook command
First, install dependencies:

```bash "install dependencies"
npm install
```

To run without building first, you can use `bun`:

```bash "install bun globally"
npm install -g bun
```

```bash "runbook ls with bun"
bun run src/cli.ts -- ls # or any other runbook command
```

Or, you can use `tsx`:

```bash "runbook ls with tsx"
npx tsx src/cli.ts ls # or any other runbook command
```

To quickly test while developing this package, run:

```bash "runbook run hello"
npx ts-node src/cli.ts run hello --greeting Hey --name Batman
bun run src/cli.ts -- run hello --greeting Hey --name Batman
```

Alternatively, the package can be linked and run with the `DEV=true` environment variable to pick up the latest TypeScript source changes without the need to re-link the package.
Expand All @@ -21,6 +43,14 @@ npm link
DEV=true runbook run hello --greeting Hey --name Batman
```

When linked, you can use `runbook` and the shorter `rb` commands right in the CLI, just like if you had installed the command globally via `npm`.

To build:

```bash "build"
npm run build
```

Here's some fun - using runbook to run runbook to run the raw TypeScript version of runbook to run the "hello" command.

```bash "runbook inception"
Expand All @@ -36,5 +66,9 @@ npm run test
Here is a command that always fails (useful for seeing how runbook handles errors):

```bash "this will fail"
exit 1
runbook run this will fail --exitCode 1
```

```bash hbs "this will fail"
echo 'Failing with {{exitCode}}' && exit {{exitCode}}
```
2 changes: 1 addition & 1 deletion LIBRARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runbook run generate password --length 20
```

```javascript hbs "generate password"
const { randomFillSync } = require('crypto')
import { randomFillSync } from 'node:crypto'

const generatePassword = (
length = {{ length }},
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 2021 2022 Khalid Zoabi
Copyright (c) 2020 2021 2022 2023 2024 2025 Khalid Zoabi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Executable markdown documents that you can run, template, and share!

## quickstart

```bash "install"
```bash "install from npm"
npm install -g @khalidx/runbook
```

Expand Down
4 changes: 2 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Currently, `runbook run` supports the execution of `bash`, `powershell`, `javasc
- `bash` blocks are executed with `bash`
- `powershell` and `ps1` blocks are executed with `pwsh` or `powershell.exe`
- `javascript` and `js` blocks are executed with `node`
- `typescript` and `ts` blocks are executed with `npx ts-node`
- `esm` and `es6` blocks are executed with `node --loader ts-node/esm`
- `typescript` and `ts` blocks are executed with `bun`
- `esm` and `es6` blocks are executed with `bun`
- `python` blocks are executed with `python`
- `go` blocks are executed with `go`

Expand Down
14 changes: 14 additions & 0 deletions bin/cli.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

if (process.env.DEV !== undefined) {
const { resolve } = require('node:path')
const { execFileSync } = require('node:child_process')
const entrypoint = resolve(__dirname, '../src/cli.ts')
try {
execFileSync('bun', [ 'run', entrypoint, '--', ...process.argv.slice(2) ], { stdio: 'inherit' })
} catch (error) {
process.exitCode = error.status || 1
}
} else {
require('../dist/cli.js')
}
8 changes: 0 additions & 8 deletions bin/cli.js

This file was deleted.

Loading
Loading