CLI development framework specifically designed for Bun runtime with complete toolchain for building, testing, and distributing command-line applications.
Bunli's configuration system provides type-safe project settings through configuration files and programmatic APIs. Configuration files are automatically discovered and loaded from the project root.
Helper function for creating type-safe configuration files with full IntelliSense support.
/**
* Type-safe helper for defining bunli configuration files
* @param config - Configuration object following BunliConfig schema
* @returns The same configuration object with type validation
*/
function defineConfig(config: BunliConfig): BunliConfig;Usage Example:
// bunli.config.ts
import { defineConfig } from 'bunli';
export default defineConfig({
name: 'my-awesome-cli',
version: '1.0.0',
description: 'An awesome CLI built with Bunli',
build: {
entry: 'src/cli.ts',
outdir: 'dist',
targets: ['darwin-arm64', 'linux-x64', 'windows-x64'],
minify: true,
sourcemap: false,
compress: true
},
dev: {
watch: true,
inspect: false,
port: 9229
},
test: {
pattern: ['**/*.test.ts', '**/*.spec.ts'],
coverage: true,
watch: false
},
release: {
npm: true,
github: true,
tagFormat: 'v${version}',
conventionalCommits: true
}
});Loads configuration from multiple file formats with automatic discovery.
/**
* Loads bunli configuration from config files
* @param cwd - Current working directory to search for config files (defaults to process.cwd())
* @returns Promise resolving to the loaded configuration or empty object if no config found
*/
function loadConfig(cwd?: string): Promise<BunliConfig>;Configuration File Discovery:
Bunli searches for configuration files in the following order:
bunli.config.tsbunli.config.jsbunli.config.mjsUsage Example:
import { loadConfig } from 'bunli';
// Load from current directory
const config = await loadConfig();
// Load from specific directory
const projectConfig = await loadConfig('/path/to/project');
// Access configuration values
console.log(`Building ${config.name || 'CLI'} v${config.version || '1.0.0'}`);Complete configuration type definition with all available options.
interface BunliConfig {
/** Project name */
name?: string;
/** Project version */
version?: string;
/** Project description */
description?: string;
/** Commands configuration */
commands?: {
/** Path to commands manifest file */
manifest?: string;
/** Directory containing command files */
directory?: string;
};
/** Build configuration */
build?: BuildConfig;
/** Development configuration */
dev?: DevConfig;
/** Testing configuration */
test?: TestConfig;
/** Release configuration */
release?: ReleaseConfig;
/** Workspace configuration for monorepos */
workspace?: WorkspaceConfig;
}
interface BuildConfig {
/** Entry point file(s) for compilation */
entry?: string | string[];
/** Output directory for built files */
outdir?: string;
/** Target platforms for compilation */
targets?: string[];
/** Enable compression for multi-target builds */
compress?: boolean;
/** External dependencies to exclude from bundle */
external?: string[];
/** Enable minification */
minify?: boolean;
/** Generate source maps */
sourcemap?: boolean;
}
interface DevConfig {
/** Enable file watching and hot reload */
watch?: boolean;
/** Enable debugger */
inspect?: boolean;
/** Debugger port number */
port?: number;
}
interface TestConfig {
/** Test file patterns to match */
pattern?: string | string[];
/** Generate coverage reports */
coverage?: boolean;
/** Enable watch mode for tests */
watch?: boolean;
}
interface ReleaseConfig {
/** Publish to npm registry */
npm?: boolean;
/** Create GitHub release */
github?: boolean;
/** Git tag format string (use ${version} placeholder) */
tagFormat?: string;
/** Use conventional commits for changelog */
conventionalCommits?: boolean;
}
interface WorkspaceConfig {
/** Package patterns for workspace detection */
packages?: string[];
/** Shared workspace configuration */
shared?: any;
/** Version strategy for workspace packages */
versionStrategy?: 'fixed' | 'independent';
}Supported compilation targets for standalone executable generation:
native - Current platform architectureall - All supported platformsdarwin-arm64 - macOS Apple Silicondarwin-x64 - macOS Intellinux-arm64 - Linux ARM64linux-x64 - Linux x86_64windows-x64 - Windows x86_64Configuration is automatically validated using Zod schemas, providing runtime type checking and helpful error messages for invalid configurations.
Install with Tessl CLI
npx tessl i tessl/npm-bunli