trix-ui 0.0.1

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 (115) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +215 -0
  3. package/dist/commands/add-section.d.ts +2 -0
  4. package/dist/commands/add-section.js +94 -0
  5. package/dist/commands/add-section.js.map +1 -0
  6. package/dist/commands/add-wrapper.d.ts +2 -0
  7. package/dist/commands/add-wrapper.js +94 -0
  8. package/dist/commands/add-wrapper.js.map +1 -0
  9. package/dist/commands/add.d.ts +2 -0
  10. package/dist/commands/add.js +53 -0
  11. package/dist/commands/add.js.map +1 -0
  12. package/dist/commands/build.d.ts +2 -0
  13. package/dist/commands/build.js +105 -0
  14. package/dist/commands/build.js.map +1 -0
  15. package/dist/commands/doctor.d.ts +2 -0
  16. package/dist/commands/doctor.js +63 -0
  17. package/dist/commands/doctor.js.map +1 -0
  18. package/dist/commands/init.d.ts +2 -0
  19. package/dist/commands/init.js +44 -0
  20. package/dist/commands/init.js.map +1 -0
  21. package/dist/commands/list-sections.d.ts +2 -0
  22. package/dist/commands/list-sections.js +25 -0
  23. package/dist/commands/list-sections.js.map +1 -0
  24. package/dist/commands/list-wrappers.d.ts +2 -0
  25. package/dist/commands/list-wrappers.js +25 -0
  26. package/dist/commands/list-wrappers.js.map +1 -0
  27. package/dist/commands/list.d.ts +2 -0
  28. package/dist/commands/list.js +20 -0
  29. package/dist/commands/list.js.map +1 -0
  30. package/dist/commands/remove-section.d.ts +2 -0
  31. package/dist/commands/remove-section.js +62 -0
  32. package/dist/commands/remove-section.js.map +1 -0
  33. package/dist/commands/remove-wrapper.d.ts +2 -0
  34. package/dist/commands/remove-wrapper.js +62 -0
  35. package/dist/commands/remove-wrapper.js.map +1 -0
  36. package/dist/commands/remove.d.ts +2 -0
  37. package/dist/commands/remove.js +61 -0
  38. package/dist/commands/remove.js.map +1 -0
  39. package/dist/icons/index.d.ts +1 -0
  40. package/dist/icons/index.js +2 -0
  41. package/dist/icons/index.js.map +1 -0
  42. package/dist/icons/libraries.d.ts +37 -0
  43. package/dist/icons/libraries.js +35 -0
  44. package/dist/icons/libraries.js.map +1 -0
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.js +36 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/lib/config.d.ts +21 -0
  49. package/dist/lib/config.js +61 -0
  50. package/dist/lib/config.js.map +1 -0
  51. package/dist/lib/fs.d.ts +6 -0
  52. package/dist/lib/fs.js +43 -0
  53. package/dist/lib/fs.js.map +1 -0
  54. package/dist/lib/install.d.ts +19 -0
  55. package/dist/lib/install.js +48 -0
  56. package/dist/lib/install.js.map +1 -0
  57. package/dist/lib/lockfile.d.ts +16 -0
  58. package/dist/lib/lockfile.js +44 -0
  59. package/dist/lib/lockfile.js.map +1 -0
  60. package/dist/lib/paths.d.ts +11 -0
  61. package/dist/lib/paths.js +25 -0
  62. package/dist/lib/paths.js.map +1 -0
  63. package/dist/lib/registry.d.ts +26 -0
  64. package/dist/lib/registry.js +20 -0
  65. package/dist/lib/registry.js.map +1 -0
  66. package/dist/schema/index.d.ts +1128 -0
  67. package/dist/schema/index.js +239 -0
  68. package/dist/schema/index.js.map +1 -0
  69. package/dist/styles/create-style-map.d.ts +4 -0
  70. package/dist/styles/create-style-map.js +69 -0
  71. package/dist/styles/create-style-map.js.map +1 -0
  72. package/dist/styles/transform-style-map.d.ts +3 -0
  73. package/dist/styles/transform-style-map.js +429 -0
  74. package/dist/styles/transform-style-map.js.map +1 -0
  75. package/dist/styles/transform.d.ts +10 -0
  76. package/dist/styles/transform.js +16 -0
  77. package/dist/styles/transform.js.map +1 -0
  78. package/dist/utils/index.d.ts +6 -0
  79. package/dist/utils/index.js +6 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/dist/utils/transformers/transform-icons.d.ts +2 -0
  82. package/dist/utils/transformers/transform-icons.js +165 -0
  83. package/dist/utils/transformers/transform-icons.js.map +1 -0
  84. package/dist/utils/transformers/transform-menu.d.ts +2 -0
  85. package/dist/utils/transformers/transform-menu.js +40 -0
  86. package/dist/utils/transformers/transform-menu.js.map +1 -0
  87. package/dist/utils/transformers/transform-render.d.ts +2 -0
  88. package/dist/utils/transformers/transform-render.js +98 -0
  89. package/dist/utils/transformers/transform-render.js.map +1 -0
  90. package/dist/utils/transformers/types.d.ts +14 -0
  91. package/dist/utils/transformers/types.js +2 -0
  92. package/dist/utils/transformers/types.js.map +1 -0
  93. package/package.json +59 -0
  94. package/registry/index.json +242 -0
  95. package/tailwind.css +95 -0
  96. package/templates/components/ui/badge.tsx +32 -0
  97. package/templates/components/ui/button.tsx +44 -0
  98. package/templates/components/ui/card.tsx +75 -0
  99. package/templates/components/ui/checkbox.tsx +33 -0
  100. package/templates/components/ui/dialog.tsx +92 -0
  101. package/templates/components/ui/dropdown.tsx +75 -0
  102. package/templates/components/ui/input.tsx +23 -0
  103. package/templates/components/ui/select.tsx +24 -0
  104. package/templates/components/ui/switch.tsx +27 -0
  105. package/templates/components/ui/tabs.tsx +50 -0
  106. package/templates/components/ui/textarea.tsx +22 -0
  107. package/templates/components/ui/toast.tsx +100 -0
  108. package/templates/lib/utils.ts +6 -0
  109. package/templates/sections/cta.tsx +22 -0
  110. package/templates/sections/feature-grid.tsx +62 -0
  111. package/templates/sections/hero.tsx +63 -0
  112. package/templates/styles/globals.css +75 -0
  113. package/templates/wrappers/border-wrapper.tsx +34 -0
  114. package/templates/wrappers/glow-wrapper.tsx +31 -0
  115. package/templates/wrappers/lift-wrapper.tsx +27 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 shadcn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # trix-ui
2
+
3
+ A small, registry-driven CLI that installs minimal, accessible UI components into your app.
4
+
5
+ ## Install
6
+
7
+ Use it with npx or install as a dev dependency.
8
+
9
+ ```bash
10
+ npx trix-ui init
11
+ ```
12
+
13
+ ```bash
14
+ npm install -D trix-ui
15
+ ui init
16
+ ```
17
+
18
+ ## Quickstart
19
+
20
+ ```bash
21
+ npx trix-ui init
22
+ npx trix-ui add button card dialog
23
+ npx trix-ui add-section hero
24
+ npx trix-ui add-wrapper glow-wrapper
25
+ npx trix-ui remove button
26
+ npx trix-ui remove-section hero
27
+ npx trix-ui remove-wrapper glow-wrapper
28
+ npx trix-ui list
29
+ npx trix-ui list-sections
30
+ npx trix-ui list-wrappers
31
+ npx trix-ui doctor
32
+ ```
33
+
34
+ ## Commands
35
+
36
+ - `ui init` - Creates `components.json`, `components/ui`, `lib/utils.ts`, `styles/globals.css`, and `.ui/lock.json`.
37
+ - `ui add <component...>` - Copies templates into `components/ui` and updates `.ui/lock.json`.
38
+ - `ui add-section <section...>` - Copies section templates into `components/sections` and updates `.ui/lock.json`.
39
+ - `ui add-wrapper <wrapper...>` - Copies wrapper templates into `components/wrappers` and updates `.ui/lock.json`.
40
+ - `ui remove <component...>` - Removes only files tracked in `.ui/lock.json` (safe by default).
41
+ - `ui remove-section <section...>` - Removes only section files tracked in `.ui/lock.json` (safe by default).
42
+ - `ui remove-wrapper <wrapper...>` - Removes only wrapper files tracked in `.ui/lock.json` (safe by default).
43
+ - `ui list` - Lists registry components.
44
+ - `ui list-sections` - Lists registry sections.
45
+ - `ui list-wrappers` - Lists registry wrappers.
46
+ - `ui doctor` - Checks config, registry, and required files.
47
+
48
+ ## Config (components.json)
49
+
50
+ ```json
51
+ {
52
+ "schemaVersion": 1,
53
+ "registry": {
54
+ "type": "bundled"
55
+ },
56
+ "paths": {
57
+ "components": "components/ui",
58
+ "sections": "components/sections",
59
+ "wrappers": "components/wrappers",
60
+ "lib": "lib",
61
+ "utils": "lib/utils.ts",
62
+ "styles": "styles/globals.css"
63
+ },
64
+ "barrel": false
65
+ }
66
+ ```
67
+
68
+ Notes:
69
+ - `registry.type`:
70
+ - `bundled` uses the registry packaged with the CLI (default).
71
+ - Set `barrel: true` and run `ui init --barrel` to create `components/ui/index.ts`.
72
+
73
+ ## Registry format
74
+
75
+ `registry/index.json`:
76
+
77
+ ```json
78
+ {
79
+ "version": 1,
80
+ "components": [
81
+ {
82
+ "name": "button",
83
+ "description": "Button with variants and focus ring.",
84
+ "files": [
85
+ {
86
+ "source": "components/ui/button.tsx",
87
+ "target": "{{components}}/button.tsx"
88
+ }
89
+ ],
90
+ "dependencies": {
91
+ "npm": ["clsx", "tailwind-merge"]
92
+ }
93
+ }
94
+ ],
95
+ "sections": [
96
+ {
97
+ "name": "hero",
98
+ "description": "Hero section with headline, bullets, and CTAs.",
99
+ "files": [
100
+ {
101
+ "source": "sections/hero.tsx",
102
+ "target": "{{sections}}/hero.tsx"
103
+ }
104
+ ],
105
+ "dependencies": {
106
+ "local": ["badge", "button"]
107
+ }
108
+ }
109
+ ],
110
+ "wrappers": [
111
+ {
112
+ "name": "glow-wrapper",
113
+ "description": "Glow effect wrapper for highlighting key components.",
114
+ "files": [
115
+ {
116
+ "source": "wrappers/glow-wrapper.tsx",
117
+ "target": "{{wrappers}}/glow-wrapper.tsx"
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ }
123
+ ```
124
+
125
+ - `source` is relative to `templates/`.
126
+ - `target` supports tokens: `{{components}}`, `{{sections}}`, `{{wrappers}}`, `{{lib}}`, `{{styles}}`.
127
+ - `dependencies.local` installs registry components before the section or wrapper.
128
+ - `dependencies.npm` are printed after install; you install them manually.
129
+
130
+ ## Add a new component
131
+
132
+ 1. Create a template in `templates/components/ui/<name>.tsx`.
133
+ 2. Add a registry entry in `registry/index.json`.
134
+ 3. Run `ui add <name>` in your app.
135
+
136
+ ## Add a new section
137
+
138
+ 1. Create a template in `templates/sections/<name>.tsx`.
139
+ 2. Add a registry entry in `registry/index.json` under `sections`.
140
+ 3. Run `ui add-section <name>` in your app.
141
+
142
+ ## Add a new wrapper
143
+
144
+ 1. Create a template in `templates/wrappers/<name>.tsx`.
145
+ 2. Add a registry entry in `registry/index.json` under `wrappers`.
146
+ 3. Run `ui add-wrapper <name>` in your app.
147
+
148
+ ## Tailwind setup
149
+
150
+ Add CSS variables in `styles/globals.css` (installed by `ui init`).
151
+ In your Tailwind config, map colors to CSS variables, for example:
152
+
153
+ ```ts
154
+ export default {
155
+ theme: {
156
+ extend: {
157
+ colors: {
158
+ border: "hsl(var(--border))",
159
+ input: "hsl(var(--input))",
160
+ ring: "hsl(var(--ring))",
161
+ background: "hsl(var(--background))",
162
+ foreground: "hsl(var(--foreground))",
163
+ primary: {
164
+ DEFAULT: "hsl(var(--primary))",
165
+ foreground: "hsl(var(--primary-foreground))"
166
+ },
167
+ secondary: {
168
+ DEFAULT: "hsl(var(--secondary))",
169
+ foreground: "hsl(var(--secondary-foreground))"
170
+ },
171
+ muted: {
172
+ DEFAULT: "hsl(var(--muted))",
173
+ foreground: "hsl(var(--muted-foreground))"
174
+ },
175
+ accent: {
176
+ DEFAULT: "hsl(var(--accent))",
177
+ foreground: "hsl(var(--accent-foreground))"
178
+ },
179
+ destructive: {
180
+ DEFAULT: "hsl(var(--destructive))",
181
+ foreground: "hsl(var(--destructive-foreground))"
182
+ },
183
+ card: {
184
+ DEFAULT: "hsl(var(--card))",
185
+ foreground: "hsl(var(--card-foreground))"
186
+ },
187
+ popover: {
188
+ DEFAULT: "hsl(var(--popover))",
189
+ foreground: "hsl(var(--popover-foreground))"
190
+ }
191
+ },
192
+ borderRadius: {
193
+ lg: "var(--radius)",
194
+ md: "calc(var(--radius) - 2px)",
195
+ sm: "calc(var(--radius) - 4px)"
196
+ }
197
+ }
198
+ }
199
+ }
200
+ ```
201
+
202
+ ## Troubleshooting
203
+
204
+ `ui doctor` reports common issues:
205
+ - missing `components.json`
206
+ - missing `components/ui` directory
207
+ - missing `lib/utils.ts` or `styles/globals.css`
208
+ - registry load failures
209
+ - missing `.ui/lock.json`
210
+
211
+ ## Notes
212
+
213
+ - Requires Node 18+ for built-in `fetch`.
214
+ - Paths are stored in `.ui/lock.json` relative to the project root for Windows/Mac safety.
215
+
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const addSectionCommand: Command;
@@ -0,0 +1,94 @@
1
+ import path from "node:path";
2
+ import { Command } from "commander";
3
+ import { loadConfig } from "../lib/config.js";
4
+ import { copyFileSafe, fileExists } from "../lib/fs.js";
5
+ import { installRegistryEntries } from "../lib/install.js";
6
+ import { loadLockfile, saveLockfile } from "../lib/lockfile.js";
7
+ import { getTemplatePath } from "../lib/paths.js";
8
+ import { getRegistrySections, loadRegistry } from "../lib/registry.js";
9
+ export const addSectionCommand = new Command("add-section")
10
+ .description("Add prebuilt sections to your project")
11
+ .argument("<sections...>", "section names")
12
+ .option("--force", "overwrite existing files")
13
+ .action(async (sections, options) => {
14
+ try {
15
+ const cwd = process.cwd();
16
+ const config = await loadConfig(cwd);
17
+ const registry = await loadRegistry(config, cwd);
18
+ const lockfile = await loadLockfile(cwd);
19
+ const availableSections = getRegistrySections(registry);
20
+ if (availableSections.length === 0) {
21
+ throw new Error("No sections available in the registry.");
22
+ }
23
+ const sectionMap = new Map(availableSections.map((section) => [section.name, section]));
24
+ const uniqueSections = [
25
+ ...new Set(sections.map((name) => name.trim()))
26
+ ].filter(Boolean);
27
+ const missing = uniqueSections.filter((name) => !sectionMap.has(name));
28
+ if (missing.length) {
29
+ throw new Error(`Unknown sections: ${missing.join(", ")}`);
30
+ }
31
+ const utilsPath = path.resolve(cwd, config.paths.utils);
32
+ if (!(await fileExists(utilsPath))) {
33
+ await copyFileSafe(getTemplatePath("lib/utils.ts"), utilsPath, true);
34
+ }
35
+ const stylesPath = path.resolve(cwd, config.paths.styles);
36
+ if (!(await fileExists(stylesPath))) {
37
+ await copyFileSafe(getTemplatePath("styles/globals.css"), stylesPath, true);
38
+ }
39
+ const dependencyNames = new Set();
40
+ for (const name of uniqueSections) {
41
+ const entry = sectionMap.get(name);
42
+ entry?.dependencies?.local?.forEach((dep) => dependencyNames.add(dep));
43
+ }
44
+ const npmDependencies = new Set();
45
+ let dependencyInstalled = [];
46
+ let dependencySkipped = [];
47
+ if (dependencyNames.size) {
48
+ const dependencySummary = await installRegistryEntries({
49
+ cwd,
50
+ config,
51
+ entries: registry.components,
52
+ names: [...dependencyNames],
53
+ lockEntries: lockfile.components,
54
+ force: Boolean(options.force),
55
+ itemLabel: "components"
56
+ });
57
+ dependencyInstalled = dependencySummary.installed;
58
+ dependencySkipped = dependencySummary.skipped;
59
+ dependencySummary.npmDependencies.forEach((dep) => npmDependencies.add(dep));
60
+ }
61
+ const sectionSummary = await installRegistryEntries({
62
+ cwd,
63
+ config,
64
+ entries: availableSections,
65
+ names: uniqueSections,
66
+ lockEntries: lockfile.sections,
67
+ force: Boolean(options.force),
68
+ itemLabel: "sections"
69
+ });
70
+ sectionSummary.npmDependencies.forEach((dep) => npmDependencies.add(dep));
71
+ await saveLockfile(cwd, lockfile);
72
+ if (dependencyInstalled.length) {
73
+ console.log(`Installed component dependencies: ${dependencyInstalled.join(", ")}`);
74
+ }
75
+ if (dependencySkipped.length) {
76
+ console.log(`Skipped component dependencies (already present): ${dependencySkipped.join(", ")}`);
77
+ }
78
+ if (sectionSummary.installed.length) {
79
+ console.log(`Installed sections: ${sectionSummary.installed.join(", ")}`);
80
+ }
81
+ if (sectionSummary.skipped.length) {
82
+ console.log(`Skipped sections (already present): ${sectionSummary.skipped.join(", ")}`);
83
+ }
84
+ if (npmDependencies.size) {
85
+ console.log(`\nInstall dependencies:`);
86
+ console.log(`npm install ${[...npmDependencies].join(" ")}`);
87
+ }
88
+ }
89
+ catch (error) {
90
+ console.error(error.message);
91
+ process.exit(1);
92
+ }
93
+ });
94
+ //# sourceMappingURL=add-section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-section.js","sourceRoot":"","sources":["../../src/commands/add-section.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;KACxD,WAAW,CAAC,uCAAuC,CAAC;KACpD,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;KAC1C,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,QAAkB,EAAE,OAA4B,EAAE,EAAE;IACjE,IAAI,CAAC;QACH,MAAM,GAA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GAAG,CAAC,yBAAyB,CAAC,CAAA;YACtC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAA;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const addWrapperCommand: Command;
@@ -0,0 +1,94 @@
1
+ import path from "node:path";
2
+ import { Command } from "commander";
3
+ import { loadConfig } from "../lib/config.js";
4
+ import { copyFileSafe, fileExists } from "../lib/fs.js";
5
+ import { installRegistryEntries } from "../lib/install.js";
6
+ import { loadLockfile, saveLockfile } from "../lib/lockfile.js";
7
+ import { getTemplatePath } from "../lib/paths.js";
8
+ import { getRegistryWrappers, loadRegistry } from "../lib/registry.js";
9
+ export const addWrapperCommand = new Command("add-wrapper")
10
+ .description("Add prebuilt wrappers to your project")
11
+ .argument("<wrappers...>", "wrapper names")
12
+ .option("--force", "overwrite existing files")
13
+ .action(async (wrappers, options) => {
14
+ try {
15
+ const cwd = process.cwd();
16
+ const config = await loadConfig(cwd);
17
+ const registry = await loadRegistry(config, cwd);
18
+ const lockfile = await loadLockfile(cwd);
19
+ const availableWrappers = getRegistryWrappers(registry);
20
+ if (availableWrappers.length === 0) {
21
+ throw new Error("No wrappers available in the registry.");
22
+ }
23
+ const wrapperMap = new Map(availableWrappers.map((wrapper) => [wrapper.name, wrapper]));
24
+ const uniqueWrappers = [
25
+ ...new Set(wrappers.map((name) => name.trim()))
26
+ ].filter(Boolean);
27
+ const missing = uniqueWrappers.filter((name) => !wrapperMap.has(name));
28
+ if (missing.length) {
29
+ throw new Error(`Unknown wrappers: ${missing.join(", ")}`);
30
+ }
31
+ const utilsPath = path.resolve(cwd, config.paths.utils);
32
+ if (!(await fileExists(utilsPath))) {
33
+ await copyFileSafe(getTemplatePath("lib/utils.ts"), utilsPath, true);
34
+ }
35
+ const stylesPath = path.resolve(cwd, config.paths.styles);
36
+ if (!(await fileExists(stylesPath))) {
37
+ await copyFileSafe(getTemplatePath("styles/globals.css"), stylesPath, true);
38
+ }
39
+ const dependencyNames = new Set();
40
+ for (const name of uniqueWrappers) {
41
+ const entry = wrapperMap.get(name);
42
+ entry?.dependencies?.local?.forEach((dep) => dependencyNames.add(dep));
43
+ }
44
+ const npmDependencies = new Set();
45
+ let dependencyInstalled = [];
46
+ let dependencySkipped = [];
47
+ if (dependencyNames.size) {
48
+ const dependencySummary = await installRegistryEntries({
49
+ cwd,
50
+ config,
51
+ entries: registry.components,
52
+ names: [...dependencyNames],
53
+ lockEntries: lockfile.components,
54
+ force: Boolean(options.force),
55
+ itemLabel: "components"
56
+ });
57
+ dependencyInstalled = dependencySummary.installed;
58
+ dependencySkipped = dependencySummary.skipped;
59
+ dependencySummary.npmDependencies.forEach((dep) => npmDependencies.add(dep));
60
+ }
61
+ const wrapperSummary = await installRegistryEntries({
62
+ cwd,
63
+ config,
64
+ entries: availableWrappers,
65
+ names: uniqueWrappers,
66
+ lockEntries: lockfile.wrappers,
67
+ force: Boolean(options.force),
68
+ itemLabel: "wrappers"
69
+ });
70
+ wrapperSummary.npmDependencies.forEach((dep) => npmDependencies.add(dep));
71
+ await saveLockfile(cwd, lockfile);
72
+ if (dependencyInstalled.length) {
73
+ console.log(`Installed component dependencies: ${dependencyInstalled.join(", ")}`);
74
+ }
75
+ if (dependencySkipped.length) {
76
+ console.log(`Skipped component dependencies (already present): ${dependencySkipped.join(", ")}`);
77
+ }
78
+ if (wrapperSummary.installed.length) {
79
+ console.log(`Installed wrappers: ${wrapperSummary.installed.join(", ")}`);
80
+ }
81
+ if (wrapperSummary.skipped.length) {
82
+ console.log(`Skipped wrappers (already present): ${wrapperSummary.skipped.join(", ")}`);
83
+ }
84
+ if (npmDependencies.size) {
85
+ console.log(`\nInstall dependencies:`);
86
+ console.log(`npm install ${[...npmDependencies].join(" ")}`);
87
+ }
88
+ }
89
+ catch (error) {
90
+ console.error(error.message);
91
+ process.exit(1);
92
+ }
93
+ });
94
+ //# sourceMappingURL=add-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-wrapper.js","sourceRoot":"","sources":["../../src/commands/add-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;KACxD,WAAW,CAAC,uCAAuC,CAAC;KACpD,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;KAC1C,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,QAAkB,EAAE,OAA4B,EAAE,EAAE;IACjE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QACzB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAChD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAA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AAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAA;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const addCommand: Command;
@@ -0,0 +1,53 @@
1
+ import path from "node:path";
2
+ import { Command } from "commander";
3
+ import { loadConfig } from "../lib/config.js";
4
+ import { copyFileSafe, fileExists } from "../lib/fs.js";
5
+ import { installRegistryEntries } from "../lib/install.js";
6
+ import { loadLockfile, saveLockfile } from "../lib/lockfile.js";
7
+ import { getTemplatePath } from "../lib/paths.js";
8
+ import { loadRegistry } from "../lib/registry.js";
9
+ export const addCommand = new Command("add")
10
+ .description("Add components to your project")
11
+ .argument("<components...>", "component names")
12
+ .option("--force", "overwrite existing files")
13
+ .action(async (components, options) => {
14
+ try {
15
+ const cwd = process.cwd();
16
+ const config = await loadConfig(cwd);
17
+ const registry = await loadRegistry(config, cwd);
18
+ const lockfile = await loadLockfile(cwd);
19
+ const utilsPath = path.resolve(cwd, config.paths.utils);
20
+ if (!(await fileExists(utilsPath))) {
21
+ await copyFileSafe(getTemplatePath("lib/utils.ts"), utilsPath, true);
22
+ }
23
+ const stylesPath = path.resolve(cwd, config.paths.styles);
24
+ if (!(await fileExists(stylesPath))) {
25
+ await copyFileSafe(getTemplatePath("styles/globals.css"), stylesPath, true);
26
+ }
27
+ const { installed, skipped, npmDependencies } = await installRegistryEntries({
28
+ cwd,
29
+ config,
30
+ entries: registry.components,
31
+ names: components,
32
+ lockEntries: lockfile.components,
33
+ force: Boolean(options.force),
34
+ itemLabel: "components"
35
+ });
36
+ await saveLockfile(cwd, lockfile);
37
+ if (installed.length) {
38
+ console.log(`Installed: ${installed.join(", ")}`);
39
+ }
40
+ if (skipped.length) {
41
+ console.log(`Skipped (already present): ${skipped.join(", ")}`);
42
+ }
43
+ if (npmDependencies.size) {
44
+ console.log(`\nInstall dependencies:`);
45
+ console.log(`npm install ${[...npmDependencies].join(" ")}`);
46
+ }
47
+ }
48
+ catch (error) {
49
+ console.error(error.message);
50
+ process.exit(1);
51
+ }
52
+ });
53
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KACzC,WAAW,CAAC,gCAAgC,CAAC;KAC7C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;KAC9C,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,UAAoB,EAAE,OAA4B,EAAE,EAAE;IACnE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QACzB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAChD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAA;QAExC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,C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,CAAC,GAAG,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAA;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const buildCommand: Command;
@@ -0,0 +1,105 @@
1
+ import path from "node:path";
2
+ import { promises as fs } from "node:fs";
3
+ import { Command } from "commander";
4
+ import { Project } from "ts-morph";
5
+ import { registryIndexSchema, registrySchema } from "../schema/index.js";
6
+ import { transformIcons, transformMenu, transformRender } from "../utils/index.js";
7
+ const DEFAULT_ITEM_SCHEMA = "https://ui.shadcn.com/schema/registry-item.json";
8
+ export const buildCommand = new Command("build")
9
+ .description("Build registry items into JSON files")
10
+ .argument("[registry]", "path to registry.json", "registry.json")
11
+ .option("--output <dir>", "output directory", "dist")
12
+ .option("--style <name>", "style name")
13
+ .option("--icon-library <name>", "icon library")
14
+ .option("--menu-color <name>", "menu color")
15
+ .option("--schema <url>", "registry item schema URL")
16
+ .action(async (registryArg, options) => {
17
+ try {
18
+ const cwd = process.cwd();
19
+ const registryPath = resolvePath(cwd, registryArg);
20
+ const { registry, items } = await loadRegistry(registryPath);
21
+ const outputDir = resolvePath(cwd, options.output ?? "dist");
22
+ const transformConfig = getTransformConfig(items, options);
23
+ const project = new Project({ useInMemoryFileSystem: true });
24
+ await fs.mkdir(outputDir, { recursive: true });
25
+ for (const item of items) {
26
+ const payload = await buildRegistryItem(cwd, project, item, transformConfig, options.schema);
27
+ const outputPath = path.join(outputDir, `${item.name}.json`);
28
+ await fs.writeFile(outputPath, JSON.stringify(payload, null, 2));
29
+ }
30
+ if (registry) {
31
+ const registryOutput = { ...registry, items };
32
+ await fs.writeFile(path.join(outputDir, "registry.json"), JSON.stringify(registryOutput, null, 2));
33
+ }
34
+ }
35
+ catch (error) {
36
+ console.error(error.message);
37
+ process.exit(1);
38
+ }
39
+ });
40
+ function resolvePath(cwd, value) {
41
+ return path.isAbsolute(value) ? value : path.resolve(cwd, value);
42
+ }
43
+ async function loadRegistry(registryPath) {
44
+ const raw = await fs.readFile(registryPath, "utf8");
45
+ const parsed = JSON.parse(raw);
46
+ if (Array.isArray(parsed)) {
47
+ return {
48
+ items: registryIndexSchema.parse(parsed)
49
+ };
50
+ }
51
+ const registry = registrySchema.parse(parsed);
52
+ return {
53
+ registry,
54
+ items: registry.items
55
+ };
56
+ }
57
+ function getTransformConfig(items, options) {
58
+ const config = {
59
+ style: options.style,
60
+ iconLibrary: options.iconLibrary,
61
+ menuColor: options.menuColor
62
+ };
63
+ const baseItem = items.find((item) => item.type === "registry:base");
64
+ if (baseItem?.config) {
65
+ config.style ??= baseItem.config.style;
66
+ config.iconLibrary ??= baseItem.config.iconLibrary;
67
+ config.menuColor ??= baseItem.config.menuColor;
68
+ }
69
+ return config;
70
+ }
71
+ async function buildRegistryItem(cwd, project, item, config, schemaOverride) {
72
+ const payload = { ...item };
73
+ const schemaValue = schemaOverride ?? DEFAULT_ITEM_SCHEMA;
74
+ if (!payload.$schema && schemaValue) {
75
+ payload.$schema = schemaValue;
76
+ }
77
+ if (item.files) {
78
+ payload.files = await Promise.all(item.files.map(async (file) => {
79
+ const sourcePath = resolvePath(cwd, file.path);
80
+ const raw = file.content ?? (await fs.readFile(sourcePath, "utf8"));
81
+ const content = isSourceFile(file.path)
82
+ ? await transformSource(project, file.path, raw, config)
83
+ : raw;
84
+ return {
85
+ ...file,
86
+ content
87
+ };
88
+ }));
89
+ }
90
+ return payload;
91
+ }
92
+ async function transformSource(project, filename, raw, config) {
93
+ const sourceFile = project.createSourceFile(filename, raw, {
94
+ overwrite: true
95
+ });
96
+ let next = await transformRender({ filename, raw, config, sourceFile });
97
+ next = await transformMenu({ filename, raw, config, sourceFile: next });
98
+ next = await transformIcons({ filename, raw, config, sourceFile: next });
99
+ return next.getFullText();
100
+ }
101
+ function isSourceFile(filePath) {
102
+ const ext = path.extname(filePath).toLowerCase();
103
+ return ext === ".ts" || ext === ".tsx" || ext === ".js" || ext === ".jsx";
104
+ }
105
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,OAAO,EACL,mBAAmB,EACnB,cAAc,EAIf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,cAAc,EACd,aAAa,EACb,eAAe,EAEhB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,mBAAmB,GACvB,iDAAiD,CAAA;AAenD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,sCAAsC,CAAC;KACnD,QAAQ,CAAC,YAAY,EAAE,uBAAuB,EAAE,eAAe,CAAC;KAChE,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,CAAC;KACpD,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,uBAAuB,EAAE,cAAc,CAAC;KAC/C,MAAM,CAAC,qBAAqB,EAAE,YAAY,CAAC;KAC3C,MAAM,CAAC,gBAAgB,EAAE,0BAA0B,CAAC;KACpD,MAAM,CAAC,KAAK,EAAE,WAAmB,EAAE,OAAqB,EAAE,EAAE;IAC3D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QACzB,MAAM,YAAY,GAAG,WAAW,CAAC,GAA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