Skip to content

Commit 4cf1e6e

Browse files
committed
Add template arg to CLI
1 parent 8194995 commit 4cf1e6e

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- [2026-01-14] [Add template arg to CLI](https://github.com/rubriclab/create-rubric-app/commit/b3de12e510b02a839f5d833f11caed7ede2bda02)
12
- [2026-01-09] [Reconcile changelog](https://github.com/rubriclab/create-rubric-app/commit/65c2411412e1873ba12b0b45ff7e9c36babf3407)
23
- [2025-12-22] [Correct example env](https://github.com/rubriclab/create-rubric-app/commit/c7200451c9d2cac4338bc7ddd2f0a66b7bd7b55e)
34
- [2025-12-19] [Fix build](https://github.com/rubriclab/create-rubric-app/commit/c78aa752e2b9eb8eec685670e610ea85d8821a3b)

index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
#! /usr/bin/env bun
22

3-
import { existsSync } from 'node:fs'
3+
import { existsSync, readdirSync } from 'node:fs'
44
import path from 'node:path'
55
import { createCLI, createCommand } from '@rubriclab/cli'
66
import { $ } from 'bun'
77
import { z } from 'zod'
88

9+
const templates = readdirSync(path.join(import.meta.dir, 'templates'))
10+
911
const initCommand = createCommand({
1012
args: z.object({
11-
name: z.string().default('myApp').describe('Name of the new app directory')
13+
name: z.string().default('my-app').describe('Name of the new app directory'),
14+
template: z.enum(templates).default('react').describe('Template to use for the new app')
1215
}),
1316
description: 'Inits an app based on Rubric patterns',
14-
handler: async ({ name }) => {
17+
handler: async ({ name, template }) => {
1518
const targetDir = path.join(process.cwd(), name)
16-
const templateDir = path.join(import.meta.dir, 'templates', 'chat')
19+
const templateDir = path.join(import.meta.dir, 'templates', template)
1720

1821
if (existsSync(targetDir)) {
1922
console.error(`Error: Directory "${name}" already exists`)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
"simple-git-hooks": {
3333
"post-commit": "bun x @rubriclab/package post-commit"
3434
},
35-
"version": "1.6.33"
35+
"version": "1.6.34"
3636
}

0 commit comments

Comments
 (0)