An open API service indexing awesome lists of open source software.

https://github.com/zrosenbauer/lauf

Discover, validate, and execute TypeScript scripts with Zod-powered arguments.
https://github.com/zrosenbauer/lauf

Last synced: 4 months ago
JSON representation

Discover, validate, and execute TypeScript scripts with Zod-powered arguments.

Awesome Lists containing this project

README

          

lauf


Typed script runner for monorepos

Discover, validate, and execute TypeScript scripts with Zod-powered arguments.


npm version
license


---

## Features

- 🔍 **Auto-discovery** — Scans every workspace package for scripts matching your configured glob patterns.
- ✅ **Zod-powered validation** — Define args with Zod schemas and get runtime validation + full TypeScript inference.
- ðŸ“Ķ **Package management** — Declare npm packages in scripts or workspace config, auto-installed to cache without polluting project dependencies.
- ðŸ§Đ **Workspace-agnostic** — Auto-detects pnpm, npm, yarn, bun, lerna, and single-package projects.
- 💎 **Auto-prompting** — Missing required args are interactively prompted, so scripts work both in CI and locally.
- ðŸŠķ **Tiny API surface** — One function (`lauf()`), one schema library (`z`), one convention (`scripts/` directory).

---

## Quick Start

Install the `laufen` package.

```bash
pnpm add -D laufen
```

Setup a `lauf` script, including defining args, env variables, and packages.

```ts
import { lauf, z, infisical } from 'laufen';

export default lauf({
description: 'Say hello',
env: infisical({ path: '/ops/ci', env: 'dev' }),
packages: {
chalk: '^5.0.0', // Auto-installed to cache, no project dependency needed
},
args: {
name: z.string().default('world'),
loud: z.boolean().default(false),
},
async run(ctx) {
const { default: chalk } = await ctx.import('chalk');
const greeting = `Hello, ${ctx.args.name}!`;
const message = ctx.args.loud ? greeting.toUpperCase() : greeting;
ctx.logger.info(chalk.blue(message));
},
});
```

Run the script using the args you defined.

```bash
lauf run @my-org/my-package/hello --name=Zac --loud=true
```

> [!TIP]
> Requires Node.js >= 22.0.0

## Quick Reference

```bash
lauf init # scaffold lauf.config.ts
lauf create # generate a new script from a template
lauf list # discover all scripts across the workspace
lauf run # execute a script by name
lauf info # view a script's args and description
```

---

## 📖 Documentation

For full docs — configuration, script API, CLI reference, examples, and more — visit the **[documentation site](https://zrosenbauer.github.io/lauf/)**.

## 📝 License

[MIT](LICENSE)