create-shadcn-js 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,15 +9,23 @@
9
9
 
10
10
  ## Why create-shadcn-js?
11
11
 
12
- The official `shadcn` CLI only provides TypeScript templates (`--template vite` creates `.tsx` and `tsconfig.json`). If you build with **JavaScript / JSX**, setting up Vite with shadcn and Tailwind requires tedious manual work every single time:
12
+ The official `shadcn` CLI focuses on TypeScript projects. Building with **JavaScript / JSX** normally means doing the same manual setup every time:
13
13
 
14
- 1. **Creating `jsconfig.json`** with `baseUrl` and `@/*` paths so both your editor and the CLI can resolve imports.
15
- 2. **Updating `vite.config.js`** with `path.resolve` and `@` path alias mapping.
16
- 3. **Installing and configuring Tailwind CSS** (Tailwind v4 with `@tailwindcss/vite` and `@import "tailwindcss";` in `index.css`, or v3 with `tailwind.config.js` and `postcss.config.js`).
17
- 4. **Purging default Vite boilerplate** (conflicting `App.css` styling and SVGs).
18
- 5. **Configuring `components.json`** with `"tsx": false` so shadcn generates `.jsx` and `utils.js` files rather than TypeScript.
14
+ 1. **Creating `jsconfig.json`** with `baseUrl` and `@/*` paths so your editor and the shadcn CLI can resolve imports.
15
+ 2. **Updating `vite.config.js`** with `path.resolve` and the `@` path alias.
16
+ 3. **Installing and configuring Tailwind CSS** — v4 with `@tailwindcss/vite` and `@import "tailwindcss";`, or v3 with `tailwind.config.js` and `postcss.config.js`.
17
+ 4. **Purging default Vite boilerplate** (conflicting `App.css` styles and assets).
18
+ 5. **Configuring `components.json`** with `"tsx": false` so shadcn generates `.jsx` components and `utils.js` instead of TypeScript.
19
19
 
20
- `create-shadcn-js` takes care of all of this automatically with an interactive CLI powered by [`@clack/prompts`](https://github.com/natemoo-re/clack).
20
+ `create-shadcn-js` handles all of this automatically with an interactive CLI powered by [`@clack/prompts`](https://github.com/natemoo-re/clack).
21
+
22
+ ---
23
+
24
+ ## Prerequisites
25
+
26
+ - **Node.js `^20.19.0` or `>=22.12.0`** (required by the Vite 8 scaffold).
27
+ - `npm`, `pnpm`, `yarn`, or `bun` on your `PATH`.
28
+ - Network access for `create-vite`, the selected package manager, and the shadcn CLI.
21
29
 
22
30
  ---
23
31
 
@@ -49,13 +57,15 @@ bun create shadcn-js
49
57
 
50
58
  ## Features
51
59
 
52
- - **Vite + React (JavaScript)**: Fast HMR and build speeds using standard `.jsx`.
53
- - **Tailwind CSS v4 & v3**: Defaults to the new Tailwind CSS v4 (`@tailwindcss/vite`), with support for Tailwind CSS v3.
54
- - **Seamless shadcn/ui Integration**: Directly hands off to the official `shadcn@latest init` wizard so you can pick your preferred primitive library (**Base UI**, **Radix UI**, or **React Aria**), presets (**Nova**, **Vega**, etc.), and color palettes.
55
- - **Auto-Configured Path Aliases**: Generates `jsconfig.json` and updates `vite.config.js` with `@/*` mapping out of the box.
56
- - **Clean Slate**: Automatically removes conflicting default Vite styles and sets up a responsive `index.html` with clean typography.
57
- - **Interactive Showcase Demo**: Optionally installs a starter `Button` component and an interactive dark/light mode demo in `src/App.jsx`.
58
- - **CLI Flags for CI/Automation**: Supports non-interactive `-y` / `--yes` mode, preset flags, and custom package managers.
60
+ - **Vite + React (JavaScript)**: Fast HMR and production builds from standard `.jsx` files.
61
+ - **Tailwind CSS v4 by default**: Uses `@tailwindcss/vite` and the CSS-first `@import "tailwindcss";` setup.
62
+ - **Tailwind CSS v3 legacy path**: Installs Tailwind 3.4 and the matching shadcn CLI for projects that still need `tailwind.config.js`.
63
+ - **Seamless shadcn/ui integration (v4)**: Hands off to the official `shadcn@4` init flow so you can choose your primitive library (**Base UI**, **Radix UI**, or **React Aria**), style preset (**Nova**, **Vega**, etc.), and colors.
64
+ - **Auto-configured path aliases**: Generates `jsconfig.json` and updates `vite.config.js` with the `@/*` mapping.
65
+ - **JavaScript-first output**: Forces `components.json` to `"tsx": false` and verifies that `src/lib/utils.js` exists.
66
+ - **Clean slate**: Removes conflicting Vite boilerplate and writes a responsive `index.html` with the Geist font.
67
+ - **Optional starter demo**: Installs a `Button` component and an interactive dark/light mode showcase in `src/App.jsx`.
68
+ - **Non-zero exit on real failures**: If shadcn init does not produce a usable `components.json`, the CLI fails instead of printing a false “Project ready”.
59
69
 
60
70
  ---
61
71
 
@@ -74,15 +84,17 @@ npx create-shadcn-js [project-name] [options]
74
84
  | `[project-name]` | Name of the project directory to create | Prompted (`my-shadcn-app`) |
75
85
  | `--pm <manager>` | Package manager to use (`npm`, `pnpm`, `yarn`, `bun`) | Auto-detected |
76
86
  | `-t, --tailwind <v>` | Tailwind version (`v4` or `v3`) | `v4` |
77
- | `-m, --mode <mode>` | Init mode (`interactive` or `quickstart`) | `interactive` |
78
- | `-b, --base <base>` | Component library (`base`, `radix`, `aria`) | User selection |
79
- | `-p, --preset <preset>` | Style preset (`nova`, `vega`, `maia`, etc.) | User selection |
80
- | `-y, --yes` | Skip interactive prompts and use recommended defaults | `false` |
81
- | `-f, --force` | Overwrite existing directory without confirmation | `false` |
82
- | `--no-sample` | Skip installing sample starter Button component | `false` |
87
+ | `-m, --mode <mode>` | shadcn init mode (`interactive` or `quickstart`). v4 only | `interactive` |
88
+ | `-b, --base <base>` | Component library (`base`, `radix`, `aria`). v4 only | User selection |
89
+ | `-p, --preset <preset>` | Style preset (`nova`, `vega`, `maia`, etc.). v4 only | User selection |
90
+ | `-y, --yes` | Skip interactive prompts and use recommended defaults. Fails on a non-empty target unless `--force` is also set | `false` |
91
+ | `-f, --force` | Overwrite an existing directory without confirmation | `false` |
92
+ | `--no-sample` | Skip the starter Button component and demo | `false` |
83
93
  | `--no-git` | Skip initializing a Git repository | `false` |
84
- | `-v, --version` | Output CLI version | — |
85
- | `-h, --help` | Display help screen | — |
94
+ | `-v, --version` | Output the CLI version | — |
95
+ | `-h, --help` | Display the help screen | — |
96
+
97
+ Invalid option values are rejected with a clear error instead of silently falling back to a different setup.
86
98
 
87
99
  ### Examples:
88
100
 
@@ -106,25 +118,67 @@ npx create-shadcn-js my-app -y
106
118
  npx create-shadcn-js my-app --pm pnpm --base radix --preset nova -y
107
119
  ```
108
120
 
121
+ #### 5. Tailwind CSS v3 (Legacy)
122
+ ```bash
123
+ npx create-shadcn-js my-app --tailwind v3 -y
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Tailwind CSS v3 (Legacy)
129
+
130
+ Tailwind v3 needs the legacy `shadcn@2.3.0` CLI, which predates the v4 preset system. The v3 path is intentionally fixed so it stays reproducible:
131
+
132
+ - **Tailwind CSS `3.4.17`** with `postcss` and `autoprefixer`.
133
+ - **React `18.3.1`** (the legacy shadcn CLI installs non-interactively on React 18).
134
+ - **shadcn `2.3.0`** with the **`new-york`** style and **zinc** base color.
135
+ - A scaffold-owned `tailwind.config.js`, `postcss.config.js`, `components.json`, HSL theme variables, and `src/lib/utils.js`.
136
+
137
+ `--mode`, `--base`, and `--preset` do not apply to Tailwind v3 and are ignored (`--base` and `--preset` also emit a warning). Use Tailwind v4 if you want the interactive library/preset picker.
138
+
109
139
  ---
110
140
 
111
141
  ## What the Generated Project Looks Like
112
142
 
143
+ ### Tailwind v4 (default)
144
+
113
145
  ```
114
146
  my-shadcn-app/
115
- ├── index.html # Pre-configured viewport and Geist font
147
+ ├── index.html # Viewport, Geist font, clean body classes
116
148
  ├── jsconfig.json # {"paths": {"@/*": ["./src/*"]}}
117
- ├── vite.config.js # Vite config with @ alias & Tailwind v4 plugin
118
- ├── components.json # Configured with "tsx": false for JavaScript
149
+ ├── vite.config.js # React + @tailwindcss/vite + @ alias
150
+ ├── components.json # Written by shadcn, normalized to "tsx": false
119
151
  ├── package.json
120
152
  ├── src/
121
153
  │ ├── components/
122
154
  │ │ └── ui/
123
155
  │ │ └── button.jsx # (Optional starter component)
124
156
  │ ├── lib/
125
- │ │ └── utils.js # cn() helper function
126
- │ ├── App.jsx # Interactive demo with Dark Mode toggle
127
- │ ├── index.css # Clean Tailwind CSS theme variables
157
+ │ │ └── utils.js # cn() helper
158
+ │ ├── App.jsx # Interactive demo with dark/light toggle
159
+ │ ├── index.css # shadcn theme tokens
160
+ │ └── main.jsx
161
+ ```
162
+
163
+ ### Tailwind v3 (legacy)
164
+
165
+ ```
166
+ my-shadcn-app/
167
+ ├── index.html
168
+ ├── jsconfig.json
169
+ ├── vite.config.js # React + @ alias (PostCSS handles Tailwind)
170
+ ├── tailwind.config.js
171
+ ├── postcss.config.js
172
+ ├── components.json # "tsx": false, "style": "new-york"
173
+ ├── package.json
174
+ ├── src/
175
+ │ ├── components/
176
+ │ │ └── ui/
177
+ │ │ └── button.jsx # (Optional starter component)
178
+ │ ├── lib/
179
+ │ │ └── utils.js # clsx + tailwind-merge cn() helper
180
+ │ ├── App.jsx
181
+ │ ├── index.css # HSL theme variables (@tailwind layers)
128
182
  │ └── main.jsx
129
183
  ```
130
184
 
@@ -132,14 +186,41 @@ my-shadcn-app/
132
186
 
133
187
  ## Adding More Components
134
188
 
135
- Once your project is created, simply `cd` into your project and use the official shadcn CLI as usual:
189
+ `cd` into your project and use the shadcn CLI version that matches your Tailwind setup.
190
+
191
+ ### Tailwind v4
192
+
193
+ ```bash
194
+ cd my-shadcn-app
195
+ npx shadcn@4 add dialog dropdown-menu input card avatar table
196
+ ```
197
+
198
+ With other package managers:
199
+
200
+ ```bash
201
+ pnpm dlx shadcn@4 add dialog
202
+ bunx --bun shadcn@4 add dialog
203
+ yarn dlx shadcn@4 add dialog
204
+ ```
205
+
206
+ ### Tailwind v3 (legacy)
136
207
 
137
208
  ```bash
138
209
  cd my-shadcn-app
139
- npx shadcn@latest add dialog dropdown-menu input card avatar table
210
+ npx shadcn@2.3.0 add dialog dropdown-menu input card avatar table
140
211
  ```
141
212
 
142
- Components will automatically be added as `.jsx` files inside `src/components/ui/`!
213
+ Components are generated as `.jsx` files inside `src/components/ui/` because `components.json` sets `"tsx": false`.
214
+
215
+ ---
216
+
217
+ ## Troubleshooting
218
+
219
+ - **“components.json is missing or invalid”** — the shadcn init step did not finish (usually a network or registry error). Re-run the CLI, or for a v4 project run `npx shadcn@4 init` inside the project.
220
+ - **“index.css is missing theme variables”** — the shadcn init stopped before writing the theme. Re-run the CLI, or add the missing `--background`/`--primary` tokens with `npx shadcn@4 init` inside the project.
221
+ - **A starter component could not be added** — the scaffold still completes, and `src/App.jsx` remains valid. Add the component later with the command printed in the warning.
222
+ - **“Target directory … is not empty” with `-y`** — non-interactive mode never deletes existing files. Re-run with `--force`, or choose a new project name.
223
+ - **`yarn dlx` is unavailable** — Yarn 1 does not support `dlx`; the CLI automatically falls back to `npx`. Newer Berry releases use `yarn dlx`.
143
224
 
144
225
  ---
145
226
 
@@ -153,6 +234,12 @@ Contributions, issues, and feature requests are welcome!
153
234
  4. Push to the branch (`git push origin feature/amazing-feature`)
154
235
  5. Open a Pull Request
155
236
 
237
+ Run the unit tests with:
238
+
239
+ ```bash
240
+ npm test
241
+ ```
242
+
156
243
  ---
157
244
 
158
245
  ## License
package/SECURITY.md ADDED
@@ -0,0 +1,25 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 1.1.x | :white_check_mark: |
8
+ | < 1.1.0 | :x: |
9
+
10
+ ## Supply Chain Security Principles
11
+
12
+ `create-shadcn-js` adheres to strict security standards to ensure package and dependency integrity:
13
+
14
+ 1. **Strict Input Sanitization**: All user inputs (project directory, components, flags, presets, package managers) are strictly validated against strict allowlists and regex patterns to prevent command injection, flag injection, and path traversal vulnerabilities.
15
+ 2. **Zero Arbitrary Execution**: The package does not use `eval`, dynamic require, or shell string interpolation. All child processes use direct argument vector passing via `cross-spawn`.
16
+ 3. **Dependency Integrity**: Dependencies are regularly audited for known CVEs. All dependencies must have verified registry signatures and 0 vulnerabilities reported by `npm audit`.
17
+ 4. **Minimal Surface Area**: Export maps explicitly define public entrypoints, preventing unauthorized file access.
18
+
19
+ ## Reporting a Vulnerability
20
+
21
+ If you discover a security vulnerability in this project:
22
+
23
+ 1. Please do **not** open a public issue.
24
+ 2. Send an email to **skandan.studio4as@gmail.com** with details of the vulnerability, proof of concept, and affected versions.
25
+ 3. You will receive an initial response within 48 hours.
package/package.json CHANGED
@@ -1,21 +1,31 @@
1
1
  {
2
2
  "name": "create-shadcn-js",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Scaffold a Vite + React + shadcn/ui JavaScript project with zero manual configuration.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "create-shadcn-js": "./bin/cli.js"
7
+ "create-shadcn-js": "bin/cli.js"
8
8
  },
9
9
  "main": "./src/index.js",
10
+ "exports": {
11
+ ".": "./src/index.js",
12
+ "./package.json": "./package.json"
13
+ },
10
14
  "files": [
11
15
  "bin",
12
16
  "src",
13
17
  "README.md",
14
- "LICENSE"
18
+ "LICENSE",
19
+ "SECURITY.md"
15
20
  ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "sideEffects": false,
16
25
  "scripts": {
17
26
  "start": "node ./bin/cli.js",
18
- "test": "node ./bin/cli.js --help"
27
+ "test": "node --test",
28
+ "audit": "npm audit --audit-level=high"
19
29
  },
20
30
  "repository": {
21
31
  "type": "git",
@@ -42,7 +52,7 @@
42
52
  },
43
53
  "homepage": "https://github.com/Skandan-V/create-shadcn-js#readme",
44
54
  "engines": {
45
- "node": ">=18.0.0"
55
+ "node": "^20.19.0 || >=22.12.0"
46
56
  },
47
57
  "dependencies": {
48
58
  "@clack/prompts": "^0.9.1",
package/src/index.js CHANGED
@@ -6,7 +6,8 @@ import { Command } from "commander"
6
6
  import { runInteractivePrompts } from "./prompts.js"
7
7
  import { scaffoldProject } from "./scaffold.js"
8
8
  import { initShadcn, addComponents } from "./shadcn.js"
9
- import { runCommandOutput, formatPath } from "./utils.js"
9
+ import { buildCliOptions } from "./options.js"
10
+ import { runCommandOutput, formatPath, getShadcnAddCommand } from "./utils.js"
10
11
 
11
12
  // Package metadata
12
13
  const packageJson = fs.readJsonSync(
@@ -32,18 +33,19 @@ function initializeGit(targetDir) {
32
33
  }
33
34
 
34
35
  /**
35
- * Main CLI runner.
36
+ * Builds the Commander program without parsing argv. Exported so tests can
37
+ * assert that options without a default stay undefined (the interactive
38
+ * Tailwind v3 prompt depends on it).
39
+ * @returns {Command}
36
40
  */
37
- export async function run() {
38
- const program = new Command()
39
-
40
- program
41
+ export function createProgram() {
42
+ return new Command()
41
43
  .name("create-shadcn-js")
42
44
  .description("Scaffold a Vite + React + shadcn/ui JavaScript project with zero manual setup")
43
45
  .version(packageJson.version, "-v, --version", "Output the current version")
44
46
  .argument("[project-name]", "Name of the project directory")
45
47
  .option("--pm <manager>", "Package manager to use (npm, pnpm, yarn, bun)")
46
- .option("-t, --tailwind <version>", "Tailwind CSS version (v4, v3)", "v4")
48
+ .option("-t, --tailwind <version>", "Tailwind CSS version (v4, v3)")
47
49
  .option("-m, --mode <mode>", "shadcn init mode (interactive, quickstart)")
48
50
  .option("-b, --base <base>", "Component library (base, radix, aria)")
49
51
  .option("-p, --preset <preset>", "shadcn preset (nova, vega, maia, etc.)")
@@ -51,37 +53,25 @@ export async function run() {
51
53
  .option("--no-git", "Skip initializing a git repository")
52
54
  .option("-y, --yes", "Skip interactive prompts and use defaults")
53
55
  .option("-f, --force", "Overwrite existing directory without prompt")
54
- .parse(process.argv)
56
+ }
57
+
58
+ /**
59
+ * Main CLI runner.
60
+ */
61
+ export async function run() {
62
+ const program = createProgram()
63
+ program.parse(process.argv)
55
64
 
56
65
  const args = program.args
57
66
  const opts = program.opts()
58
67
 
59
- const cliOptions = {
60
- name: args[0],
61
- pm: opts.pm,
62
- tailwind: opts.tailwind,
63
- mode: opts.mode,
64
- base: opts.base,
65
- preset: opts.preset,
66
- sampleComponents: opts.sample === false ? false : undefined,
67
- git: opts.git === false ? false : undefined,
68
- force: opts.force || false,
69
- yes: opts.yes || false,
70
- }
71
-
72
- // If -y / --yes is passed, supply defaults for any missing arguments
73
- if (cliOptions.yes) {
74
- cliOptions.name = cliOptions.name || "my-shadcn-app"
75
- cliOptions.pm = cliOptions.pm || "npm"
76
- cliOptions.tailwind = cliOptions.tailwind || "v4"
77
- cliOptions.mode = cliOptions.mode || "quickstart"
78
- cliOptions.sampleComponents = cliOptions.sampleComponents ?? true
79
- cliOptions.git = cliOptions.git ?? true
80
- }
81
-
82
68
  try {
69
+ const cliOptions = buildCliOptions(args, opts)
70
+
83
71
  // 1. Run interactive prompts (or resolve defaults)
84
- const answers = await runInteractivePrompts(cliOptions)
72
+ const answers = await runInteractivePrompts(cliOptions, {
73
+ version: packageJson.version,
74
+ })
85
75
 
86
76
  // 2. Scaffold Vite React JavaScript project with Tailwind and Aliases
87
77
  await scaffoldProject({
@@ -95,6 +85,7 @@ export async function run() {
95
85
  await initShadcn({
96
86
  targetDir: answers.targetDir,
97
87
  packageManager: answers.packageManager,
88
+ tailwindVersion: answers.tailwindVersion,
98
89
  initMode: answers.initMode,
99
90
  nonInteractive: cliOptions.yes,
100
91
  base: cliOptions.base,
@@ -106,6 +97,7 @@ export async function run() {
106
97
  await addComponents({
107
98
  targetDir: answers.targetDir,
108
99
  packageManager: answers.packageManager,
100
+ tailwindVersion: answers.tailwindVersion,
109
101
  components: ["button"],
110
102
  })
111
103
  }
@@ -122,14 +114,10 @@ export async function run() {
122
114
  answers.packageManager === "npm"
123
115
  ? "npm run dev"
124
116
  : `${answers.packageManager} dev`
125
- const addCmd =
126
- answers.packageManager === "npm"
127
- ? "npx shadcn@latest add <component>"
128
- : answers.packageManager === "pnpm"
129
- ? "pnpm dlx shadcn@latest add <component>"
130
- : answers.packageManager === "bun"
131
- ? "bunx --bun shadcn@latest add <component>"
132
- : "yarn dlx shadcn@latest add <component>"
117
+ const addCmd = getShadcnAddCommand(
118
+ answers.packageManager,
119
+ answers.tailwindVersion
120
+ )
133
121
 
134
122
  p.note(
135
123
  `${pc.bold("Next steps:")}\n\n` +
package/src/options.js ADDED
@@ -0,0 +1,53 @@
1
+ import {
2
+ sanitizeBaseLibrary,
3
+ sanitizeInitMode,
4
+ sanitizePackageManager,
5
+ sanitizePreset,
6
+ sanitizeTailwindVersion,
7
+ validateProjectName,
8
+ } from "./utils.js"
9
+
10
+ /**
11
+ * Validates CLI arguments and normalizes them into the option object used by
12
+ * the prompt layer. Undefined values are intentional: they mean "ask the
13
+ * user" (or, with --yes, "use the non-interactive default").
14
+ *
15
+ * @param {string[]} args
16
+ * @param {Record<string, unknown>} opts
17
+ * @returns {object}
18
+ */
19
+ export function buildCliOptions(args, opts = {}) {
20
+ if (args[0]) {
21
+ const valid = validateProjectName(args[0])
22
+ if (typeof valid === "string") {
23
+ throw new Error(`Invalid project name: ${valid}`)
24
+ }
25
+ }
26
+
27
+ const cliOptions = {
28
+ name: args[0],
29
+ pm: opts.pm ? sanitizePackageManager(opts.pm) : undefined,
30
+ tailwind: opts.tailwind
31
+ ? sanitizeTailwindVersion(opts.tailwind)
32
+ : undefined,
33
+ mode: opts.mode ? sanitizeInitMode(opts.mode) : undefined,
34
+ base: opts.base ? sanitizeBaseLibrary(opts.base) : undefined,
35
+ preset: opts.preset ? sanitizePreset(opts.preset) : undefined,
36
+ sampleComponents: opts.sample === false ? false : undefined,
37
+ git: opts.git === false ? false : undefined,
38
+ force: opts.force || false,
39
+ yes: opts.yes || false,
40
+ }
41
+
42
+ // If -y / --yes is passed, supply defaults for any missing arguments.
43
+ if (cliOptions.yes) {
44
+ cliOptions.name = cliOptions.name || "my-shadcn-app"
45
+ cliOptions.pm = cliOptions.pm || "npm"
46
+ cliOptions.tailwind = cliOptions.tailwind || "v4"
47
+ cliOptions.mode = cliOptions.mode || "quickstart"
48
+ cliOptions.sampleComponents = cliOptions.sampleComponents ?? true
49
+ cliOptions.git = cliOptions.git ?? true
50
+ }
51
+
52
+ return cliOptions
53
+ }
package/src/prompts.js CHANGED
@@ -7,10 +7,24 @@ import { detectPackageManager, validateProjectName } from "./utils.js"
7
7
  /**
8
8
  * Handles all interactive CLI prompts using @clack/prompts.
9
9
  * @param {object} cliOptions
10
+ * @param {{ version?: string }} [metadata]
10
11
  * @returns {Promise<object>}
11
12
  */
12
- export async function runInteractivePrompts(cliOptions = {}) {
13
- p.intro(`${pc.bgCyan(pc.black(" create-shadcn-js "))} ${pc.dim("v1.0.0")}`)
13
+ export async function runInteractivePrompts(cliOptions = {}, { version } = {}) {
14
+ // run() validates first, but callers can reach this function directly.
15
+ if (cliOptions.name) {
16
+ const valid = validateProjectName(cliOptions.name)
17
+ if (typeof valid === "string") {
18
+ throw new Error(`Invalid project name: ${valid}`)
19
+ }
20
+ }
21
+
22
+ const versionLabel = version ? `v${version}` : ""
23
+ p.intro(
24
+ `${pc.bgCyan(pc.black(" create-shadcn-js "))}${
25
+ versionLabel ? ` ${pc.dim(versionLabel)}` : ""
26
+ }`
27
+ )
14
28
 
15
29
  // 1. Project name / directory
16
30
  let projectName = cliOptions.name
@@ -39,6 +53,15 @@ export async function runInteractivePrompts(cliOptions = {}) {
39
53
  // Check if directory exists and is not empty
40
54
  if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
41
55
  if (!cliOptions.force) {
56
+ // --yes promises a non-interactive run. Never delete a non-empty
57
+ // directory in that mode without an explicit --force.
58
+ if (cliOptions.yes) {
59
+ throw new Error(
60
+ `Target directory "${projectName}" is not empty. ` +
61
+ `Re-run with --force to overwrite it, or choose a different project name.`
62
+ )
63
+ }
64
+
42
65
  const overwrite = await p.confirm({
43
66
  message: `Target directory "${projectName}" is not empty. Remove existing files and continue?`,
44
67
  initialValue: false,
@@ -101,7 +124,12 @@ export async function runInteractivePrompts(cliOptions = {}) {
101
124
  }
102
125
 
103
126
  // 4. shadcn/ui initialization mode
127
+ // Tailwind v3 uses the legacy shadcn CLI with a fixed new-york theme, so
128
+ // there is no interactive library/preset choice to make.
104
129
  let initMode = cliOptions.mode
130
+ if (!initMode && tailwindVersion === "v3") {
131
+ initMode = "quickstart"
132
+ }
105
133
  if (!initMode) {
106
134
  const modeResponse = await p.select({
107
135
  message: "How would you like to configure shadcn/ui?",