@pauldvlp/vp-react-ts-shadcn 0.3.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +6 -2
  2. package/dist/index.js +131 -97
  3. package/package.json +11 -2
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/pauldvlp/vp-templates/main/assets/cover.webp" alt="@pauldvlp/vp-templates" width="100%" />
3
+ </p>
4
+
1
5
  # @pauldvlp/vp-react-ts-shadcn
2
6
 
3
7
  A [Vite+](https://viteplus.dev) **monorepo generator** that scaffolds a minimal front-end workspace:
@@ -15,10 +19,10 @@ Published under the [`@pauldvlp/create`](../create) manifest:
15
19
 
16
20
  ```bash
17
21
  # Interactive (prompts for anything you don't pass)
18
- vp create @pauldvlp:react-ts-shadcn
22
+ vp create @pauldvlp:vp-react-ts-shadcn
19
23
 
20
24
  # Non-interactive, fully specified
21
- vp create @pauldvlp:react-ts-shadcn -- \
25
+ vp create @pauldvlp:vp-react-ts-shadcn -- \
22
26
  --name my-app --scope @acme --base base --preset vega --iconLibrary lucide --components button,card,dialog
23
27
  ```
24
28
 
package/dist/index.js CHANGED
@@ -4,51 +4,12 @@
4
4
  import { runTemplateCLI } from "bingo";
5
5
 
6
6
  // src/template.ts
7
- import fs from "node:fs";
8
- import path from "node:path";
7
+ import path2 from "node:path";
9
8
  import { fileURLToPath } from "node:url";
10
- import { createTemplate } from "bingo";
11
- import { z } from "zod";
12
9
 
13
- // package.json
14
- var package_default = {
15
- name: "@pauldvlp/vp-react-ts-shadcn",
16
- version: "0.3.1",
17
- description: "Vite+ monorepo template: one frontend app (website) + a shared shadcn UI package, themeable via shadcn presets.",
18
- keywords: [
19
- "vite-plus-generator",
20
- "vite-plus",
21
- "shadcn",
22
- "react",
23
- "template"
24
- ],
25
- bin: "./dist/index.js",
26
- type: "module",
27
- files: [
28
- "dist",
29
- "template"
30
- ],
31
- scripts: {
32
- build: "esbuild bin/index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --target=node22 --packages=external",
33
- dev: "node bin/index.ts",
34
- prepack: "pnpm run build"
35
- },
36
- dependencies: {
37
- bingo: "^0.9.3",
38
- zod: "^3.25.76"
39
- },
40
- devDependencies: {
41
- "@types/node": "^24",
42
- esbuild: "^0.25.0",
43
- typescript: "^5"
44
- },
45
- engines: {
46
- node: ">=22.18.0"
47
- }
48
- };
49
-
50
- // src/template.ts
51
- var TEMPLATE_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "template");
10
+ // ../template-kit/src/index.ts
11
+ import fs from "node:fs";
12
+ import path from "node:path";
52
13
  var RENAME = {
53
14
  _gitignore: ".gitignore"
54
15
  };
@@ -97,6 +58,118 @@ function patchJson(tree, relPath, mutate) {
97
58
  node[key] = `${JSON.stringify(json, null, 2)}
98
59
  `;
99
60
  }
61
+ function addIconDeps(pkg, iconLibrary) {
62
+ const iconDeps = ICON_LIBS[iconLibrary] ?? ICON_LIBS.hugeicons;
63
+ pkg.dependencies = { ...pkg.dependencies, ...iconDeps };
64
+ }
65
+ function withRequiredComponents(csv, required = ["button", "badge"]) {
66
+ const requested = csv.split(",").map((c) => c.trim()).filter(Boolean);
67
+ return Array.from(/* @__PURE__ */ new Set([...required, ...requested]));
68
+ }
69
+ function uiComponentsJson(theme) {
70
+ const { scope, base, cssVariables, iconLibrary, rtl } = theme;
71
+ return {
72
+ $schema: "https://ui.shadcn.com/schema.json",
73
+ style: `${base}-nova`,
74
+ rsc: false,
75
+ tsx: true,
76
+ tailwind: { config: "", css: "./src/styles/globals.css", baseColor: "neutral", cssVariables },
77
+ iconLibrary,
78
+ rtl,
79
+ base,
80
+ aliases: {
81
+ components: `${scope}/ui/components`,
82
+ ui: `${scope}/ui/components`,
83
+ lib: `${scope}/ui/lib`,
84
+ utils: `${scope}/ui/lib/utils`,
85
+ hooks: `${scope}/ui/hooks`
86
+ }
87
+ };
88
+ }
89
+ function appComponentsJson(theme) {
90
+ const { scope, base, cssVariables, iconLibrary, rtl, cssPath } = theme;
91
+ return {
92
+ $schema: "https://ui.shadcn.com/schema.json",
93
+ style: `${base}-nova`,
94
+ rsc: false,
95
+ tsx: true,
96
+ tailwind: { config: "", css: cssPath, baseColor: "neutral", cssVariables },
97
+ iconLibrary,
98
+ rtl,
99
+ aliases: {
100
+ components: "@/components",
101
+ hooks: "@/hooks",
102
+ lib: "@/lib",
103
+ utils: `${scope}/ui/lib/utils`,
104
+ ui: `${scope}/ui/components`
105
+ }
106
+ };
107
+ }
108
+ function shadcnInitFlags(opts) {
109
+ return [
110
+ `--base ${opts.base}`,
111
+ `--preset ${opts.preset}`,
112
+ opts.cssVariables ? "--css-variables" : "--no-css-variables",
113
+ opts.rtl ? "--rtl" : "--no-rtl",
114
+ opts.pointer ? "--pointer" : "--no-pointer",
115
+ "--no-reinstall",
116
+ "-y",
117
+ "-f"
118
+ ].join(" ");
119
+ }
120
+
121
+ // src/template.ts
122
+ import { createTemplate } from "bingo";
123
+ import { z } from "zod";
124
+
125
+ // package.json
126
+ var package_default = {
127
+ name: "@pauldvlp/vp-react-ts-shadcn",
128
+ version: "0.4.0",
129
+ description: "Vite+ monorepo template: one frontend app (website) + a shared shadcn UI package, themeable via shadcn presets.",
130
+ author: "pauldvlp (https://github.com/pauldvlp/vp-templates)",
131
+ homepage: "https://github.com/pauldvlp/vp-templates",
132
+ repository: {
133
+ type: "git",
134
+ url: "git+https://github.com/pauldvlp/vp-templates.git",
135
+ directory: "packages/vp-react-ts-shadcn"
136
+ },
137
+ bugs: "https://github.com/pauldvlp/vp-templates/issues",
138
+ keywords: [
139
+ "vite-plus-generator",
140
+ "vite-plus",
141
+ "shadcn",
142
+ "react",
143
+ "template"
144
+ ],
145
+ bin: "./dist/index.js",
146
+ type: "module",
147
+ files: [
148
+ "dist",
149
+ "template"
150
+ ],
151
+ scripts: {
152
+ build: "esbuild bin/index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --target=node22 --packages=external",
153
+ dev: "node bin/index.ts",
154
+ prepack: "pnpm run build"
155
+ },
156
+ dependencies: {
157
+ bingo: "^0.9.3",
158
+ zod: "^3.25.76"
159
+ },
160
+ devDependencies: {
161
+ "@pauldvlp/template-kit": "workspace:*",
162
+ "@types/node": "^24",
163
+ esbuild: "^0.25.0",
164
+ typescript: "^5"
165
+ },
166
+ engines: {
167
+ node: ">=22.18.0"
168
+ }
169
+ };
170
+
171
+ // src/template.ts
172
+ var TEMPLATE_DIR = path2.join(path2.dirname(fileURLToPath(import.meta.url)), "..", "template");
100
173
  var template_default = createTemplate({
101
174
  about: {
102
175
  name: package_default.name,
@@ -105,9 +178,12 @@ var template_default = createTemplate({
105
178
  options: {
106
179
  name: z.string().describe("Root project / package name").default("my-app"),
107
180
  scope: z.string().describe("npm scope for workspace packages, e.g. @acme (defaults to @<name>)"),
108
- base: z.enum(["radix", "base"]).describe("shadcn component library base (radix-ui or @base-ui)").default("radix"),
181
+ // Unions of literals (not z.enum) so the value is settable on Bingo's CLI: bingo's arg parser
182
+ // handles ZodUnion/ZodLiteral but not ZodEnum (a bare `--base radix` would otherwise mis-parse to
183
+ // `base: true`). Both still render as an interactive `select`.
184
+ base: z.union([z.literal("radix"), z.literal("base")]).describe("shadcn component library base (radix-ui or @base-ui)").default("radix"),
109
185
  preset: z.string().describe("shadcn preset: a style name (nova, vega, maia, lyra, mira, luma, sera, rhea) or a code from ui.shadcn.com").default(DEFAULT_PRESET),
110
- iconLibrary: z.enum(["lucide", "hugeicons", "radix", "tabler"]).describe("Icon library").default("hugeicons"),
186
+ iconLibrary: z.union([z.literal("lucide"), z.literal("hugeicons"), z.literal("radix"), z.literal("tabler")]).describe("Icon library").default("hugeicons"),
111
187
  cssVariables: z.boolean().describe("Use CSS variables for theming").default(true),
112
188
  rtl: z.boolean().describe("Enable RTL support").default(false),
113
189
  pointer: z.boolean().describe("Use pointer cursor on interactive elements").default(false),
@@ -127,62 +203,20 @@ var template_default = createTemplate({
127
203
  TEMPLATE_DIR,
128
204
  (_rel, content) => content.split("@app").join(scope).split("__PROJECT_NAME__").join(options.name)
129
205
  );
130
- const uiComponentsJson = {
131
- $schema: "https://ui.shadcn.com/schema.json",
132
- style: `${options.base}-nova`,
133
- rsc: false,
134
- tsx: true,
135
- tailwind: { config: "", css: "./src/styles/globals.css", baseColor: "neutral", cssVariables: options.cssVariables },
136
- iconLibrary: options.iconLibrary,
137
- rtl: options.rtl,
138
- base: options.base,
139
- aliases: {
140
- components: `${scope}/ui/components`,
141
- ui: `${scope}/ui/components`,
142
- lib: `${scope}/ui/lib`,
143
- utils: `${scope}/ui/lib/utils`,
144
- hooks: `${scope}/ui/hooks`
145
- }
146
- };
147
- const websiteComponentsJson = {
148
- $schema: "https://ui.shadcn.com/schema.json",
149
- style: `${options.base}-nova`,
150
- rsc: false,
151
- tsx: true,
152
- tailwind: { config: "", css: "../../packages/ui/src/styles/globals.css", baseColor: "neutral", cssVariables: options.cssVariables },
153
- iconLibrary: options.iconLibrary,
154
- rtl: options.rtl,
155
- aliases: {
156
- components: "@/components",
157
- hooks: "@/hooks",
158
- lib: "@/lib",
159
- utils: `${scope}/ui/lib/utils`,
160
- ui: `${scope}/ui/components`
161
- }
162
- };
163
- setPath(files, "packages/ui/components.json", `${JSON.stringify(uiComponentsJson, null, 2)}
206
+ setPath(files, "packages/ui/components.json", `${JSON.stringify(uiComponentsJson({ ...options, scope }), null, 2)}
164
207
  `);
165
- setPath(files, "apps/website/components.json", `${JSON.stringify(websiteComponentsJson, null, 2)}
166
- `);
167
- const iconDeps = ICON_LIBS[options.iconLibrary] ?? ICON_LIBS.hugeicons;
208
+ setPath(
209
+ files,
210
+ "apps/website/components.json",
211
+ `${JSON.stringify(appComponentsJson({ ...options, scope, cssPath: "../../packages/ui/src/styles/globals.css" }), null, 2)}
212
+ `
213
+ );
168
214
  for (const rel of ["packages/ui/package.json", "apps/website/package.json"]) {
169
- patchJson(files, rel, (pkg) => {
170
- pkg.dependencies = { ...pkg.dependencies, ...iconDeps };
171
- });
215
+ patchJson(files, rel, (pkg) => addIconDeps(pkg, options.iconLibrary));
172
216
  }
173
- const requested = options.components.split(",").map((c) => c.trim()).filter(Boolean);
174
- const adds = Array.from(/* @__PURE__ */ new Set(["button", "badge", ...requested]));
217
+ const adds = withRequiredComponents(options.components);
175
218
  const ui = `${scope}/ui`;
176
- const initFlags = [
177
- `--base ${options.base}`,
178
- `--preset ${options.preset}`,
179
- options.cssVariables ? "--css-variables" : "--no-css-variables",
180
- options.rtl ? "--rtl" : "--no-rtl",
181
- options.pointer ? "--pointer" : "--no-pointer",
182
- "--no-reinstall",
183
- "-y",
184
- "-f"
185
- ].join(" ");
219
+ const initFlags = shadcnInitFlags(options);
186
220
  const scripts = options.install ? [
187
221
  { commands: ["pnpm install --silent"], phase: 0 },
188
222
  { commands: [`pnpm --filter ${ui} exec shadcn init ${initFlags}`], phase: 1 },
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@pauldvlp/vp-react-ts-shadcn",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Vite+ monorepo template: one frontend app (website) + a shared shadcn UI package, themeable via shadcn presets.",
5
+ "author": "pauldvlp (https://github.com/pauldvlp/vp-templates)",
6
+ "homepage": "https://github.com/pauldvlp/vp-templates",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/pauldvlp/vp-templates.git",
10
+ "directory": "packages/vp-react-ts-shadcn"
11
+ },
12
+ "bugs": "https://github.com/pauldvlp/vp-templates/issues",
5
13
  "keywords": [
6
14
  "vite-plus-generator",
7
15
  "vite-plus",
@@ -21,7 +29,8 @@
21
29
  "devDependencies": {
22
30
  "@types/node": "^24",
23
31
  "esbuild": "^0.25.0",
24
- "typescript": "^5"
32
+ "typescript": "^5",
33
+ "@pauldvlp/template-kit": "0.0.0"
25
34
  },
26
35
  "engines": {
27
36
  "node": ">=22.18.0"