create-bunli
v0.8.2
Published
Scaffold new Bunli CLI projects
Maintainers
Readme
create-bunli
Scaffold new Bunli CLI projects with ease.
Quick Start
# Using bunx (recommended)
bunx create-bunli my-cli
# Or install globally and use directly
bun add -g create-bunli
create-bunli my-cliFeatures
- 🚀 Fast scaffolding - Get started in seconds
- 📦 Multiple templates - Choose from basic, advanced, or monorepo setups
- 🔧 TypeScript ready - Full TypeScript support out of the box
- 🧪 Testing included - Comes with @bunli/test for CLI testing
- 🎨 Best practices - Follows Bunli conventions and patterns
- 🌐 Flexible sources - Use bundled templates or any GitHub repository
- ⚡ Type generation - All templates include codegen for enhanced developer experience
Usage
Basic Usage
Create a new project with the default template:
bunx create-bunli my-cliUsing Templates
Choose from bundled templates:
# Basic single-command CLI
bunx create-bunli my-cli --template basic
# Advanced multi-command CLI with subcommands
bunx create-bunli my-cli --template advanced
# Monorepo setup with Turborepo
bunx create-bunli my-cli --template monorepoUsing External Templates
Use any GitHub repository as a template:
# GitHub repository
bunx create-bunli my-cli --template username/repo
# With full GitHub URL
bunx create-bunli my-cli --template github:username/repo
# Specific branch or tag
bunx create-bunli my-cli --template username/repo#branchOptions
bunx create-bunli [name] [options]
Options:
-t, --template <template> Project template (default: "basic")
-d, --dir <dir> Directory to create project in
-g, --git Initialize git repository (default: true)
-i, --install Install dependencies (default: true)
--offline Use cached templates when available
-h, --help Display help
-v, --version Display versionExamples
# Create in current directory
bunx create-bunli .
# Create without installing dependencies
bunx create-bunli my-cli --no-install
# Create in custom directory
bunx create-bunli my-cli --dir ~/projects/my-cli
# Use external template
bunx create-bunli my-cli --template pvtnbr/bunli-starterTemplates
Basic Template
Perfect for simple CLI tools with a single command.
Features:
- Single command setup
- TypeScript configuration
- Test setup with @bunli/test
- Build script using bunli
Structure:
my-cli/
├── src/
│ ├── index.ts # CLI entry point
│ └── commands/
│ └── hello.ts # Example command
├── test/
│ └── hello.test.ts # Example test
├── package.json
├── tsconfig.json
└── README.mdAdvanced Template
For complex CLIs with multiple commands and features.
Features:
- Multiple commands with subcommands
- Configuration management
- File validation system
- Built-in development server
- Advanced command examples
Commands included:
init- Initialize configurationvalidate- Validate files with rulesserve- Start development serverconfig- Manage configuration
Structure:
my-cli/
├── src/
│ ├── index.ts # CLI entry point
│ ├── commands/ # Command implementations
│ │ ├── init.ts
│ │ ├── validate.ts
│ │ ├── serve.ts
│ │ └── config.ts
│ └── utils/ # Utility functions
│ ├── config.ts
│ ├── validator.ts
│ └── glob.ts
├── test/
├── package.json
├── tsconfig.json
└── README.mdMonorepo Template
For large projects with multiple packages.
Features:
- Turborepo configuration
- Multiple packages setup
- Shared dependencies
- Changeset support
- Parallel builds
Structure:
my-cli/
├── packages/
│ ├── cli/ # Main CLI package
│ ├── core/ # Core functionality
│ └── utils/ # Shared utilities
├── turbo.json # Turborepo config
├── package.json # Root package.json
├── tsconfig.json # Root TypeScript config
└── README.mdCreating Custom Templates
Templates can include a template.json manifest:
{
"name": "my-template",
"description": "My custom template",
"variables": [
{
"name": "projectName",
"message": "Project name",
"type": "string",
"default": "my-project"
},
{
"name": "license",
"message": "License",
"type": "select",
"choices": ["MIT", "Apache-2.0", "GPL-3.0"]
}
]
}Type Generation
All templates include type generation configuration for enhanced developer experience:
This provides:
- Autocomplete for command names and options
- Type safety at compile time
- IntelliSense for command metadata
- CLI wrappers for programmatic execution
Learn more in the Type Generation Guide.
Template Variables
Use these variables in your template files:
{{projectName}}- The project name{{description}}- Project description{{author}}- Author name{{license}}- License type{{year}}- Current year
Variables can be used in file contents and filenames:
__projectName__.config.js→my-app.config.js
Programmatic Usage
import { createProject } from "create-bunli";
await createProject({
name: "my-cli",
template: "advanced",
install: true,
git: true,
});Development
# Clone the repository
git clone https://github.com/AryaLabsHQ/bunli.git
cd bunli/packages/create-bunli
# Install dependencies
bun install
# Run in development
bun dev
# Run tests
bun test
# Build
bun run buildTroubleshooting
Template not found
If you get a "template not found" error, ensure:
- The template name is correct
- For GitHub templates, the repository exists and is public
- You have internet connection (for external templates)
Installation fails
If dependency installation fails:
- Check your internet connection
- Ensure Bun is installed correctly
- Try running with
--no-installand install manually withbun install
Permission errors
If you get permission errors:
- Ensure you have write access to the target directory
- Try running in a different directory
- Check disk space availability
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
Adding a New Template
- Create a new directory in
templates/ - Add all template files
- Create a
template.jsonmanifest - Test the template thoroughly
- Submit a pull request
License
MIT © Arya Labs, Inc.
