mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat(cli): add programmatic api (#494)
This commit is contained in:
@@ -22,6 +22,8 @@ create-better-t-stack [project-directory] [options]
|
||||
### Key Options
|
||||
|
||||
- `--yes, -y`: Use default configuration (skips prompts)
|
||||
- `--verbose`: Show detailed result information as JSON
|
||||
- `--yolo`: Bypass validations and compatibility checks
|
||||
- `--package-manager <pm>`: `npm`, `pnpm`, `bun`
|
||||
- `--install / --no-install`: Install dependencies after creation
|
||||
- `--git / --no-git`: Initialize Git repository
|
||||
@@ -34,6 +36,8 @@ create-better-t-stack [project-directory] [options]
|
||||
- `--db-setup <setup>`: `none`, `turso`, `d1`, `neon`, `supabase`, `prisma-postgres`, `mongodb-atlas`, `docker`
|
||||
- `--examples <types...>`: `none`, `todo`, `ai`
|
||||
- `--web-deploy <setup>`: `none`, `workers`
|
||||
- `--directory-conflict <strategy>`: `merge`, `overwrite`, `increment`, `error`
|
||||
- `--render-title / --no-render-title`: Show/hide ASCII art title
|
||||
|
||||
See the full reference in [Options](/docs/cli/options).
|
||||
|
||||
@@ -147,3 +151,35 @@ create-better-t-stack api-server \
|
||||
cd my-existing-project
|
||||
create-better-t-stack add --addons tauri starlight --install
|
||||
```
|
||||
|
||||
## Programmatic Usage
|
||||
|
||||
For advanced use cases, automation, or integration with other tools, you can use the [Programmatic API](/docs/cli/programmatic-api) to create projects from Node.js code:
|
||||
|
||||
```typescript
|
||||
import { init } from "create-better-t-stack";
|
||||
|
||||
// Create multiple projects programmatically
|
||||
const projects = [
|
||||
{ name: "api", config: { frontend: ["none"], backend: "hono" } },
|
||||
{ name: "web", config: { frontend: ["next"], backend: "none" } }
|
||||
];
|
||||
|
||||
for (const { name, config } of projects) {
|
||||
const result = await init(name, {
|
||||
yes: true,
|
||||
...config,
|
||||
directoryConflict: "increment"
|
||||
});
|
||||
|
||||
console.log(result.success ? `✅ ${name}` : `❌ ${name}: ${result.error}`);
|
||||
}
|
||||
```
|
||||
|
||||
This is useful for:
|
||||
- **Build tools and generators** - Create projects from templates
|
||||
- **CI/CD pipelines** - Generate test projects automatically
|
||||
- **Development workflows** - Batch create related projects
|
||||
- **Custom tooling** - Integrate with your existing development setup
|
||||
|
||||
See the [Programmatic API documentation](/docs/cli/programmatic-api) for complete examples and API reference.
|
||||
|
||||
Reference in New Issue
Block a user