@jongh/cli 4.1.0 → 5.20260905.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.
- package/README.md +5 -5
- package/dist/index.js +6 -683
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
npx @jongh/cli init
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- 사용자의 `tsconfig.json` 경로 설정에서 base alias를 찾습니다
|
|
10
|
+
- 이후 코드가 저장될 components, hooks, utils 경로를 `components.json`에 저장합니다
|
|
11
11
|
|
|
12
12
|
### add
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npx @jongh/cli add [
|
|
15
|
+
npx @jongh/cli add [name]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
- 원격 Registry에서
|
|
19
|
-
-
|
|
18
|
+
- 원격 Registry에서 항목의 파일을 가져와 `components.json`에 명시된 경로에 저장합니다
|
|
19
|
+
- 컴포넌트 코드뿐 아니라 hook, util 파일과 패키지 의존성도 함께 처리합니다
|
|
20
20
|
|
|
21
21
|
### codemod: radix-ui-import
|
|
22
22
|
|
package/dist/index.js
CHANGED
|
@@ -1,685 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {Command}from'commander';import {intro,confirm,outro,spinner,log
|
|
2
|
+
import {Command}from'commander';import {intro,confirm,outro,spinner,log}from'@clack/prompts';import J from'chalk';import T from'fs-extra';import S from'path';import {z as z$1}from'zod';import {loadConfig,createMatchPath}from'tsconfig-paths';import {detect,resolveCommand}from'package-manager-detector';import {packageDirectory}from'pkg-dir';import Se from'fast-glob';import {Project,SyntaxKind}from'ts-morph';var P=t=>{let e={};for(let o of t)e[o]=o;return e},v=P(["config_not_found","resolve_path_fail","failed_to_fetch"]);P(["components.json","tsconfig.json","package.json"]);var h=class extends Error{issue;constructor(e){super(),this.name="NewError",this.issue=e;}get format(){return this.issue.code+`
|
|
3
3
|
`+this.issue.message?.join(`
|
|
4
|
-
`)}},
|
|
5
|
-
${
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
--color-background: var(--jds-background);
|
|
10
|
-
|
|
11
|
-
--color-foreground: var(--jds-foreground);
|
|
12
|
-
--color-foreground-muted: var(--jds-foreground-muted);
|
|
13
|
-
--color-foreground-emphasized: var(--jds-foreground-emphasized);
|
|
14
|
-
--color-foreground-primary: var(--jds-foreground-primary);
|
|
15
|
-
--color-foreground-destructive: var(--jds-foreground-destructive);
|
|
16
|
-
--color-foreground-inverted: var(--jds-foreground-inverted);
|
|
17
|
-
|
|
18
|
-
--color-layer: var(--jds-layer);
|
|
19
|
-
--color-layer-floating: var(--jds-layer-floating);
|
|
20
|
-
--color-layer-active: var(--jds-layer-active);
|
|
21
|
-
--color-layer-overlay: var(--jds-layer-overlay);
|
|
22
|
-
|
|
23
|
-
--color-primary: var(--jds-primary);
|
|
24
|
-
--color-primary-active: var(--jds-primary-active);
|
|
25
|
-
--color-primary-foreground: var(--jds-primary-foreground);
|
|
26
|
-
|
|
27
|
-
--color-secondary: var(--jds-secondary);
|
|
28
|
-
--color-secondary-active: var(--jds-secondary-active);
|
|
29
|
-
--color-secondary-foreground: var(--jds-secondary-foreground);
|
|
30
|
-
|
|
31
|
-
--color-neutral: var(--jds-neutral);
|
|
32
|
-
--color-neutral-active: var(--jds-neutral-active);
|
|
33
|
-
|
|
34
|
-
--color-destructive: var(--jds-destructive);
|
|
35
|
-
--color-destructive-active: var(--jds-destructive-active);
|
|
36
|
-
--color-destructive-foreground: var(--jds-destructive-foreground);
|
|
37
|
-
|
|
38
|
-
--color-stroke: var(--jds-stroke);
|
|
39
|
-
--color-stroke-subtle: var(--jds-stroke-subtle);
|
|
40
|
-
--color-stroke-interactive: var(--jds-stroke-interactive);
|
|
41
|
-
--color-stroke-ring: var(--jds-stroke-ring);
|
|
42
|
-
--color-stroke-destructive: var(--jds-stroke-destructive);
|
|
43
|
-
|
|
44
|
-
--radius-radius: var(--jds-radius);
|
|
45
|
-
--radius-md: var(--jds-radius);
|
|
46
|
-
|
|
47
|
-
--animate-accordion-down: accordion-down-radix 150ms ease-out;
|
|
48
|
-
--animate-accordion-up: accordion-up-radix 150ms ease-out;
|
|
49
|
-
--animate-content-show: content-show 200ms ease-out;
|
|
50
|
-
--animate-fade-in: fade-in 200ms ease-out;
|
|
51
|
-
--animate-fade-out: fade-out 200ms ease-out;
|
|
52
|
-
--animate-slide-in-down: slide-in-down 200ms ease-out;
|
|
53
|
-
|
|
54
|
-
--text-display1: 4.5rem;
|
|
55
|
-
--text-display1--line-height: var(--leading-loose);
|
|
56
|
-
--text-display1--letter-spacing: var(--tracking-tight);
|
|
57
|
-
--text-display1--font-weight: var(--font-weight-bold);
|
|
58
|
-
|
|
59
|
-
--text-display2: 3.75rem;
|
|
60
|
-
--text-display2--line-height: var(--leading-relaxed);
|
|
61
|
-
--text-display2--letter-spacing: var(--tracking-tight);
|
|
62
|
-
--text-display2--font-weight: var(--font-weight-bold);
|
|
63
|
-
|
|
64
|
-
--text-title1: 2.25rem;
|
|
65
|
-
--text-title1--line-height: var(--leading-normal);
|
|
66
|
-
--text-title1--letter-spacing: var(--tracking-tight);
|
|
67
|
-
--text-title1--font-weight: var(--font-weight-semibold);
|
|
68
|
-
|
|
69
|
-
--text-title2: 1.5rem;
|
|
70
|
-
--text-title2--line-height: var(--leading-snug);
|
|
71
|
-
--text-title2--letter-spacing: var(--tracking-tight);
|
|
72
|
-
--text-title2--font-weight: var(--font-weight-semibold);
|
|
73
|
-
|
|
74
|
-
--text-title3: 1.25rem;
|
|
75
|
-
--text-title3--line-height: var(--leading-snug);
|
|
76
|
-
--text-title3--letter-spacing: var(--tracking-tight);
|
|
77
|
-
--text-title3--font-weight: var(--font-weight-bold);
|
|
78
|
-
|
|
79
|
-
--text-heading1: 1.125rem;
|
|
80
|
-
--text-heading1--line-height: var(--leading-normal);
|
|
81
|
-
--text-heading1--letter-spacing: var(--tracking-normal);
|
|
82
|
-
--text-heading1--font-weight: var(--font-weight-semibold);
|
|
83
|
-
|
|
84
|
-
--text-heading2: 1rem;
|
|
85
|
-
--text-heading2--line-height: var(--leading-normal);
|
|
86
|
-
--text-heading2--letter-spacing: var(--tracking-normal);
|
|
87
|
-
--text-heading2--font-weight: var(--font-weight-semibold);
|
|
88
|
-
|
|
89
|
-
--text-body1: 1rem;
|
|
90
|
-
--text-body1--line-height: var(--leading-relaxed);
|
|
91
|
-
--text-body1--letter-spacing: var(--tracking-normal);
|
|
92
|
-
--text-body1--font-weight: var(--font-weight-normal);
|
|
93
|
-
|
|
94
|
-
--text-body2: 0.875rem;
|
|
95
|
-
--text-body2--line-height: var(--leading-normal);
|
|
96
|
-
--text-body2--letter-spacing: var(--tracking-normal);
|
|
97
|
-
--text-body2--font-weight: var(--font-weight-normal);
|
|
98
|
-
|
|
99
|
-
--text-label1: 0.875rem;
|
|
100
|
-
--text-label1--line-height: var(--leading-snug);
|
|
101
|
-
--text-label1--letter-spacing: var(--tracking-wide);
|
|
102
|
-
--text-label1--font-weight: var(--font-weight-semibold);
|
|
103
|
-
|
|
104
|
-
--text-label2: 0.75rem;
|
|
105
|
-
--text-label2--line-height: var(--leading-snug);
|
|
106
|
-
--text-label2--letter-spacing: var(--tracking-wide);
|
|
107
|
-
--text-label2--font-weight: var(--font-weight-semibold);
|
|
108
|
-
|
|
109
|
-
--text-caption1: 0.75rem;
|
|
110
|
-
--text-caption1--line-height: var(--leading-tight);
|
|
111
|
-
--text-caption1--letter-spacing: var(--tracking-wide);
|
|
112
|
-
--text-caption1--font-weight: var(--font-weight-semibold);
|
|
113
|
-
|
|
114
|
-
--text-caption2: 0.625rem;
|
|
115
|
-
--text-caption2--line-height: var(--leading-tight);
|
|
116
|
-
--text-caption2--letter-spacing: var(--tracking-wide);
|
|
117
|
-
--text-caption2--font-weight: var(--font-weight-semibold);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@utility typo-display1 {
|
|
121
|
-
font-size: var(--text-display1);
|
|
122
|
-
font-weight: var(--text-display1--font-weight);
|
|
123
|
-
letter-spacing: var(--text-display1--letter-spacing);
|
|
124
|
-
line-height: var(--text-display1--line-height);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@utility typo-display2 {
|
|
128
|
-
font-size: var(--text-display2);
|
|
129
|
-
font-weight: var(--text-display2--font-weight);
|
|
130
|
-
letter-spacing: var(--text-display2--letter-spacing);
|
|
131
|
-
line-height: var(--text-display2--line-height);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@utility typo-title1 {
|
|
135
|
-
font-size: var(--text-title1);
|
|
136
|
-
font-weight: var(--text-title1--font-weight);
|
|
137
|
-
letter-spacing: var(--text-title1--letter-spacing);
|
|
138
|
-
line-height: var(--text-title1--line-height);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@utility typo-title2 {
|
|
142
|
-
font-size: var(--text-title2);
|
|
143
|
-
font-weight: var(--text-title2--font-weight);
|
|
144
|
-
letter-spacing: var(--text-title2--letter-spacing);
|
|
145
|
-
line-height: var(--text-title2--line-height);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
@utility typo-title3 {
|
|
149
|
-
font-size: var(--text-title3);
|
|
150
|
-
font-weight: var(--text-title3--font-weight);
|
|
151
|
-
letter-spacing: var(--text-title3--letter-spacing);
|
|
152
|
-
line-height: var(--text-title3--line-height);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
@utility typo-heading1 {
|
|
156
|
-
font-size: var(--text-heading1);
|
|
157
|
-
font-weight: var(--text-heading1--font-weight);
|
|
158
|
-
letter-spacing: var(--text-heading1--letter-spacing);
|
|
159
|
-
line-height: var(--text-heading1--line-height);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
@utility typo-heading2 {
|
|
163
|
-
font-size: var(--text-heading2);
|
|
164
|
-
font-weight: var(--text-heading2--font-weight);
|
|
165
|
-
letter-spacing: var(--text-heading2--letter-spacing);
|
|
166
|
-
line-height: var(--text-heading2--line-height);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@utility typo-body1 {
|
|
170
|
-
font-size: var(--text-body1);
|
|
171
|
-
font-weight: var(--text-body1--font-weight);
|
|
172
|
-
letter-spacing: var(--text-body1--letter-spacing);
|
|
173
|
-
line-height: var(--text-body1--line-height);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@utility typo-body2 {
|
|
177
|
-
font-size: var(--text-body2);
|
|
178
|
-
font-weight: var(--text-body2--font-weight);
|
|
179
|
-
letter-spacing: var(--text-body2--letter-spacing);
|
|
180
|
-
line-height: var(--text-body2--line-height);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@utility typo-label1 {
|
|
184
|
-
font-size: var(--text-label1);
|
|
185
|
-
font-weight: var(--text-label1--font-weight);
|
|
186
|
-
letter-spacing: var(--text-label1--letter-spacing);
|
|
187
|
-
line-height: var(--text-label1--line-height);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
@utility typo-label2 {
|
|
191
|
-
font-size: var(--text-label2);
|
|
192
|
-
font-weight: var(--text-label2--font-weight);
|
|
193
|
-
letter-spacing: var(--text-label2--letter-spacing);
|
|
194
|
-
line-height: var(--text-label2--line-height);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
@utility typo-caption1 {
|
|
198
|
-
font-size: var(--text-caption1);
|
|
199
|
-
font-weight: var(--text-caption1--font-weight);
|
|
200
|
-
letter-spacing: var(--text-caption1--letter-spacing);
|
|
201
|
-
line-height: var(--text-caption1--line-height);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@utility typo-caption2 {
|
|
205
|
-
font-size: var(--text-caption2);
|
|
206
|
-
font-weight: var(--text-caption2--font-weight);
|
|
207
|
-
letter-spacing: var(--text-caption2--letter-spacing);
|
|
208
|
-
line-height: var(--text-caption2--line-height);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
@keyframes accordion-down-radix {
|
|
212
|
-
from {
|
|
213
|
-
height: 0;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
to {
|
|
217
|
-
height: var(--radix-accordion-content-height);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
@keyframes accordion-up-radix {
|
|
222
|
-
from {
|
|
223
|
-
height: var(--radix-accordion-content-height);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
to {
|
|
227
|
-
height: 0;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
@keyframes content-show {
|
|
232
|
-
from {
|
|
233
|
-
opacity: 0;
|
|
234
|
-
transform: translate(-50%, -48%) scale(0.96);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
to {
|
|
238
|
-
opacity: 1;
|
|
239
|
-
transform: translate(-50%, -50%) scale(1);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
@keyframes fade-in {
|
|
244
|
-
from {
|
|
245
|
-
opacity: 0;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
to {
|
|
249
|
-
opacity: 1;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
@keyframes fade-out {
|
|
254
|
-
from {
|
|
255
|
-
opacity: 1;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
to {
|
|
259
|
-
opacity: 0;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
@keyframes slide-in-down {
|
|
264
|
-
from {
|
|
265
|
-
transform: translate3d(0, -100%, 0);
|
|
266
|
-
visibility: visible;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
to {
|
|
270
|
-
transform: translateZ(0);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
:root {
|
|
275
|
-
--jds-radius: 0.5rem;
|
|
276
|
-
|
|
277
|
-
--jds-background: var(--color-white);
|
|
278
|
-
|
|
279
|
-
--jds-foreground: var(--color-{{gray}}-700);
|
|
280
|
-
--jds-foreground-muted: var(--color-{{gray}}-500);
|
|
281
|
-
--jds-foreground-emphasized: var(--color-{{gray}}-900);
|
|
282
|
-
--jds-foreground-primary: var(--color-{{primary}}-600);
|
|
283
|
-
--jds-foreground-destructive: var(--color-red-600);
|
|
284
|
-
--jds-foreground-inverted: var(--color-white);
|
|
285
|
-
|
|
286
|
-
--jds-layer: var(--color-white);
|
|
287
|
-
--jds-layer-floating: var(--color-{{gray}}-50);
|
|
288
|
-
--jds-layer-active: var(--color-{{gray}}-100);
|
|
289
|
-
--jds-layer-overlay: color-mix(in oklab, var(--color-black) 50%, transparent);
|
|
290
|
-
|
|
291
|
-
--jds-primary: var(--color-{{primary}}-600);
|
|
292
|
-
--jds-primary-active: var(--color-{{primary}}-700);
|
|
293
|
-
--jds-primary-foreground: var(--color-white);
|
|
294
|
-
|
|
295
|
-
--jds-secondary: var(--color-{{secondary}}-700);
|
|
296
|
-
--jds-secondary-active: var(--color-{{secondary}}-800);
|
|
297
|
-
--jds-secondary-foreground: var(--color-white);
|
|
298
|
-
|
|
299
|
-
--jds-neutral: var(--color-{{gray}}-100);
|
|
300
|
-
--jds-neutral-active: var(--color-{{gray}}-200);
|
|
301
|
-
|
|
302
|
-
--jds-destructive: var(--color-red-600);
|
|
303
|
-
--jds-destructive-active: var(--color-red-700);
|
|
304
|
-
--jds-destructive-foreground: var(--color-white);
|
|
305
|
-
|
|
306
|
-
--jds-stroke: var(--color-{{gray}}-300);
|
|
307
|
-
--jds-stroke-subtle: var(--color-{{gray}}-200);
|
|
308
|
-
--jds-stroke-interactive: var(--color-{{primary}}-400);
|
|
309
|
-
--jds-stroke-ring: var(--color-{{primary}}-500);
|
|
310
|
-
--jds-stroke-destructive: var(--color-red-500);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.dark {
|
|
314
|
-
--jds-background: var(--color-{{gray}}-950);
|
|
315
|
-
|
|
316
|
-
--jds-foreground: var(--color-{{gray}}-300);
|
|
317
|
-
--jds-foreground-muted: var(--color-{{gray}}-400);
|
|
318
|
-
--jds-foreground-emphasized: var(--color-{{gray}}-100);
|
|
319
|
-
--jds-foreground-primary: var(--color-{{primary}}-400);
|
|
320
|
-
--jds-foreground-destructive: var(--color-red-400);
|
|
321
|
-
--jds-foreground-inverted: var(--color-{{gray}}-950);
|
|
322
|
-
|
|
323
|
-
--jds-layer: var(--color-{{gray}}-950);
|
|
324
|
-
--jds-layer-floating: var(--color-{{gray}}-900);
|
|
325
|
-
--jds-layer-active: var(--color-{{gray}}-800);
|
|
326
|
-
--jds-layer-overlay: color-mix(in oklab, var(--color-black) 50%, transparent);
|
|
327
|
-
|
|
328
|
-
--jds-primary: var(--color-{{primary}}-700);
|
|
329
|
-
--jds-primary-active: var(--color-{{primary}}-300);
|
|
330
|
-
--jds-primary-foreground: var(--color-{{gray}}-50);
|
|
331
|
-
|
|
332
|
-
--jds-secondary: var(--color-{{secondary}}-500);
|
|
333
|
-
--jds-secondary-active: var(--color-{{secondary}}-400);
|
|
334
|
-
--jds-secondary-foreground: var(--color-{{gray}}-50);
|
|
335
|
-
|
|
336
|
-
--jds-neutral: var(--color-{{gray}}-800);
|
|
337
|
-
--jds-neutral-active: var(--color-{{gray}}-700);
|
|
338
|
-
|
|
339
|
-
--jds-destructive: var(--color-red-400);
|
|
340
|
-
--jds-destructive-active: var(--color-red-300);
|
|
341
|
-
--jds-destructive-foreground: var(--color-{{gray}}-50);
|
|
342
|
-
|
|
343
|
-
--jds-stroke: var(--color-{{gray}}-50);
|
|
344
|
-
--jds-stroke-subtle: var(--color-{{gray}}-800);
|
|
345
|
-
--jds-stroke-interactive: var(--color-{{primary}}-500);
|
|
346
|
-
--jds-stroke-ring: var(--color-{{primary}}-400);
|
|
347
|
-
--jds-stroke-destructive: var(--color-red-400);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
@layer base {
|
|
351
|
-
body {
|
|
352
|
-
background: var(--jds-background);
|
|
353
|
-
color: var(--jds-foreground);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
`;var ue=`
|
|
357
|
-
import {
|
|
358
|
-
definePreset,
|
|
359
|
-
defineSemanticTokens,
|
|
360
|
-
defineTextStyles,
|
|
361
|
-
defineTokens,
|
|
362
|
-
} from "@pandacss/dev"
|
|
363
|
-
|
|
364
|
-
const radii = defineTokens.radii({
|
|
365
|
-
radius: { value: "0.5rem" },
|
|
366
|
-
})
|
|
367
|
-
|
|
368
|
-
export const semanticColors = defineSemanticTokens.colors({
|
|
369
|
-
background: {
|
|
370
|
-
value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
|
|
371
|
-
},
|
|
372
|
-
foreground: {
|
|
373
|
-
value: { "base": "{colors.{{gray}}.950}", "_dark": "{colors.{{gray}}.50}" }
|
|
374
|
-
},
|
|
375
|
-
primary: {
|
|
376
|
-
DEFAULT: {
|
|
377
|
-
value: { "base": "{colors.{{primary}}.600}", "_dark": "{colors.{{primary}}.700}" }
|
|
378
|
-
},
|
|
379
|
-
foreground: {
|
|
380
|
-
value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
|
|
381
|
-
},
|
|
382
|
-
active: {
|
|
383
|
-
value: { "base": "{colors.{{primary}}.700}", "_dark": "{colors.{{primary}}.300}" }
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
secondary: {
|
|
387
|
-
DEFAULT: {
|
|
388
|
-
value: { "base": "{colors.{{secondary}}.600}", "_dark": "{colors.{{secondary}}.400}" }
|
|
389
|
-
},
|
|
390
|
-
foreground: {
|
|
391
|
-
value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
|
|
392
|
-
},
|
|
393
|
-
active: {
|
|
394
|
-
value: { "base": "{colors.{{secondary}}.700}", "_dark": "{colors.{{secondary}}.300}" }
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
neutral: {
|
|
398
|
-
DEFAULT: {
|
|
399
|
-
value: { "base": "{colors.{{gray}}.100}", "_dark": "{colors.{{gray}}.800}" }
|
|
400
|
-
},
|
|
401
|
-
foreground: {
|
|
402
|
-
value: { "base": "{colors.{{gray}}.500}", "_dark": "{colors.{{gray}}.400}" }
|
|
403
|
-
},
|
|
404
|
-
active: {
|
|
405
|
-
value: { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.700}" }
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
accent: {
|
|
409
|
-
DEFAULT: {
|
|
410
|
-
value: { "base": "{colors.{{secondary}}.100}", "_dark": "{colors.{{secondary}}.800}" }
|
|
411
|
-
},
|
|
412
|
-
foreground: {
|
|
413
|
-
value: { "base": "{colors.{{secondary}}.900}", "_dark": "{colors.{{secondary}}.50}" }
|
|
414
|
-
},
|
|
415
|
-
active: {
|
|
416
|
-
value: { "base": "{colors.{{secondary}}.200}", "_dark": "{colors.{{secondary}}.700}" }
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
destructive: {
|
|
420
|
-
DEFAULT: {
|
|
421
|
-
value: { "base": "{colors.red.600}", "_dark": "{colors.red.400}" }
|
|
422
|
-
},
|
|
423
|
-
foreground: {
|
|
424
|
-
value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
|
|
425
|
-
},
|
|
426
|
-
active: {
|
|
427
|
-
value: { "base": "{colors.red.700}", "_dark": "{colors.red.300}" }
|
|
428
|
-
}
|
|
429
|
-
},
|
|
430
|
-
layer: {
|
|
431
|
-
DEFAULT: {
|
|
432
|
-
value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
|
|
433
|
-
},
|
|
434
|
-
overlay: {
|
|
435
|
-
value: { "base": "{colors.black/50}", "_dark": "{colors.black/50}" }
|
|
436
|
-
},
|
|
437
|
-
floating: {
|
|
438
|
-
value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
|
|
439
|
-
},
|
|
440
|
-
active: {
|
|
441
|
-
value: { "base": "{colors.{{gray}}.50}", "_dark": "{colors.{{gray}}.800}" }
|
|
442
|
-
},
|
|
443
|
-
foreground: {
|
|
444
|
-
DEFAULT: {
|
|
445
|
-
value: { "base": "{colors.{{gray}}.500}", "_dark": "{colors.{{gray}}.400}" }
|
|
446
|
-
},
|
|
447
|
-
muted: {
|
|
448
|
-
value: { "base": "{colors.{{gray}}.400}", "_dark": "{colors.{{gray}}.500}" }
|
|
449
|
-
},
|
|
450
|
-
emphasized: {
|
|
451
|
-
value: { "base": "{colors.{{gray}}.700}", "_dark": "{colors.{{gray}}.200}" }
|
|
452
|
-
},
|
|
453
|
-
primary: {
|
|
454
|
-
value: { "base": "{colors.{{primary}}.500}", "_dark": "{colors.{{primary}}.400}" }
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
stroke: {
|
|
459
|
-
DEFAULT: {
|
|
460
|
-
value: { "base": "{colors.{{primary}}.200}", "_dark": "{colors.{{primary}}.600}" }
|
|
461
|
-
},
|
|
462
|
-
border: {
|
|
463
|
-
value: { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.800}" }
|
|
464
|
-
},
|
|
465
|
-
input: {
|
|
466
|
-
value: { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.800}" }
|
|
467
|
-
},
|
|
468
|
-
ring: {
|
|
469
|
-
value: { "base": "{colors.{{primary}}.500}", "_dark": "{colors.{{primary}}.400}" }
|
|
470
|
-
},
|
|
471
|
-
destructive: {
|
|
472
|
-
value: { "base": "{colors.red.500}", "_dark": "{colors.red.400}" }
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
})
|
|
476
|
-
|
|
477
|
-
const borders = defineSemanticTokens.borders({
|
|
478
|
-
base: { value: "1px solid {colors.stroke.border}" },
|
|
479
|
-
input: { value: "1px solid {colors.stroke.input}" },
|
|
480
|
-
primary: { value: "1px solid {colors.stroke}" },
|
|
481
|
-
destructive: { value: "1px solid {colors.destructive}" },
|
|
482
|
-
})
|
|
483
|
-
|
|
484
|
-
export const textStyles = defineTextStyles({
|
|
485
|
-
display1: {
|
|
486
|
-
value: {
|
|
487
|
-
fontWeight: "{fontWeights.bold}",
|
|
488
|
-
fontSize: "4.5rem",
|
|
489
|
-
lineHeight: "{lineHeights.loose}",
|
|
490
|
-
letterSpacing: "{letterSpacings.tight}",
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
display2: {
|
|
494
|
-
value: {
|
|
495
|
-
fontWeight: "{fontWeights.bold}",
|
|
496
|
-
fontSize: "3.75rem",
|
|
497
|
-
lineHeight: "{lineHeights.relaxed}",
|
|
498
|
-
letterSpacing: "{letterSpacings.tight}",
|
|
499
|
-
},
|
|
500
|
-
},
|
|
501
|
-
title1: {
|
|
502
|
-
value: {
|
|
503
|
-
fontWeight: "semibold",
|
|
504
|
-
fontSize: "2.25rem",
|
|
505
|
-
lineHeight: "{lineHeights.normal}",
|
|
506
|
-
letterSpacing: "{letterSpacings.tight}",
|
|
507
|
-
},
|
|
508
|
-
},
|
|
509
|
-
title2: {
|
|
510
|
-
value: {
|
|
511
|
-
fontWeight: "semibold",
|
|
512
|
-
fontSize: "1.5rem",
|
|
513
|
-
lineHeight: "{lineHeights.snug}",
|
|
514
|
-
letterSpacing: "{letterSpacings.tight}",
|
|
515
|
-
},
|
|
516
|
-
},
|
|
517
|
-
title3: {
|
|
518
|
-
value: {
|
|
519
|
-
fontWeight: "{fontWeights.bold}",
|
|
520
|
-
fontSize: "1.25rem",
|
|
521
|
-
lineHeight: "{lineHeights.snug}",
|
|
522
|
-
letterSpacing: "{letterSpacings.tight}",
|
|
523
|
-
},
|
|
524
|
-
},
|
|
525
|
-
heading1: {
|
|
526
|
-
value: {
|
|
527
|
-
fontWeight: "{fontWeights.semibold}",
|
|
528
|
-
fontSize: "1.125rem",
|
|
529
|
-
lineHeight: "{lineHeights.normal}",
|
|
530
|
-
letterSpacing: "{letterSpacings.normal}",
|
|
531
|
-
},
|
|
532
|
-
},
|
|
533
|
-
heading2: {
|
|
534
|
-
value: {
|
|
535
|
-
fontWeight: "{fontWeights.semibold}",
|
|
536
|
-
fontSize: "1rem",
|
|
537
|
-
lineHeight: "{lineHeights.normal}",
|
|
538
|
-
letterSpacing: "{letterSpacings.normal}",
|
|
539
|
-
},
|
|
540
|
-
},
|
|
541
|
-
body1: {
|
|
542
|
-
value: {
|
|
543
|
-
fontWeight: "{fontWeights.normal}",
|
|
544
|
-
fontSize: "1rem",
|
|
545
|
-
lineHeight: "{lineHeights.relaxed}",
|
|
546
|
-
letterSpacing: "{letterSpacings.normal}",
|
|
547
|
-
},
|
|
548
|
-
},
|
|
549
|
-
body2: {
|
|
550
|
-
value: {
|
|
551
|
-
fontWeight: "{fontWeights.normal}",
|
|
552
|
-
fontSize: "0.875rem",
|
|
553
|
-
lineHeight: "{lineHeights.normal}",
|
|
554
|
-
letterSpacing: "{letterSpacings.normal}",
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
label1: {
|
|
558
|
-
value: {
|
|
559
|
-
fontWeight: "{fontWeights.semibold}",
|
|
560
|
-
fontSize: "0.875rem",
|
|
561
|
-
lineHeight: "{lineHeights.snug}",
|
|
562
|
-
letterSpacing: "{letterSpacings.wide}",
|
|
563
|
-
},
|
|
564
|
-
},
|
|
565
|
-
label2: {
|
|
566
|
-
value: {
|
|
567
|
-
fontWeight: "{fontWeights.semibold}",
|
|
568
|
-
fontSize: "0.75rem",
|
|
569
|
-
lineHeight: "{lineHeights.snug}",
|
|
570
|
-
letterSpacing: "{letterSpacings.wide}",
|
|
571
|
-
},
|
|
572
|
-
},
|
|
573
|
-
caption1: {
|
|
574
|
-
value: {
|
|
575
|
-
fontWeight: "{fontWeights.semibold}",
|
|
576
|
-
fontSize: "0.75rem",
|
|
577
|
-
lineHeight: "{lineHeights.tight}",
|
|
578
|
-
letterSpacing: "{letterSpacings.wide}",
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
caption2: {
|
|
582
|
-
value: {
|
|
583
|
-
fontWeight: "{fontWeights.semibold}",
|
|
584
|
-
fontSize: "0.625rem",
|
|
585
|
-
lineHeight: "{lineHeights.tight}",
|
|
586
|
-
letterSpacing: "{letterSpacings.wide}",
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
})
|
|
590
|
-
|
|
591
|
-
export const utilities = {
|
|
592
|
-
extend: {
|
|
593
|
-
fluidFontSize: {
|
|
594
|
-
shorthand: "fluidFontSize",
|
|
595
|
-
values: "fontSizes",
|
|
596
|
-
transform(value) {
|
|
597
|
-
if (!value.endsWith("rem")) {
|
|
598
|
-
return value
|
|
599
|
-
}
|
|
600
|
-
try {
|
|
601
|
-
const min = parseFloat(value) * 16
|
|
602
|
-
const max = min + 0.5 * 16
|
|
603
|
-
|
|
604
|
-
const [minRange, maxRange] = [360, 640]
|
|
605
|
-
const slopePxPerVw = (100 * (max - min)) / (maxRange - minRange)
|
|
606
|
-
const intercept = (min - slopePxPerVw * (minRange / 100)) / 16
|
|
607
|
-
const calcPart = \`calc(\${intercept.toFixed(4)}rem + \${slopePxPerVw.toFixed(4)}vw)\`
|
|
608
|
-
|
|
609
|
-
return {
|
|
610
|
-
fontSize: \`clamp(\${value}, \${calcPart}, \${max / 16}rem)\`,
|
|
611
|
-
}
|
|
612
|
-
} catch (error) {
|
|
613
|
-
console.error(
|
|
614
|
-
"[fluidFontSize] Error transforming value:",
|
|
615
|
-
error,
|
|
616
|
-
value,
|
|
617
|
-
)
|
|
618
|
-
return {
|
|
619
|
-
fontSize: value
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
},
|
|
624
|
-
},
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
export const defaultPreset = definePreset({
|
|
628
|
-
name: "default",
|
|
629
|
-
globalCss: {
|
|
630
|
-
body: {
|
|
631
|
-
background: "background",
|
|
632
|
-
color: "foreground",
|
|
633
|
-
},
|
|
634
|
-
},
|
|
635
|
-
theme: {
|
|
636
|
-
extend: {
|
|
637
|
-
textStyles,
|
|
638
|
-
tokens: {
|
|
639
|
-
radii,
|
|
640
|
-
},
|
|
641
|
-
semanticTokens: {
|
|
642
|
-
colors: semanticColors,
|
|
643
|
-
borders,
|
|
644
|
-
},
|
|
645
|
-
},
|
|
646
|
-
},
|
|
647
|
-
utilities,
|
|
648
|
-
})
|
|
649
|
-
|
|
650
|
-
`;var j=["rose","pink","fuchsia","purple","violet","indigo","blue","sky","cyan","teal","emerald","green","lime","yellow","amber","orange","red","neutral","stone","zinc","gray","slate"],I=["neutral","stone","zinc","gray","slate"],E=z.object({primary:z.enum(j),secondary:z.enum(j),gray:z.enum(I)}),ye=t=>fe.compile(ue)(t),he=t=>fe.compile(ge)(t);var D=z.object({cwd:z.string().default(()=>process.cwd()),yes:z.boolean().default(false),style:L.default("panda"),primary:E.shape.primary.default("neutral"),secondary:E.shape.secondary.default("slate"),gray:E.shape.gray.default("gray")}),W=async t=>t.yes?D.parse(t):D.parse({...t,style:t.style??await select({message:"Pick component style",initialValue:"panda",options:L.options.map(e=>({value:e,label:e}))}),primary:t.primary??await select({message:"Pick primary color",initialValue:"neutral",options:j.map(e=>({value:e,label:e}))}),secondary:t.secondary??await select({message:"Pick secondary color",initialValue:"slate",options:j.map(e=>({value:e,label:e}))}),gray:t.gray??await select({message:"Pick gray color",initialValue:"gray",options:I.map(e=>({value:e,label:e}))})});var G=de.bold.red,ve=de.bold.blue,qe=["tailwindcss","clsx","tailwind-merge","tailwind-variants"],be=new Command().name("init").description("Initialize the project").option("-c, --cwd <cwd>","current working directory, default to process.cwd()",process.cwd()).option("-y, --yes","skip prompts and use default options",false).option("--style <style>","component style").option("--primary <color>","primary color").option("--secondary <color>","secondary color").option("--gray <color>","gray color").action(async t=>{let e=spinner();e.start("Initializing");try{let r=await W({cwd:v.resolve(t.cwd),yes:t.yes,style:t.style,primary:t.primary,secondary:t.secondary,gray:t.gray}),o=await V(r);if(e.stop("successfully Initialized!"),o?.style==="tailwind"){let a=await O(r.cwd,qe);a&&outro(ve(`Run this command in the terminal : ${a.command} ${a.args.join(" ")}`));}}catch(r){e.stop(G(ve("error occured"))),r instanceof z.ZodError&&console.log(r.message),r instanceof x&&console.log(G(r.format)),r instanceof Error&&console.log(G(r.message)),process.exit(1);}});async function V(t){let e=t.cwd||await packageDirectory();if(!e)throw u({code:"config_not_found",configFile:"package.json",message:[`cannot find package.json in ${e}`]});let r=F(e),o=te(e,r);if(o===null)throw u({code:"resolve_path_fail",target:"tsconfig.json",cwd:e,message:[`cannot find paths alias in your ${v.join(e,"tsconfig.json")}`]});if(await ee(e)&&(await confirm({message:"you already initialize,are you want to overwrite it?"})||process.exit(0)),t.style==="panda"){let n=await ne(e),s=await T.readFile(v.join(e,n),"utf-8"),d="styled-system",{outdir:l,importMap:c}=await ae(s);c?d=c:d=oe(e,l||"styled-system",r)||".",l&&(d=l);let p=b.schema.parse({style:t.style,utils:`${o}/utils`,components:`${o}/components`,hooks:`${o}/hooks`,styledsystem:d},{errorMap:()=>({message:"components.json is invalid"})});await T.writeFile(v.resolve(e,"components.json"),JSON.stringify(p),"utf-8");let y=ye({primary:t.primary,secondary:t.secondary,gray:t.gray});return await T.writeFile(v.join(e,"preset.ts"),y),se(v.resolve(e,n)),p}if(t.style==="tailwind"){let n=re(e,r);if(n===null)throw u({code:"resolve_path_fail",target:"tsconfig.json",cwd:e,message:[`cannot find base path in your ${v.join(e,"tsconfig.json")}`]});let s=b.schema.parse({style:t.style,utils:`${o}/utils`,components:`${o}/components`,hooks:`${o}/hooks`},{errorMap:()=>({message:"components.json is invalid"})});await T.writeFile(v.resolve(e,"components.json"),JSON.stringify(s),"utf-8");let d=he({primary:t.primary,secondary:t.secondary,gray:t.gray});return await T.outputFile(v.join(n,"styles.css"),d),await T.outputFile(v.join(await C(s.utils,r),"cn.ts"),`import { type ClassValue, clsx } from "clsx"
|
|
651
|
-
import { twMerge } from "tailwind-merge"
|
|
652
|
-
|
|
653
|
-
export function cn(...inputs: ClassValue[]) {
|
|
654
|
-
return twMerge(clsx(inputs))
|
|
655
|
-
}
|
|
656
|
-
`),s}}var _=new Server({name:"DesignSystemCLI",version:"1.0.0"},{capabilities:{resources:{},tools:{},prompts:{}}});_.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"init",description:"Initialize the design system and generate theme files.",inputSchema:zodToJsonSchema(D)},{name:"previewColors",description:"Generate a preview of selected color combinations.",inputSchema:zodToJsonSchema(E)}]}));_.setRequestHandler(CallToolRequestSchema,async t=>{try{if(!t.params.arguments)throw new Error("Arguments are required for this tool.");switch(t.params.name){case "init":try{let e=await W({...t.params.arguments,yes:!0});return await V(e),{content:[{type:"text",text:`Design system initialized for directory: ${e.cwd}. Theme files generated.`}]}}catch(e){return console.error("Error during init tool execution:",e),{content:[{type:"text",text:`Error initializing design system: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}default:return {content:[{type:"text",text:`Tool ${t.params.name} not found`}],isError:!0}}}catch(e){return console.error("Error parsing MCP request arguments:",e),e instanceof z.ZodError?{content:[{type:"text",text:`Invalid arguments for tool ${t.params?.name}: ${JSON.stringify(e.errors)}`}],isError:true}:{content:[{type:"text",text:`An unexpected error occurred: ${e instanceof Error?e.message:String(e)}`}],isError:true}}});_.setRequestHandler(ListPromptsRequestSchema,async()=>({prompts:[{name:"selectThemeColors",description:"Theme color selection guide for AI",arguments:[{name:"primary",description:"The primary color using design system"},{name:"secondary",description:"The secondary color using design system."},{name:"gray",description:"The gray color using design system."}]}]}));_.setRequestHandler(GetPromptRequestSchema,async t=>t.params.name!=="selectThemeColors"?{jsonrpc:"2.0",error:{code:-32601,message:`Prompt ${t.params.name} not found.`}}:{description:"Help the user select appropriate primary, secondary, and gray colors for the design system theme.",messages:[{role:"assistant",content:{type:"text",text:`I'll help you set up the theme colors for your design system.
|
|
657
|
-
|
|
658
|
-
**The goal is to determine primary, secondary, and gray colors based on your preference.**
|
|
659
|
-
|
|
660
|
-
**Available color palettes:**
|
|
661
|
-
- primary,secondary colors: ${j.join(", ")}
|
|
662
|
-
- Gray shades (for gray selection): ${I.join(", ")}
|
|
663
|
-
|
|
664
|
-
**Guidelines:**
|
|
665
|
-
1. **Guide the user to select the primary color only from the list above.**
|
|
666
|
-
2. **If the user requests a color not on the list, suggest the closest available color and guide them to choose from the list.**
|
|
667
|
-
3. **Secondary and gray colors must also be selected only from the list above.**
|
|
668
|
-
4. **Recommend secondary and gray colors that complement the primary color according to color theory and harmony principles.**
|
|
669
|
-
- Primary is a color that reflects the brand's message, and is used for major components throughout the UI, such as buttons and active states.
|
|
670
|
-
- Secondary is a supporting color, used throughout components that play a secondary role in the UI.
|
|
671
|
-
- Gray is used for text, backgrounds, borders, etc., serving to convey information and indicate hierarchy.
|
|
672
|
-
- The color contrast ratio must be checked to ensure it meets the WCAG (Web Content Accessibility Guidelines) AA level
|
|
673
|
-
5. **Strictly avoid color overlap.** Primary, secondary, and gray colors must be different from each other.
|
|
674
|
-
6. **Confirm the finalized color combination with the user.**
|
|
675
|
-
7. **Explain to the user the reason for the color selection.**
|
|
676
|
-
8. **Execute the 'init' tool with the final colors. Use only values exactly as they appear in the color list above.**
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
**Important notes:**
|
|
680
|
-
- Color values must only be used from the lists above.
|
|
681
|
-
- Colors not in the list (e.g., 'magenta', 'brown') cannot be used.
|
|
682
|
-
- When executing the 'DesignSystemCLI init' tool, color arguments must be passed with the exact names from the list.`}},{role:"user",content:{type:"text",text:"I need to set up the theme colors for my design system. Can you guide me through the process?"}},{role:"assistant",content:{type:"text",text:"I can help you set up the theme colors for your design system. First, you need to select a primary color. Please choose from the following colors: rose, pink, fuchsia, purple, violet, indigo, blue, sky, cyan, teal, emerald, green, lime, yellow, amber, orange, red, neutral, stone, zinc, gray, slate. Which color would you like to use as your primary color?"}}]});var ke=new Command().name("mcp").description("Manage your design system").action(async()=>{try{let t=new StdioServerTransport;await _.connect(t);}catch(t){console.error(t);}});var je={"@radix-ui/react-accessible-icon":"AccessibleIcon","@radix-ui/react-accordion":"Accordion","@radix-ui/react-alert-dialog":"AlertDialog","@radix-ui/react-aspect-ratio":"AspectRatio","@radix-ui/react-avatar":"Avatar","@radix-ui/react-checkbox":"Checkbox","@radix-ui/react-collapsible":"Collapsible","@radix-ui/react-context-menu":"ContextMenu","@radix-ui/react-dialog":"Dialog","@radix-ui/react-direction":"Direction","@radix-ui/react-dropdown-menu":"DropdownMenu","@radix-ui/react-form":"Form","@radix-ui/react-hover-card":"HoverCard","@radix-ui/react-label":"Label","@radix-ui/react-menubar":"Menubar","@radix-ui/react-navigation-menu":"NavigationMenu","@radix-ui/react-popover":"Popover","@radix-ui/react-portal":"Portal","@radix-ui/react-progress":"Progress","@radix-ui/react-radio-group":"RadioGroup","@radix-ui/react-scroll-area":"ScrollArea","@radix-ui/react-select":"Select","@radix-ui/react-separator":"Separator","@radix-ui/react-slider":"Slider","@radix-ui/react-slot":"Slot","@radix-ui/react-switch":"Switch","@radix-ui/react-tabs":"Tabs","@radix-ui/react-toast":"Toast","@radix-ui/react-toggle":"Toggle","@radix-ui/react-toggle-group":"ToggleGroup","@radix-ui/react-toolbar":"Toolbar","@radix-ui/react-tooltip":"Tooltip","@radix-ui/react-visually-hidden":"VisuallyHidden"};function M(t,e,r){return r?t===r:t===e}function Se(t){return `import {${t}} from "radix-ui"`}function Ce(t){let e=[];return t.getImportDeclarations().forEach(r=>{let o=r.getModuleSpecifierValue();if(!(o in je))return;let a=je[o];e.push(o);let n=r.getNamespaceImport();if(n){let d=n.getText();a!==d&&(a+=` as ${d}`),r.replaceWithText(Se(a));return}let s=r.getNamedImports();if(s.length){let d=a;s.forEach(l=>{let c=l.getName(),p=l.getAliasNode()?.getText(),y=`${d}.${c}`;for(let h of [SyntaxKind.JsxOpeningElement,SyntaxKind.JsxClosingElement,SyntaxKind.JsxSelfClosingElement])t.getDescendantsOfKind(h).forEach(m=>{let f=m.getTagNameNode().getText();M(f,c,p)&&m.getTagNameNode().replaceWithText(y);});t.getDescendantsOfKind(SyntaxKind.TypeQuery).forEach(h=>{h.getChildren().forEach(m=>{let f=m.getText();M(f,c,p)&&m.replaceWithText(y);});}),t.getDescendantsOfKind(SyntaxKind.ExpressionStatement).forEach(h=>{h.getChildrenOfKind(SyntaxKind.BinaryExpression).forEach(f=>{f.getRight().getChildren().forEach(g=>{let z=g.getText();M(z,c,p)&&g.replaceWithText(y);});});}),t.getDescendantsOfKind(SyntaxKind.VariableDeclaration).forEach(h=>{let m=h.getInitializer();m&&m.getChildren().forEach(f=>{let $=f.getText();M($,c,p)&&f.replaceWithText(y);});});}),r.replaceWithText(Se(d));}}),{source:t.getFullText(),packages:e}}var Te=new Command().name("radix-ui-import").action(()=>{intro("find .tsx files...");let t=Pe.sync("**/*.tsx",{ignore:["**/node_modules/**"],dot:false}),e=new Project,r="";t.forEach(o=>{let a=e.addSourceFileAtPathIfExists(v.join(process.cwd(),o));if(a)try{let{packages:n}=Ce(a);r+=n.join(" "),a.save();}catch(n){log.error(`failed to transform ${o} ${n}`);}}),r.length?`copy this to delete and install new package
|
|
683
|
-
<your package manager's delete command> ${r}
|
|
684
|
-
<your package manager's install command> ${de.bgGreen("radix-ui")}`.split(`
|
|
685
|
-
`).forEach(log.step):outro("no transform occured");});var _e={version:"4.1.0"};async function gt(){new Command().name("design-system").version(_e.version).addCommand(be).addCommand(pe).addCommand(me).addCommand(Te).addCommand(ke).parse();}gt();
|
|
4
|
+
`)}},g=t=>{let e;switch(t.code){case v.config_not_found:e=`error occured while config ${t.configFile}`;break;case v.resolve_path_fail:e=`failed to resolve your path, current ${t.cwd}`;break;case v.failed_to_fetch:e=`failed to fetch ${t.target} [${t.statusCode}]`;break;default:e="error occured";}return new h({...t,message:[...t.message||"",e]})};var oe=z$1.object({utils:z$1.string(),components:z$1.string(),hooks:z$1.string()}),E={fileName:"components.json",schema:oe.strict()},te=z$1.object({name:z$1.string(),content:z$1.string(),type:z$1.enum(["ui","hooks","utils"])}),z=z$1.object({name:z$1.string(),dependencies:z$1.array(z$1.string()).optional(),files:z$1.array(te)});function R(t){try{return T.readJsonSync(S.resolve(t,E.fileName))}catch(e){return g({code:"config_not_found",configFile:E.fileName,message:[e instanceof Error?e.message:""]})}}function j(t){let e=loadConfig(t);if(e.resultType==="failed")throw g({code:"config_not_found",configFile:"tsconfig.json",message:["cannot found tsconfig.json"]});return e}async function D(t){return await T.pathExists(S.join(t,"components.json"))}function A(t,e){let o=["./","./src/","./app/","./src/app"].map(r=>S.resolve(t,r));for(let[r,n]of Object.entries(e.paths)){let s=S.join(t,e.baseUrl||"",n[0].replace(/\/\*$/,""));if(o.some(i=>i===s||i.includes(s)))return r.replace(/\/\*$/,"")}return null}async function _(t,e){let o=createMatchPath(e.absoluteBaseUrl,e.paths)(t,void 0,()=>true);if(!o)throw g({code:"resolve_path_fail",target:t,cwd:process.cwd(),message:["resolve error"]});return o}function U(t,e){let o=t;return [{from:/@\/component\/([^/"']+)/g,to:`${e.components}/$1`},{from:/@utils\//g,to:`${e.utils}/`},{from:/@hooks\//g,to:`${e.hooks}/`},{from:/@components\//g,to:`${e.components}/`}].forEach(({from:n,to:s})=>{o=o.replace(n,s);}),o}async function B(t,e){let o=await detect({cwd:t}),r=resolveCommand(o?.agent||"npm","add",e);if(r)return r}var pe=z$1.object({components:z$1.array(z$1.string()).optional(),cwd:z$1.string()}),de=(process.env.JDS_REGISTRY_URL??"https://raw.githubusercontent.com/jongh-design-system/jds/dev/registry").replace(/\/$/,""),b=J.bold.red,N=J.bold.blue,K=new Command().name("add").argument("[components...]").option("-c, --cwd <cwd>","current working directory, default to process.cwd()",process.cwd()).action(async(t,e)=>{try{let o=pe.parse({components:t,...e});intro(N("install components..."));let r=E.schema.parse(R(o.cwd),{errorMap:()=>({message:"components.json is invalid"})}),n=j(o.cwd),s={utils:await _(r.utils,n),components:await _(r.components,n),hooks:await _(r.hooks,n)},i=o.components?.map(p=>p.toLowerCase());if(!i?.length)return;let x=await Promise.allSettled(i.map(async p=>{let a=await fetch(`${de}/${p}.json`);if(!a.ok)throw g({code:"failed_to_fetch",target:p,statusCode:a.status,message:[a.statusText]});return await a.json()}));for(let[p,a]of x.entries()){if(a.status==="rejected"){a.reason instanceof h?console.log(b(a.reason.format)):console.log(b(a.reason));continue}try{let l=z.parse(a.value,{errorMap:()=>({message:`registry for ${i[p]} is invaliad`})}),y=S.join(s.components,i[p]);if(T.pathExistsSync(y)&&!await confirm({message:`Component ${i[p]} already exists. Do you want to overwrite it?`}))return;l.files.forEach(u=>{let C=U(u.content,r);u.type==="ui"?T.outputFileSync(S.join(y,u.name),C):T.outputFileSync(S.join(s[u.type],u.name),C,"utf-8");});let d=l.dependencies||[],c=d.length?await B(o.cwd,d):void 0,f=d.length?c?`Run this command in the terminal : ${c.command} ${c.args.join(" ")}`:`Cannot find your package manager, install this dependencies: ${d.join(" ")}`:"No additional dependencies required";outro(N(`${i[p]} completed successfully
|
|
5
|
+
${f}`));}catch(l){l instanceof Error&&console.log(b(l.message));}}}catch(o){outro(b(N("error occured"))),o instanceof z$1.ZodError&&console.log(o.message),o instanceof h&&console.log(b(o.format)),o instanceof Error&&console.log(b(o.message)),process.exit(1);}});var G=z$1.object({cwd:z$1.string().default(()=>process.cwd())});var F=J.bold.red,V=new Command().name("init").description("Initialize the project").option("-c, --cwd <cwd>","current working directory, default to process.cwd()",process.cwd()).action(async t=>{let e=spinner();e.start("Initializing");try{let o=G.parse({cwd:S.resolve(t.cwd)});await we(o),e.stop("successfully Initialized!");}catch(o){e.stop(F("error occured")),o instanceof z$1.ZodError&&console.log(o.message),o instanceof h&&console.log(F(o.format)),o instanceof Error&&console.log(F(o.message)),process.exit(1);}});async function we(t){let e=await packageDirectory({cwd:t.cwd});if(!e)throw g({code:"config_not_found",configFile:"package.json",message:[`cannot find package.json in ${e}`]});let o=j(e),r=A(e,o);if(r===null)throw g({code:"resolve_path_fail",target:"tsconfig.json",cwd:e,message:[`cannot find paths alias in your ${S.join(e,"tsconfig.json")}`]});await D(e)&&(await confirm({message:"you already initialize,are you want to overwrite it?"})||process.exit(0));let s={utils:`${r}/utils`,components:`${r}/components`,hooks:`${r}/hooks`};return await T.writeFile(S.resolve(e,"components.json"),JSON.stringify(s),"utf-8"),s}var Y={"@radix-ui/react-accessible-icon":"AccessibleIcon","@radix-ui/react-accordion":"Accordion","@radix-ui/react-alert-dialog":"AlertDialog","@radix-ui/react-aspect-ratio":"AspectRatio","@radix-ui/react-avatar":"Avatar","@radix-ui/react-checkbox":"Checkbox","@radix-ui/react-collapsible":"Collapsible","@radix-ui/react-context-menu":"ContextMenu","@radix-ui/react-dialog":"Dialog","@radix-ui/react-direction":"Direction","@radix-ui/react-dropdown-menu":"DropdownMenu","@radix-ui/react-form":"Form","@radix-ui/react-hover-card":"HoverCard","@radix-ui/react-label":"Label","@radix-ui/react-menubar":"Menubar","@radix-ui/react-navigation-menu":"NavigationMenu","@radix-ui/react-popover":"Popover","@radix-ui/react-portal":"Portal","@radix-ui/react-progress":"Progress","@radix-ui/react-radio-group":"RadioGroup","@radix-ui/react-scroll-area":"ScrollArea","@radix-ui/react-select":"Select","@radix-ui/react-separator":"Separator","@radix-ui/react-slider":"Slider","@radix-ui/react-slot":"Slot","@radix-ui/react-switch":"Switch","@radix-ui/react-tabs":"Tabs","@radix-ui/react-toast":"Toast","@radix-ui/react-toggle":"Toggle","@radix-ui/react-toggle-group":"ToggleGroup","@radix-ui/react-toolbar":"Toolbar","@radix-ui/react-tooltip":"Tooltip","@radix-ui/react-visually-hidden":"VisuallyHidden"};function I(t,e,o){return o?t===o:t===e}function H(t){return `import {${t}} from "radix-ui"`}function Z(t){let e=[];return t.getImportDeclarations().forEach(o=>{let r=o.getModuleSpecifierValue();if(!(r in Y))return;let n=Y[r];e.push(r);let s=o.getNamespaceImport();if(s){let x=s.getText();n!==x&&(n+=` as ${x}`),o.replaceWithText(H(n));return}let i=o.getNamedImports();if(i.length){let x=n;i.forEach(p=>{let a=p.getName(),l=p.getAliasNode()?.getText(),y=`${x}.${a}`;for(let d of [SyntaxKind.JsxOpeningElement,SyntaxKind.JsxClosingElement,SyntaxKind.JsxSelfClosingElement])t.getDescendantsOfKind(d).forEach(c=>{let f=c.getTagNameNode().getText();I(f,a,l)&&c.getTagNameNode().replaceWithText(y);});t.getDescendantsOfKind(SyntaxKind.TypeQuery).forEach(d=>{d.getChildren().forEach(c=>{let f=c.getText();I(f,a,l)&&c.replaceWithText(y);});}),t.getDescendantsOfKind(SyntaxKind.ExpressionStatement).forEach(d=>{d.getChildrenOfKind(SyntaxKind.BinaryExpression).forEach(f=>{f.getRight().getChildren().forEach(C=>{let ee=C.getText();I(ee,a,l)&&C.replaceWithText(y);});});}),t.getDescendantsOfKind(SyntaxKind.VariableDeclaration).forEach(d=>{let c=d.getInitializer();c&&c.getChildren().forEach(f=>{let u=f.getText();I(u,a,l)&&f.replaceWithText(y);});});}),o.replaceWithText(H(x));}}),{source:t.getFullText(),packages:e}}var Q=new Command().name("radix-ui-import").action(()=>{intro("find .tsx files...");let t=Se.sync("**/*.tsx",{ignore:["**/node_modules/**"],dot:false}),e=new Project,o="";t.forEach(r=>{let n=e.addSourceFileAtPathIfExists(S.join(process.cwd(),r));if(n)try{let{packages:s}=Z(n);o+=s.join(" "),n.save();}catch(s){log.error(`failed to transform ${r} ${s}`);}}),o.length?`copy this to delete and install new package
|
|
6
|
+
<your package manager's delete command> ${o}
|
|
7
|
+
<your package manager's install command> ${J.bgGreen("radix-ui")}`.split(`
|
|
8
|
+
`).forEach(log.step):outro("no transform occured");});var X={version:"5.20260905.1"};async function Te(){new Command().name("design-system").version(X.version).addCommand(V).addCommand(K).addCommand(Q).parse();}Te();
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jongh/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.20260905.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"bin": "./dist/index.js",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"keywords": [],
|
|
8
7
|
"author": "",
|
|
@@ -28,7 +27,6 @@
|
|
|
28
27
|
"@babel/traverse": "^7.26.4",
|
|
29
28
|
"@clack/prompts": "^0.7.0",
|
|
30
29
|
"@effect/platform": "^0.69.13",
|
|
31
|
-
"@effect/schema": "^0.75.5",
|
|
32
30
|
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
33
31
|
"@types/babel__traverse": "^7.20.6",
|
|
34
32
|
"chalk": "^5.4.1",
|
|
@@ -37,7 +35,6 @@
|
|
|
37
35
|
"execa": "^9.5.2",
|
|
38
36
|
"fast-glob": "^3.3.2",
|
|
39
37
|
"fs-extra": "^11.2.0",
|
|
40
|
-
"handlebars": "^4.7.8",
|
|
41
38
|
"package-manager-detector": "^0.2.8",
|
|
42
39
|
"pkg-dir": "^8.0.0",
|
|
43
40
|
"ts-morph": "^25.0.0",
|
|
@@ -47,6 +44,8 @@
|
|
|
47
44
|
"zod-to-json-schema": "^3.24.5"
|
|
48
45
|
},
|
|
49
46
|
"devDependencies": {
|
|
47
|
+
"@jongh/eslint": "0.0.0",
|
|
48
|
+
"@jongh/tsconfig": "0.0.0",
|
|
50
49
|
"@types/babel__generator": "^7.6.8",
|
|
51
50
|
"@types/fs-extra": "^11.0.4",
|
|
52
51
|
"@types/node": "^22.8.6",
|
|
@@ -54,16 +53,18 @@
|
|
|
54
53
|
"ts-node": "^10.9.2",
|
|
55
54
|
"tsup": "^8.3.0",
|
|
56
55
|
"tsx": "^4.19.2",
|
|
57
|
-
"
|
|
58
|
-
"@jongh/tsconfig": "0.0.0"
|
|
56
|
+
"vitest": "4.1.11"
|
|
59
57
|
},
|
|
60
58
|
"scripts": {
|
|
61
|
-
"build": "tsup
|
|
59
|
+
"build": "tsup",
|
|
62
60
|
"build:cli": "tsup",
|
|
63
|
-
"build:registry": "
|
|
61
|
+
"build:registry": "tsx src/build-script.ts --all",
|
|
64
62
|
"release": "pnpm publish -no-git-checks",
|
|
65
63
|
"lint": "eslint --max-warnings 0 --no-warn-ignored --fix",
|
|
66
64
|
"check-type": "tsgo --noEmit",
|
|
67
65
|
"test": "vitest run"
|
|
66
|
+
},
|
|
67
|
+
"bin": {
|
|
68
|
+
"cli": "./dist/index.js"
|
|
68
69
|
}
|
|
69
70
|
}
|