@pauldvlp/vp-pkg-shadcn 0.6.0 → 0.6.2
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/LICENSE +1 -1
- package/README.md +15 -15
- package/dist/index.js +94 -21
- package/package.json +6 -5
- package/template/_package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -47,17 +47,17 @@ defaults to the **surrounding monorepo's scope** (read from the nearest `pnpm-wo
|
|
|
47
47
|
|
|
48
48
|
## Options
|
|
49
49
|
|
|
50
|
-
| Option
|
|
51
|
-
|
|
|
52
|
-
| `--scope`
|
|
53
|
-
| `--base`
|
|
54
|
-
| `--preset`
|
|
55
|
-
| `--iconLibrary`
|
|
56
|
-
| `--cssVariables
|
|
57
|
-
| `--rtl`
|
|
58
|
-
| `--pointer`
|
|
59
|
-
| `--components`
|
|
60
|
-
| `--install`
|
|
50
|
+
| Option | Type / values | Default | Notes |
|
|
51
|
+
| ---------------- | ---------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
52
|
+
| `--scope` | string | monorepo scope | npm scope for the package → `@scope/ui`. Defaults to the surrounding monorepo's scope (e.g. `@acme`), `@app` outside a workspace. `@` is added if you omit it. |
|
|
53
|
+
| `--base` | `radix` \| `base` | `radix` | shadcn component library (radix-ui or @base-ui). Honored by `shadcn init --base`. |
|
|
54
|
+
| `--preset` | style name or code | `b30557okNu` | A style (`nova`, `vega`, `maia`, `lyra`, `mira`, `luma`, `sera`, `rhea`) **or** a code from ui.shadcn.com. **Owns** color, fonts, radius, baseColor, menu styling. |
|
|
55
|
+
| `--iconLibrary` | `lucide` \| `hugeicons` \| `radix` \| `tabler` | `hugeicons` | Icon library (persists; not part of the preset). |
|
|
56
|
+
| `--cssVariables` | boolean | `true` | CSS variables for theming. |
|
|
57
|
+
| `--rtl` | boolean | `false` | RTL support. |
|
|
58
|
+
| `--pointer` | boolean | `false` | Pointer cursor on interactive elements. |
|
|
59
|
+
| `--components` | comma list | `button,badge` | shadcn components to pre-install. `button` + `badge` are always included. |
|
|
60
|
+
| `--install` | boolean | `true` | Run install + apply the shadcn theme after scaffolding. `false` = files only. |
|
|
61
61
|
|
|
62
62
|
## How it scaffolds
|
|
63
63
|
|
|
@@ -95,8 +95,8 @@ pnpm --filter <your-app> add -D @tailwindcss/vite tailwindcss
|
|
|
95
95
|
|
|
96
96
|
```ts
|
|
97
97
|
// apps/<your-app>/vite.config.ts
|
|
98
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
99
|
-
export default defineConfig({ plugins: [/* ...existing */ tailwindcss()] })
|
|
98
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
99
|
+
export default defineConfig({ plugins: [/* ...existing */ tailwindcss()] });
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
> `ui`'s `globals.css` already `@source`s `apps/**/*.{ts,tsx}` (and the `ui` package), so Tailwind
|
|
@@ -106,8 +106,8 @@ export default defineConfig({ plugins: [/* ...existing */ tailwindcss()] })
|
|
|
106
106
|
|
|
107
107
|
```tsx
|
|
108
108
|
// apps/<your-app>/src/main.tsx
|
|
109
|
-
import '@scope/ui/globals.css'
|
|
110
|
-
import { Button } from '@scope/ui/components/ui/button'
|
|
109
|
+
import '@scope/ui/globals.css';
|
|
110
|
+
import { Button } from '@scope/ui/components/ui/button';
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
## Re-theme later
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,8 @@ var RENAME = {
|
|
|
16
16
|
};
|
|
17
17
|
var DEFAULT_PRESET = "b30557okNu";
|
|
18
18
|
var ICON_LIBS = {
|
|
19
|
-
hugeicons: { "@hugeicons/react": "^1.1.9", "@hugeicons/core-free-icons": "^4.2.
|
|
20
|
-
lucide: { "lucide-react": "^
|
|
19
|
+
hugeicons: { "@hugeicons/react": "^1.1.9", "@hugeicons/core-free-icons": "^4.2.2" },
|
|
20
|
+
lucide: { "lucide-react": "^1" },
|
|
21
21
|
radix: { "@radix-ui/react-icons": "^1" },
|
|
22
22
|
tabler: { "@tabler/icons-react": "^3" }
|
|
23
23
|
};
|
|
@@ -25,8 +25,8 @@ var CATALOG = {
|
|
|
25
25
|
"@types/node": "^24",
|
|
26
26
|
typescript: "^5",
|
|
27
27
|
vite: "npm:@voidzero-dev/vite-plus-core@latest",
|
|
28
|
-
vitest: "4.1.
|
|
29
|
-
"vite-plus": "^0.2.
|
|
28
|
+
vitest: "4.1.10",
|
|
29
|
+
"vite-plus": "^0.2.4",
|
|
30
30
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
31
31
|
"@rolldown/plugin-babel": "^0.2.3"
|
|
32
32
|
};
|
|
@@ -90,11 +90,17 @@ function patchJson(tree, relPath, mutate) {
|
|
|
90
90
|
`;
|
|
91
91
|
}
|
|
92
92
|
function resolveCatalogDeps(pkg, catalog = CATALOG) {
|
|
93
|
-
for (const field of [
|
|
93
|
+
for (const field of [
|
|
94
|
+
"dependencies",
|
|
95
|
+
"devDependencies",
|
|
96
|
+
"peerDependencies",
|
|
97
|
+
"optionalDependencies"
|
|
98
|
+
]) {
|
|
94
99
|
const deps = pkg[field];
|
|
95
100
|
if (!deps) continue;
|
|
96
101
|
for (const [name, range] of Object.entries(deps)) {
|
|
97
|
-
if ((range === "catalog:" || range === "catalog:default") && catalog[name])
|
|
102
|
+
if ((range === "catalog:" || range === "catalog:default") && catalog[name])
|
|
103
|
+
deps[name] = catalog[name];
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
}
|
|
@@ -204,7 +210,10 @@ function resolveDefault(d, options, directory) {
|
|
|
204
210
|
}
|
|
205
211
|
async function promptForOption(d, def) {
|
|
206
212
|
if (d.type === "boolean") {
|
|
207
|
-
return prompts.confirm({
|
|
213
|
+
return prompts.confirm({
|
|
214
|
+
message: d.message,
|
|
215
|
+
initialValue: def === void 0 ? false : Boolean(def)
|
|
216
|
+
});
|
|
208
217
|
}
|
|
209
218
|
if (d.type === "select") {
|
|
210
219
|
return prompts.select({
|
|
@@ -249,7 +258,11 @@ function initGit(dir) {
|
|
|
249
258
|
} catch {
|
|
250
259
|
identity = ["-c", "user.name=create", "-c", "user.email=create@users.noreply.github.com"];
|
|
251
260
|
}
|
|
252
|
-
execFileSync(
|
|
261
|
+
execFileSync(
|
|
262
|
+
"git",
|
|
263
|
+
[...identity, "commit", "-m", "feat: initialize project", "--no-gpg-sign"],
|
|
264
|
+
{ cwd: dir, stdio: "ignore" }
|
|
265
|
+
);
|
|
253
266
|
} catch {
|
|
254
267
|
}
|
|
255
268
|
}
|
|
@@ -265,7 +278,11 @@ async function runTemplateCLI(template) {
|
|
|
265
278
|
let directory = dirArg;
|
|
266
279
|
if (!directory) {
|
|
267
280
|
if (interactive) {
|
|
268
|
-
const answer = await prompts.text({
|
|
281
|
+
const answer = await prompts.text({
|
|
282
|
+
message: "Where should we create your project?",
|
|
283
|
+
placeholder: "my-app",
|
|
284
|
+
defaultValue: "my-app"
|
|
285
|
+
});
|
|
269
286
|
if (prompts.isCancel(answer)) {
|
|
270
287
|
prompts.cancel("Cancelled.");
|
|
271
288
|
return 2;
|
|
@@ -307,7 +324,11 @@ async function runTemplateCLI(template) {
|
|
|
307
324
|
for (const step of [...creation.scripts].sort((a, b) => a.phase - b.phase)) {
|
|
308
325
|
for (const [program, ...commandArgs] of step.commands) {
|
|
309
326
|
if (!program) continue;
|
|
310
|
-
execFileSync(program, commandArgs, {
|
|
327
|
+
execFileSync(program, commandArgs, {
|
|
328
|
+
cwd: directory,
|
|
329
|
+
stdio: "inherit",
|
|
330
|
+
shell: process.platform === "win32"
|
|
331
|
+
});
|
|
311
332
|
}
|
|
312
333
|
}
|
|
313
334
|
}
|
|
@@ -337,15 +358,60 @@ var template_default = defineTemplate({
|
|
|
337
358
|
options: [
|
|
338
359
|
// Default the scope to the surrounding monorepo's scope (e.g. `@acme`) so it tracks the repo
|
|
339
360
|
// instead of a fixed `@app`. Falls back to `@app` when run outside a pnpm workspace.
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
361
|
+
{
|
|
362
|
+
key: "scope",
|
|
363
|
+
type: "string",
|
|
364
|
+
message: "npm scope for the workspace package, e.g. @acme",
|
|
365
|
+
default: () => detectMonorepoScope() ?? "@app",
|
|
366
|
+
validate: validateScope
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
key: "base",
|
|
370
|
+
type: "select",
|
|
371
|
+
message: "shadcn component library base (radix-ui or @base-ui)",
|
|
372
|
+
choices: ["radix", "base"],
|
|
373
|
+
default: "radix"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
key: "preset",
|
|
377
|
+
type: "string",
|
|
378
|
+
message: "shadcn preset: a style name (nova, vega, maia, lyra, mira, luma, sera, rhea) or a code from ui.shadcn.com",
|
|
379
|
+
default: DEFAULT_PRESET,
|
|
380
|
+
validate: validatePreset
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
key: "iconLibrary",
|
|
384
|
+
type: "select",
|
|
385
|
+
message: "Icon library",
|
|
386
|
+
choices: ["lucide", "hugeicons", "radix", "tabler"],
|
|
387
|
+
default: "hugeicons"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
key: "cssVariables",
|
|
391
|
+
type: "boolean",
|
|
392
|
+
message: "Use CSS variables for theming",
|
|
393
|
+
default: true
|
|
394
|
+
},
|
|
345
395
|
{ key: "rtl", type: "boolean", message: "Enable RTL support", default: false },
|
|
346
|
-
{
|
|
347
|
-
|
|
348
|
-
|
|
396
|
+
{
|
|
397
|
+
key: "pointer",
|
|
398
|
+
type: "boolean",
|
|
399
|
+
message: "Use pointer cursor on interactive elements",
|
|
400
|
+
default: false
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
key: "components",
|
|
404
|
+
type: "string",
|
|
405
|
+
message: "Comma-separated shadcn components to pre-install, e.g. button,card,dialog",
|
|
406
|
+
default: "button,badge",
|
|
407
|
+
validate: validateComponents
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
key: "install",
|
|
411
|
+
type: "boolean",
|
|
412
|
+
message: "Install deps and apply the shadcn theme after scaffolding",
|
|
413
|
+
default: true
|
|
414
|
+
}
|
|
349
415
|
],
|
|
350
416
|
async produce({ options }) {
|
|
351
417
|
const scope = toScope(options.scope || "app");
|
|
@@ -354,15 +420,22 @@ var template_default = defineTemplate({
|
|
|
354
420
|
resolveCatalogDeps(pkg);
|
|
355
421
|
addIconDeps(pkg, options.iconLibrary);
|
|
356
422
|
});
|
|
357
|
-
setPath(
|
|
358
|
-
|
|
423
|
+
setPath(
|
|
424
|
+
files,
|
|
425
|
+
"components.json",
|
|
426
|
+
`${JSON.stringify(uiComponentsJson({ ...options, scope }), null, 2)}
|
|
427
|
+
`
|
|
428
|
+
);
|
|
359
429
|
const adds = withRequiredComponents(options.components);
|
|
360
430
|
const ui = `${scope}/ui`;
|
|
361
431
|
const initArgs = shadcnInitArgs(options);
|
|
362
432
|
const scripts = options.install ? [
|
|
363
433
|
{ commands: [["pnpm", "install", "--silent"]], phase: 0 },
|
|
364
434
|
{ commands: [["pnpm", "--filter", ui, "exec", "shadcn", "init", ...initArgs]], phase: 1 },
|
|
365
|
-
{
|
|
435
|
+
{
|
|
436
|
+
commands: [["pnpm", "--filter", ui, "exec", "shadcn", "add", ...adds, "-y"]],
|
|
437
|
+
phase: 2
|
|
438
|
+
}
|
|
366
439
|
] : [];
|
|
367
440
|
return {
|
|
368
441
|
files,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pauldvlp/vp-pkg-shadcn",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Add a shared, fully customizable shadcn UI package (packages/ui) into an existing Vite+ monorepo, themeable via shadcn presets.",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "Paul Barahona <johanpaulbarahona@gmail.com> (https://github.com/pauldvlp/vp-templates)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/pauldvlp/vp-templates",
|
|
8
8
|
"repository": {
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"template"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@clack/prompts": "^1.
|
|
27
|
+
"@clack/prompts": "^1.7.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^24",
|
|
31
|
-
"esbuild": "^0.
|
|
31
|
+
"esbuild": "^0.28.0",
|
|
32
32
|
"typescript": "^5",
|
|
33
33
|
"@pauldvlp/template-kit": "0.0.0"
|
|
34
34
|
},
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "esbuild bin/index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --target=node22 --packages=external",
|
|
40
|
-
"dev": "node bin/index.ts"
|
|
40
|
+
"dev": "node bin/index.ts",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
41
42
|
},
|
|
42
43
|
"bin": {
|
|
43
44
|
"vp-pkg-shadcn": "./dist/index.js"
|
package/template/_package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@fontsource-variable/space-grotesk": "^5.2.10",
|
|
21
21
|
"class-variance-authority": "^0.7.1",
|
|
22
22
|
"clsx": "^2.1.1",
|
|
23
|
-
"shadcn": "^4.
|
|
23
|
+
"shadcn": "^4.13.0",
|
|
24
24
|
"tailwind-merge": "^3.6.0",
|
|
25
25
|
"tw-animate-css": "^1.4.0"
|
|
26
26
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@tailwindcss/vite": "^4",
|
|
29
29
|
"@types/react": "^19.2.17",
|
|
30
30
|
"@types/react-dom": "^19.2.3",
|
|
31
|
-
"@vitejs/plugin-react": "^6.0.
|
|
31
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
32
32
|
"react": "^19.2.7",
|
|
33
33
|
"react-dom": "^19.2.7",
|
|
34
34
|
"tailwindcss": "^4",
|