@pauldvlp/vp-react-ts-shadcn 0.3.2 → 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 (2) hide show
  1. package/dist/index.js +131 -105
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -4,59 +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.2",
17
- description: "Vite+ monorepo template: one frontend app (website) + a shared shadcn UI package, themeable via shadcn presets.",
18
- author: "pauldvlp (https://github.com/pauldvlp/vp-templates)",
19
- homepage: "https://github.com/pauldvlp/vp-templates",
20
- repository: {
21
- type: "git",
22
- url: "git+https://github.com/pauldvlp/vp-templates.git",
23
- directory: "packages/vp-react-ts-shadcn"
24
- },
25
- bugs: "https://github.com/pauldvlp/vp-templates/issues",
26
- keywords: [
27
- "vite-plus-generator",
28
- "vite-plus",
29
- "shadcn",
30
- "react",
31
- "template"
32
- ],
33
- bin: "./dist/index.js",
34
- type: "module",
35
- files: [
36
- "dist",
37
- "template"
38
- ],
39
- scripts: {
40
- build: "esbuild bin/index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --target=node22 --packages=external",
41
- dev: "node bin/index.ts",
42
- prepack: "pnpm run build"
43
- },
44
- dependencies: {
45
- bingo: "^0.9.3",
46
- zod: "^3.25.76"
47
- },
48
- devDependencies: {
49
- "@types/node": "^24",
50
- esbuild: "^0.25.0",
51
- typescript: "^5"
52
- },
53
- engines: {
54
- node: ">=22.18.0"
55
- }
56
- };
57
-
58
- // src/template.ts
59
- 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";
60
13
  var RENAME = {
61
14
  _gitignore: ".gitignore"
62
15
  };
@@ -105,6 +58,118 @@ function patchJson(tree, relPath, mutate) {
105
58
  node[key] = `${JSON.stringify(json, null, 2)}
106
59
  `;
107
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");
108
173
  var template_default = createTemplate({
109
174
  about: {
110
175
  name: package_default.name,
@@ -113,9 +178,12 @@ var template_default = createTemplate({
113
178
  options: {
114
179
  name: z.string().describe("Root project / package name").default("my-app"),
115
180
  scope: z.string().describe("npm scope for workspace packages, e.g. @acme (defaults to @<name>)"),
116
- 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"),
117
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),
118
- 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"),
119
187
  cssVariables: z.boolean().describe("Use CSS variables for theming").default(true),
120
188
  rtl: z.boolean().describe("Enable RTL support").default(false),
121
189
  pointer: z.boolean().describe("Use pointer cursor on interactive elements").default(false),
@@ -135,62 +203,20 @@ var template_default = createTemplate({
135
203
  TEMPLATE_DIR,
136
204
  (_rel, content) => content.split("@app").join(scope).split("__PROJECT_NAME__").join(options.name)
137
205
  );
138
- const uiComponentsJson = {
139
- $schema: "https://ui.shadcn.com/schema.json",
140
- style: `${options.base}-nova`,
141
- rsc: false,
142
- tsx: true,
143
- tailwind: { config: "", css: "./src/styles/globals.css", baseColor: "neutral", cssVariables: options.cssVariables },
144
- iconLibrary: options.iconLibrary,
145
- rtl: options.rtl,
146
- base: options.base,
147
- aliases: {
148
- components: `${scope}/ui/components`,
149
- ui: `${scope}/ui/components`,
150
- lib: `${scope}/ui/lib`,
151
- utils: `${scope}/ui/lib/utils`,
152
- hooks: `${scope}/ui/hooks`
153
- }
154
- };
155
- const websiteComponentsJson = {
156
- $schema: "https://ui.shadcn.com/schema.json",
157
- style: `${options.base}-nova`,
158
- rsc: false,
159
- tsx: true,
160
- tailwind: { config: "", css: "../../packages/ui/src/styles/globals.css", baseColor: "neutral", cssVariables: options.cssVariables },
161
- iconLibrary: options.iconLibrary,
162
- rtl: options.rtl,
163
- aliases: {
164
- components: "@/components",
165
- hooks: "@/hooks",
166
- lib: "@/lib",
167
- utils: `${scope}/ui/lib/utils`,
168
- ui: `${scope}/ui/components`
169
- }
170
- };
171
- 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)}
172
207
  `);
173
- setPath(files, "apps/website/components.json", `${JSON.stringify(websiteComponentsJson, null, 2)}
174
- `);
175
- 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
+ );
176
214
  for (const rel of ["packages/ui/package.json", "apps/website/package.json"]) {
177
- patchJson(files, rel, (pkg) => {
178
- pkg.dependencies = { ...pkg.dependencies, ...iconDeps };
179
- });
215
+ patchJson(files, rel, (pkg) => addIconDeps(pkg, options.iconLibrary));
180
216
  }
181
- const requested = options.components.split(",").map((c) => c.trim()).filter(Boolean);
182
- const adds = Array.from(/* @__PURE__ */ new Set(["button", "badge", ...requested]));
217
+ const adds = withRequiredComponents(options.components);
183
218
  const ui = `${scope}/ui`;
184
- const initFlags = [
185
- `--base ${options.base}`,
186
- `--preset ${options.preset}`,
187
- options.cssVariables ? "--css-variables" : "--no-css-variables",
188
- options.rtl ? "--rtl" : "--no-rtl",
189
- options.pointer ? "--pointer" : "--no-pointer",
190
- "--no-reinstall",
191
- "-y",
192
- "-f"
193
- ].join(" ");
219
+ const initFlags = shadcnInitFlags(options);
194
220
  const scripts = options.install ? [
195
221
  { commands: ["pnpm install --silent"], phase: 0 },
196
222
  { commands: [`pnpm --filter ${ui} exec shadcn init ${initFlags}`], phase: 1 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pauldvlp/vp-react-ts-shadcn",
3
- "version": "0.3.2",
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
5
  "author": "pauldvlp (https://github.com/pauldvlp/vp-templates)",
6
6
  "homepage": "https://github.com/pauldvlp/vp-templates",
@@ -29,7 +29,8 @@
29
29
  "devDependencies": {
30
30
  "@types/node": "^24",
31
31
  "esbuild": "^0.25.0",
32
- "typescript": "^5"
32
+ "typescript": "^5",
33
+ "@pauldvlp/template-kit": "0.0.0"
33
34
  },
34
35
  "engines": {
35
36
  "node": ">=22.18.0"