CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-bunli

CLI development framework specifically designed for Bun runtime with complete toolchain for building, testing, and distributing command-line applications.

Overview
Eval results
Files

project-utilities.mddocs/

Project Utilities

Bunli provides utility functions for project introspection and automated file discovery, helping developers avoid manual configuration where possible.

Capabilities

Entry Point Discovery

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:

  1. src/cli.ts
  2. src/index.ts
  3. src/main.ts
  4. cli.ts
  5. index.ts
  6. main.ts
  7. src/cli.js
  8. src/index.js
  9. src/main.js
  10. cli.js
  11. index.js
  12. main.js
  13. First entry from package.json bin field

Usage 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.

Version Information

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

docs

cli-commands.md

configuration.md

index.md

project-utilities.md

tile.json