laufen
v1.3.1
Published
Typed script runner for monorepos — discover, validate, and execute TypeScript scripts with Zod-powered arguments
Downloads
2,065
Maintainers
Readme
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.
pnpm add -D laufenSetup a lauf script, including defining args, env variables, and packages.
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.
lauf run @my-org/my-package/hello --name=Zac --loud=true[!TIP] Requires Node.js >= 22.0.0
Quick Reference
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.
