CLI development framework specifically designed for Bun runtime with complete toolchain for building, testing, and distributing command-line applications.
Bunli provides utility functions for project introspection and automated file discovery, helping developers avoid manual configuration where possible.
Automatically detects common CLI entry point files in projects, eliminating the need for manual entry point configuration in most cases.
/**
* Auto-detects entry point files for CLI projects
* @param cwd - Current working directory to search (defaults to process.cwd())
* @returns Promise resolving to detected entry file path or undefined if none found
*/
function findEntry(cwd?: string): Promise<string | undefined>;Entry Point Search Order:
The function searches for entry files in the following priority order:
src/cli.tssrc/index.tssrc/main.tscli.tsindex.tsmain.tssrc/cli.jssrc/index.jssrc/main.jscli.jsindex.jsmain.jspackage.json bin fieldUsage Example:
import { findEntry } from 'bunli';
// Find entry point in current directory
const entry = await findEntry();
if (entry) {
console.log(`Detected entry point: ${entry}`);
} else {
console.log('No entry point found, please specify manually');
}
// Find entry point in specific directory
const projectEntry = await findEntry('/path/to/project');
// Use in build scripts or programmatic usage
import { defineConfig, findEntry } from 'bunli';
const entry = await findEntry();
export default defineConfig({
build: {
entry: entry || 'src/index.ts', // fallback if not found
outdir: 'dist'
}
});Package.json Integration:
The utility also checks the bin field in package.json for executable entries:
{
"bin": {
"my-cli": "./dist/cli.js"
}
}Or for single binaries:
{
"bin": "./dist/cli.js"
}Error Handling:
The function gracefully handles missing files and invalid package.json files, returning undefined when no suitable entry point is found rather than throwing errors.
Access to the current bunli version for programmatic use.
/**
* Current bunli version string (currently "0.1.0")
*/
const version: string;Usage Example:
import { version } from 'bunli';
console.log(`Using Bunli v${version}`); // "Using Bunli v0.1.0"Install with Tessl CLI
npx tessl i tessl/npm-bunli