@jongh/cli 2.1.0 → 4.0.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.
- package/dist/index.js +366 -10
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,358 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {Command}from'commander';import {intro,confirm,outro,spinner,select
|
|
2
|
+
import {Command}from'commander';import {intro,confirm,outro,spinner,log,select}from'@clack/prompts';import le from'chalk';import T from'fs-extra';import v from'path';import {z as z$1}from'zod';import ze from'fast-glob';import {loadConfig,createMatchPath}from'tsconfig-paths';import {Project,SyntaxKind}from'ts-morph';import {detect,resolveCommand}from'package-manager-detector';import {packageDirectory}from'pkg-dir';import ge from'handlebars';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema,ListPromptsRequestSchema,GetPromptRequestSchema}from'@modelcontextprotocol/sdk/types.js';import {zodToJsonSchema}from'zod-to-json-schema';var K=t=>{let e={};for(let r of t)e[r]=r;return e},H=K(["config_not_found","resolve_path_fail","failed_to_fetch"]);K(["components.json","tsconfig.json","panda.config.*","package.json"]);var x=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
|
-
`)}},u=t=>{let e;switch(t.code){case
|
|
5
|
-
${$}`));}catch(
|
|
4
|
+
`)}},u=t=>{let e;switch(t.code){case H.config_not_found:e=`error occured while config ${t.configFile}`;break;case H.resolve_path_fail:e=`failed to resolve your path, current ${t.cwd}`;break;case H.failed_to_fetch:e=`failed to fetch ${t.target} [${t.statusCode}]`;break;default:e="error occured";}return new x({...t,message:[...t.message||"",e]})};var L=z$1.enum(["panda","tailwind"]),q=z$1.object({utils:z$1.string(),components:z$1.string(),hooks:z$1.string()}),b={fileName:"components.json",schema:z$1.discriminatedUnion("style",[q.extend({style:z$1.literal("panda"),styledsystem:z$1.string()}).strict(),q.extend({style:z$1.literal("tailwind")}).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(),styles:z$1.record(z$1.string(),z$1.object({dependencies:z$1.array(z$1.string()).optional(),files:z$1.array(Te)}))});z$1.object({name:z$1.string(),dependencies:z$1.array(z$1.string()).optional(),file:z$1.string()});function Q(t){try{return T.readJsonSync(v.resolve(t,b.fileName))}catch(e){return u({code:"config_not_found",configFile:b.fileName,message:[e instanceof Error?e.message:""]})}}function F(t){let e=loadConfig(t);if(e.resultType==="failed")throw u({code:"config_not_found",configFile:"tsconfig.json",message:["cannot found tsconfig.json"]});return e}async function X(t){return await T.pathExists(v.join(t,"components.json"))}function ee(t,e){let r=["./","./src/","./app/","./src/app"].map(o=>v.resolve(t,o));for(let[o,a]of Object.entries(e.paths)){let n=v.join(t,e.baseUrl||"",a[0].replace(/\/\*$/,""));if(r.some(i=>i===n||i.includes(n)))return o.replace(/\/\*$/,"")}return null}function te(t,e){let r=["./","./src/","./app/","./src/app"].map(o=>v.resolve(t,o));for(let o of Object.values(e.paths)){let a=v.join(t,e.baseUrl||"",o[0].replace(/\/\*$/,""));if(r.some(n=>n===a||n.includes(a)))return a}return null}function re(t,e,r){let o=v.join(t,e);for(let[a,n]of Object.entries(r.paths)){let i=n[0].replace(/\/\*$/,"");if(o===v.join(t,r.baseUrl||"",i))return a.replace(/\/\*$/,"")}return null}async function oe(t){try{let e=await ze.glob(["panda.config.*"],{cwd:t,deep:3});if(!e.length)throw u({code:"config_not_found",configFile:"panda.config.*",message:["failed to find panda.config file"]});return e[0]}catch(e){throw u({code:"config_not_found",configFile:"panda.config.*",message:[e instanceof Error?e.message:"unknown error occured finding panda.config"]})}}async function C(t,e){let r=createMatchPath(e.absoluteBaseUrl,e.paths)(t,void 0,()=>true);if(!r)throw u({code:"resolve_path_fail",target:t,cwd:process.cwd(),message:["resolve error"]});return r}async function ne(t){let e=t.match(/outdir:\s*["']([^"']+)["']/),r=t.match(/importMap:\s*({[^}]+}|["'][^"']+["'])/),o=e?e[1]:null,a=null;if(r){let n=r[1];if(n.startsWith("{")){let i=n.match(/css:\s*["']([^"']+)["']/);a=i?i[1].replace(/\/css$/,""):null;}else a=n.replace(/["']/g,"");}return {outdir:o,importMap:a}}function ae(t,e){let r=t,o=[{from:/@\/component\/([^/"']+)\/(?:panda|tailwind)/g,to:`${e.components}/$1`},{from:/@utils\//g,to:`${e.utils}/`},{from:/@hooks\//g,to:`${e.hooks}/`},{from:/@components\//g,to:`${e.components}/`}];return e.style==="panda"&&o.push({from:/@styled-system\//g,to:`${e.styledsystem}/`}),o.forEach(({from:a,to:n})=>{r=r.replace(a,n);}),r}function ie(t){let r=new Project().addSourceFileAtPath(t),o=[{namedImports:[{name:"preset"}],moduleSpecifier:"panda-animation"},{namedImports:[{name:"defaultPreset"}],moduleSpecifier:"./preset"}];r.addImportDeclarations(o);let n=r.getFirstDescendantByKind(SyntaxKind.CallExpression)?.getArguments()[0];n?(n.getProperty("presets")||n.addPropertyAssignment({name:"presets",initializer:'[preset(), "@pandacss/preset-panda", defaultPreset]'}),r.saveSync()):console.warn("Could not modify panda.config.ts. add presets : [preset(), @pandacss/preset-panda, defaultPreset] in your panda.config");}async function O(t,e){let r=await detect({cwd:t}),o=resolveCommand(r?.agent||"npm","add",e);if(o)return o}var We=z$1.object({components:z$1.array(z$1.string()).optional(),cwd:z$1.string()}),De=(process.env.JDS_REGISTRY_URL??"https://jds-docs.vercel.app").replace(/\/$/,""),k=le.bold.red,B=le.bold.blue,de=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 r=We.parse({components:t,...e});intro(B("install components..."));let o=b.schema.parse(Q(r.cwd),{errorMap:()=>({message:"components.json is invalid"})}),a=F(r.cwd),n={utils:await C(o.utils,a),components:await C(o.components,a),hooks:await C(o.hooks,a)},i=r.components?.map(l=>l.toLowerCase());if(!i?.length)return;let d=await Promise.allSettled(i.map(async l=>{let c=await fetch(`${De}/${l}.json`);if(!c.ok)throw u({code:"failed_to_fetch",target:l,statusCode:c.status,message:[c.statusText]});return await c.json()}));for(let[l,c]of d.entries()){if(c.status==="rejected"){c.reason instanceof x?console.log(k(c.reason.format)):console.log(k(c.reason));continue}try{let p=Z.parse(c.value,{errorMap:()=>({message:`registry for ${i[l]} is invaliad`})}),y=p.styles[o.style];if(!y){let[g]=Object.keys(p.styles);if(!g){console.log(k(`${i[l]} has no styles`));continue}if(!await confirm({message:`${i[l]} does not support ${o.style}. Install ${g} instead?`}))continue;y=p.styles[g];}let h=v.join(n.components,i[l]);if(T.pathExistsSync(h)&&!await confirm({message:`Component ${i[l]} already exists. Do you want to overwrite it?`}))return;y.files.forEach(g=>{let _=ae(g.content,o);g.type==="ui"?T.outputFileSync(v.join(h,g.name),_):T.outputFileSync(v.join(n[g.type],g.name),_,"utf-8");});let m=y.dependencies||[],f=m.length?await O(r.cwd,m):void 0,$=m.length?f?`Run this command in the terminal : ${f.command} ${f.args.join(" ")}`:`Cannot find your package manager, install this dependencies: ${m.join(" ")}`:"No additional dependencies required";outro(B(`${i[l]} completed successfully
|
|
5
|
+
${$}`));}catch(p){p instanceof Error&&console.log(k(p.message));}}}catch(r){outro(k(B("error occured"))),r instanceof z$1.ZodError&&console.log(r.message),r instanceof x&&console.log(k(r.format)),r instanceof Error&&console.log(k(r.message)),process.exit(1);}});var pe=`@import "tailwindcss";
|
|
6
|
+
|
|
7
|
+
@theme inline {
|
|
8
|
+
--color-background: var(--jds-background);
|
|
9
|
+
|
|
10
|
+
--color-foreground: var(--jds-foreground);
|
|
11
|
+
--color-foreground-muted: var(--jds-foreground-muted);
|
|
12
|
+
--color-foreground-emphasized: var(--jds-foreground-emphasized);
|
|
13
|
+
--color-foreground-primary: var(--jds-foreground-primary);
|
|
14
|
+
--color-foreground-destructive: var(--jds-foreground-destructive);
|
|
15
|
+
--color-foreground-inverted: var(--jds-foreground-inverted);
|
|
16
|
+
|
|
17
|
+
--color-layer: var(--jds-layer);
|
|
18
|
+
--color-layer-floating: var(--jds-layer-floating);
|
|
19
|
+
--color-layer-active: var(--jds-layer-active);
|
|
20
|
+
--color-layer-overlay: var(--jds-layer-overlay);
|
|
21
|
+
|
|
22
|
+
--color-primary: var(--jds-primary);
|
|
23
|
+
--color-primary-active: var(--jds-primary-active);
|
|
24
|
+
--color-primary-foreground: var(--jds-primary-foreground);
|
|
25
|
+
|
|
26
|
+
--color-secondary: var(--jds-secondary);
|
|
27
|
+
--color-secondary-active: var(--jds-secondary-active);
|
|
28
|
+
--color-secondary-foreground: var(--jds-secondary-foreground);
|
|
29
|
+
|
|
30
|
+
--color-neutral: var(--jds-neutral);
|
|
31
|
+
--color-neutral-active: var(--jds-neutral-active);
|
|
32
|
+
|
|
33
|
+
--color-destructive: var(--jds-destructive);
|
|
34
|
+
--color-destructive-active: var(--jds-destructive-active);
|
|
35
|
+
--color-destructive-foreground: var(--jds-destructive-foreground);
|
|
36
|
+
|
|
37
|
+
--color-stroke: var(--jds-stroke);
|
|
38
|
+
--color-stroke-subtle: var(--jds-stroke-subtle);
|
|
39
|
+
--color-stroke-interactive: var(--jds-stroke-interactive);
|
|
40
|
+
--color-stroke-ring: var(--jds-stroke-ring);
|
|
41
|
+
--color-stroke-destructive: var(--jds-stroke-destructive);
|
|
42
|
+
|
|
43
|
+
--radius-radius: var(--jds-radius);
|
|
44
|
+
--radius-md: var(--jds-radius);
|
|
45
|
+
|
|
46
|
+
--animate-accordion-down: accordion-down-radix 150ms ease-out;
|
|
47
|
+
--animate-accordion-up: accordion-up-radix 150ms ease-out;
|
|
48
|
+
--animate-content-show: content-show 200ms ease-out;
|
|
49
|
+
--animate-fade-in: fade-in 200ms ease-out;
|
|
50
|
+
--animate-fade-out: fade-out 200ms ease-out;
|
|
51
|
+
--animate-slide-in-down: slide-in-down 200ms ease-out;
|
|
52
|
+
|
|
53
|
+
--text-display1: 4.5rem;
|
|
54
|
+
--text-display1--line-height: var(--leading-loose);
|
|
55
|
+
--text-display1--letter-spacing: var(--tracking-tight);
|
|
56
|
+
--text-display1--font-weight: var(--font-weight-bold);
|
|
57
|
+
|
|
58
|
+
--text-display2: 3.75rem;
|
|
59
|
+
--text-display2--line-height: var(--leading-relaxed);
|
|
60
|
+
--text-display2--letter-spacing: var(--tracking-tight);
|
|
61
|
+
--text-display2--font-weight: var(--font-weight-bold);
|
|
62
|
+
|
|
63
|
+
--text-title1: 2.25rem;
|
|
64
|
+
--text-title1--line-height: var(--leading-normal);
|
|
65
|
+
--text-title1--letter-spacing: var(--tracking-tight);
|
|
66
|
+
--text-title1--font-weight: var(--font-weight-semibold);
|
|
67
|
+
|
|
68
|
+
--text-title2: 1.5rem;
|
|
69
|
+
--text-title2--line-height: var(--leading-snug);
|
|
70
|
+
--text-title2--letter-spacing: var(--tracking-tight);
|
|
71
|
+
--text-title2--font-weight: var(--font-weight-semibold);
|
|
72
|
+
|
|
73
|
+
--text-title3: 1.25rem;
|
|
74
|
+
--text-title3--line-height: var(--leading-snug);
|
|
75
|
+
--text-title3--letter-spacing: var(--tracking-tight);
|
|
76
|
+
--text-title3--font-weight: var(--font-weight-bold);
|
|
77
|
+
|
|
78
|
+
--text-heading1: 1.125rem;
|
|
79
|
+
--text-heading1--line-height: var(--leading-normal);
|
|
80
|
+
--text-heading1--letter-spacing: var(--tracking-normal);
|
|
81
|
+
--text-heading1--font-weight: var(--font-weight-semibold);
|
|
82
|
+
|
|
83
|
+
--text-heading2: 1rem;
|
|
84
|
+
--text-heading2--line-height: var(--leading-normal);
|
|
85
|
+
--text-heading2--letter-spacing: var(--tracking-normal);
|
|
86
|
+
--text-heading2--font-weight: var(--font-weight-semibold);
|
|
87
|
+
|
|
88
|
+
--text-body1: 1rem;
|
|
89
|
+
--text-body1--line-height: var(--leading-relaxed);
|
|
90
|
+
--text-body1--letter-spacing: var(--tracking-normal);
|
|
91
|
+
--text-body1--font-weight: var(--font-weight-normal);
|
|
92
|
+
|
|
93
|
+
--text-body2: 0.875rem;
|
|
94
|
+
--text-body2--line-height: var(--leading-normal);
|
|
95
|
+
--text-body2--letter-spacing: var(--tracking-normal);
|
|
96
|
+
--text-body2--font-weight: var(--font-weight-normal);
|
|
97
|
+
|
|
98
|
+
--text-label1: 0.875rem;
|
|
99
|
+
--text-label1--line-height: var(--leading-snug);
|
|
100
|
+
--text-label1--letter-spacing: var(--tracking-wide);
|
|
101
|
+
--text-label1--font-weight: var(--font-weight-semibold);
|
|
102
|
+
|
|
103
|
+
--text-label2: 0.75rem;
|
|
104
|
+
--text-label2--line-height: var(--leading-snug);
|
|
105
|
+
--text-label2--letter-spacing: var(--tracking-wide);
|
|
106
|
+
--text-label2--font-weight: var(--font-weight-semibold);
|
|
107
|
+
|
|
108
|
+
--text-caption1: 0.75rem;
|
|
109
|
+
--text-caption1--line-height: var(--leading-tight);
|
|
110
|
+
--text-caption1--letter-spacing: var(--tracking-wide);
|
|
111
|
+
--text-caption1--font-weight: var(--font-weight-semibold);
|
|
112
|
+
|
|
113
|
+
--text-caption2: 0.625rem;
|
|
114
|
+
--text-caption2--line-height: var(--leading-tight);
|
|
115
|
+
--text-caption2--letter-spacing: var(--tracking-wide);
|
|
116
|
+
--text-caption2--font-weight: var(--font-weight-semibold);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@utility typo-display1 {
|
|
120
|
+
font-size: var(--text-display1);
|
|
121
|
+
font-weight: var(--text-display1--font-weight);
|
|
122
|
+
letter-spacing: var(--text-display1--letter-spacing);
|
|
123
|
+
line-height: var(--text-display1--line-height);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@utility typo-display2 {
|
|
127
|
+
font-size: var(--text-display2);
|
|
128
|
+
font-weight: var(--text-display2--font-weight);
|
|
129
|
+
letter-spacing: var(--text-display2--letter-spacing);
|
|
130
|
+
line-height: var(--text-display2--line-height);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@utility typo-title1 {
|
|
134
|
+
font-size: var(--text-title1);
|
|
135
|
+
font-weight: var(--text-title1--font-weight);
|
|
136
|
+
letter-spacing: var(--text-title1--letter-spacing);
|
|
137
|
+
line-height: var(--text-title1--line-height);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@utility typo-title2 {
|
|
141
|
+
font-size: var(--text-title2);
|
|
142
|
+
font-weight: var(--text-title2--font-weight);
|
|
143
|
+
letter-spacing: var(--text-title2--letter-spacing);
|
|
144
|
+
line-height: var(--text-title2--line-height);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@utility typo-title3 {
|
|
148
|
+
font-size: var(--text-title3);
|
|
149
|
+
font-weight: var(--text-title3--font-weight);
|
|
150
|
+
letter-spacing: var(--text-title3--letter-spacing);
|
|
151
|
+
line-height: var(--text-title3--line-height);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@utility typo-heading1 {
|
|
155
|
+
font-size: var(--text-heading1);
|
|
156
|
+
font-weight: var(--text-heading1--font-weight);
|
|
157
|
+
letter-spacing: var(--text-heading1--letter-spacing);
|
|
158
|
+
line-height: var(--text-heading1--line-height);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@utility typo-heading2 {
|
|
162
|
+
font-size: var(--text-heading2);
|
|
163
|
+
font-weight: var(--text-heading2--font-weight);
|
|
164
|
+
letter-spacing: var(--text-heading2--letter-spacing);
|
|
165
|
+
line-height: var(--text-heading2--line-height);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@utility typo-body1 {
|
|
169
|
+
font-size: var(--text-body1);
|
|
170
|
+
font-weight: var(--text-body1--font-weight);
|
|
171
|
+
letter-spacing: var(--text-body1--letter-spacing);
|
|
172
|
+
line-height: var(--text-body1--line-height);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@utility typo-body2 {
|
|
176
|
+
font-size: var(--text-body2);
|
|
177
|
+
font-weight: var(--text-body2--font-weight);
|
|
178
|
+
letter-spacing: var(--text-body2--letter-spacing);
|
|
179
|
+
line-height: var(--text-body2--line-height);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@utility typo-label1 {
|
|
183
|
+
font-size: var(--text-label1);
|
|
184
|
+
font-weight: var(--text-label1--font-weight);
|
|
185
|
+
letter-spacing: var(--text-label1--letter-spacing);
|
|
186
|
+
line-height: var(--text-label1--line-height);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@utility typo-label2 {
|
|
190
|
+
font-size: var(--text-label2);
|
|
191
|
+
font-weight: var(--text-label2--font-weight);
|
|
192
|
+
letter-spacing: var(--text-label2--letter-spacing);
|
|
193
|
+
line-height: var(--text-label2--line-height);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@utility typo-caption1 {
|
|
197
|
+
font-size: var(--text-caption1);
|
|
198
|
+
font-weight: var(--text-caption1--font-weight);
|
|
199
|
+
letter-spacing: var(--text-caption1--letter-spacing);
|
|
200
|
+
line-height: var(--text-caption1--line-height);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@utility typo-caption2 {
|
|
204
|
+
font-size: var(--text-caption2);
|
|
205
|
+
font-weight: var(--text-caption2--font-weight);
|
|
206
|
+
letter-spacing: var(--text-caption2--letter-spacing);
|
|
207
|
+
line-height: var(--text-caption2--line-height);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@keyframes accordion-down-radix {
|
|
211
|
+
from {
|
|
212
|
+
height: 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
to {
|
|
216
|
+
height: var(--radix-accordion-content-height);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@keyframes accordion-up-radix {
|
|
221
|
+
from {
|
|
222
|
+
height: var(--radix-accordion-content-height);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
to {
|
|
226
|
+
height: 0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@keyframes content-show {
|
|
231
|
+
from {
|
|
232
|
+
opacity: 0;
|
|
233
|
+
transform: translate(-50%, -48%) scale(0.96);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
to {
|
|
237
|
+
opacity: 1;
|
|
238
|
+
transform: translate(-50%, -50%) scale(1);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@keyframes fade-in {
|
|
243
|
+
from {
|
|
244
|
+
opacity: 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
to {
|
|
248
|
+
opacity: 1;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes fade-out {
|
|
253
|
+
from {
|
|
254
|
+
opacity: 1;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
to {
|
|
258
|
+
opacity: 0;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@keyframes slide-in-down {
|
|
263
|
+
from {
|
|
264
|
+
transform: translate3d(0, -100%, 0);
|
|
265
|
+
visibility: visible;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
to {
|
|
269
|
+
transform: translateZ(0);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
:root {
|
|
274
|
+
--jds-radius: 0.5rem;
|
|
275
|
+
|
|
276
|
+
--jds-background: var(--color-white);
|
|
277
|
+
|
|
278
|
+
--jds-foreground: var(--color-{{gray}}-700);
|
|
279
|
+
--jds-foreground-muted: var(--color-{{gray}}-500);
|
|
280
|
+
--jds-foreground-emphasized: var(--color-{{gray}}-900);
|
|
281
|
+
--jds-foreground-primary: var(--color-{{primary}}-600);
|
|
282
|
+
--jds-foreground-destructive: var(--color-red-600);
|
|
283
|
+
--jds-foreground-inverted: var(--color-white);
|
|
284
|
+
|
|
285
|
+
--jds-layer: var(--color-white);
|
|
286
|
+
--jds-layer-floating: var(--color-{{gray}}-50);
|
|
287
|
+
--jds-layer-active: var(--color-{{gray}}-100);
|
|
288
|
+
--jds-layer-overlay: color-mix(in oklab, var(--color-black) 50%, transparent);
|
|
289
|
+
|
|
290
|
+
--jds-primary: var(--color-{{primary}}-600);
|
|
291
|
+
--jds-primary-active: var(--color-{{primary}}-700);
|
|
292
|
+
--jds-primary-foreground: var(--color-white);
|
|
293
|
+
|
|
294
|
+
--jds-secondary: var(--color-{{secondary}}-700);
|
|
295
|
+
--jds-secondary-active: var(--color-{{secondary}}-800);
|
|
296
|
+
--jds-secondary-foreground: var(--color-white);
|
|
297
|
+
|
|
298
|
+
--jds-neutral: var(--color-{{gray}}-100);
|
|
299
|
+
--jds-neutral-active: var(--color-{{gray}}-200);
|
|
300
|
+
|
|
301
|
+
--jds-destructive: var(--color-red-600);
|
|
302
|
+
--jds-destructive-active: var(--color-red-700);
|
|
303
|
+
--jds-destructive-foreground: var(--color-white);
|
|
304
|
+
|
|
305
|
+
--jds-stroke: var(--color-{{gray}}-300);
|
|
306
|
+
--jds-stroke-subtle: var(--color-{{gray}}-200);
|
|
307
|
+
--jds-stroke-interactive: var(--color-{{primary}}-400);
|
|
308
|
+
--jds-stroke-ring: var(--color-{{primary}}-500);
|
|
309
|
+
--jds-stroke-destructive: var(--color-red-500);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.dark {
|
|
313
|
+
--jds-background: var(--color-{{gray}}-950);
|
|
314
|
+
|
|
315
|
+
--jds-foreground: var(--color-{{gray}}-300);
|
|
316
|
+
--jds-foreground-muted: var(--color-{{gray}}-400);
|
|
317
|
+
--jds-foreground-emphasized: var(--color-{{gray}}-100);
|
|
318
|
+
--jds-foreground-primary: var(--color-{{primary}}-400);
|
|
319
|
+
--jds-foreground-destructive: var(--color-red-400);
|
|
320
|
+
--jds-foreground-inverted: var(--color-{{gray}}-950);
|
|
321
|
+
|
|
322
|
+
--jds-layer: var(--color-{{gray}}-950);
|
|
323
|
+
--jds-layer-floating: var(--color-{{gray}}-900);
|
|
324
|
+
--jds-layer-active: var(--color-{{gray}}-800);
|
|
325
|
+
--jds-layer-overlay: color-mix(in oklab, var(--color-black) 50%, transparent);
|
|
326
|
+
|
|
327
|
+
--jds-primary: var(--color-{{primary}}-700);
|
|
328
|
+
--jds-primary-active: var(--color-{{primary}}-300);
|
|
329
|
+
--jds-primary-foreground: var(--color-{{gray}}-50);
|
|
330
|
+
|
|
331
|
+
--jds-secondary: var(--color-{{secondary}}-500);
|
|
332
|
+
--jds-secondary-active: var(--color-{{secondary}}-400);
|
|
333
|
+
--jds-secondary-foreground: var(--color-{{gray}}-50);
|
|
334
|
+
|
|
335
|
+
--jds-neutral: var(--color-{{gray}}-800);
|
|
336
|
+
--jds-neutral-active: var(--color-{{gray}}-700);
|
|
337
|
+
|
|
338
|
+
--jds-destructive: var(--color-red-400);
|
|
339
|
+
--jds-destructive-active: var(--color-red-300);
|
|
340
|
+
--jds-destructive-foreground: var(--color-{{gray}}-50);
|
|
341
|
+
|
|
342
|
+
--jds-stroke: var(--color-{{gray}}-50);
|
|
343
|
+
--jds-stroke-subtle: var(--color-{{gray}}-800);
|
|
344
|
+
--jds-stroke-interactive: var(--color-{{primary}}-500);
|
|
345
|
+
--jds-stroke-ring: var(--color-{{primary}}-400);
|
|
346
|
+
--jds-stroke-destructive: var(--color-red-400);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
@layer base {
|
|
350
|
+
body {
|
|
351
|
+
background: var(--jds-background);
|
|
352
|
+
color: var(--jds-foreground);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
`;var me=`
|
|
6
356
|
import {
|
|
7
357
|
definePreset,
|
|
8
358
|
defineSemanticTokens,
|
|
@@ -296,13 +646,19 @@ export const defaultPreset = definePreset({
|
|
|
296
646
|
utilities,
|
|
297
647
|
})
|
|
298
648
|
|
|
299
|
-
`;var
|
|
649
|
+
`;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$1.object({primary:z$1.enum(j),secondary:z$1.enum(j),gray:z$1.enum(I)}),ue=t=>ge.compile(me)(t),fe=t=>ge.compile(pe)(t);var W=z$1.object({cwd:z$1.string().default(()=>process.cwd()),yes:z$1.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")}),D=async t=>t.yes?W.parse(t):W.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 V=le.bold.red,ye=le.bold.blue,Je=["tailwindcss","clsx","tailwind-merge","tailwind-variants"],ve=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 D({cwd:v.resolve(t.cwd),yes:t.yes,style:t.style,primary:t.primary,secondary:t.secondary,gray:t.gray}),o=await G(r);if(e.stop("successfully Initialized!"),o?.style==="tailwind"){let a=await O(r.cwd,Je);a&&outro(ye(`Run this command in the terminal : ${a.command} ${a.args.join(" ")}`));}}catch(r){e.stop(V(ye("error occured"))),r instanceof z$1.ZodError&&console.log(r.message),r instanceof x&&console.log(V(r.format)),r instanceof Error&&console.log(V(r.message)),process.exit(1);}});async function G(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=ee(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 X(e)&&(await confirm({message:"you already initialize,are you want to overwrite it?"})||process.exit(0)),t.style==="panda"){let n=await oe(e),i=await T.readFile(v.join(e,n),"utf-8"),d="styled-system",{outdir:l,importMap:c}=await ne(i);c?d=c:d=re(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=ue({primary:t.primary,secondary:t.secondary,gray:t.gray});return await T.writeFile(v.join(e,"preset.ts"),y),ie(v.resolve(e,n)),p}if(t.style==="tailwind"){let n=te(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 i=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(i),"utf-8");let d=fe({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(i.utils,r),"cn.ts"),`import { type ClassValue, clsx } from "clsx"
|
|
650
|
+
import { twMerge } from "tailwind-merge"
|
|
651
|
+
|
|
652
|
+
export function cn(...inputs: ClassValue[]) {
|
|
653
|
+
return twMerge(clsx(inputs))
|
|
654
|
+
}
|
|
655
|
+
`),i}}var z=new Server({name:"DesignSystemCLI",version:"1.0.0"},{capabilities:{resources:{},tools:{},prompts:{}}});z.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"init",description:"Initialize the design system and generate theme files.",inputSchema:zodToJsonSchema(W)},{name:"previewColors",description:"Generate a preview of selected color combinations.",inputSchema:zodToJsonSchema(E)}]}));z.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 D({...t.params.arguments,yes:!0});return await G(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$1.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}}});z.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."}]}]}));z.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.
|
|
300
656
|
|
|
301
657
|
**The goal is to determine primary, secondary, and gray colors based on your preference.**
|
|
302
658
|
|
|
303
659
|
**Available color palettes:**
|
|
304
|
-
- primary,secondary colors: ${
|
|
305
|
-
- Gray shades (for gray selection): ${
|
|
660
|
+
- primary,secondary colors: ${j.join(", ")}
|
|
661
|
+
- Gray shades (for gray selection): ${I.join(", ")}
|
|
306
662
|
|
|
307
663
|
**Guidelines:**
|
|
308
664
|
1. **Guide the user to select the primary color only from the list above.**
|
|
@@ -322,7 +678,7 @@ export const defaultPreset = definePreset({
|
|
|
322
678
|
**Important notes:**
|
|
323
679
|
- Color values must only be used from the lists above.
|
|
324
680
|
- Colors not in the list (e.g., 'magenta', 'brown') cannot be used.
|
|
325
|
-
- 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
|
|
326
|
-
<your package manager's delete command> ${
|
|
327
|
-
<your package manager's install command> ${
|
|
328
|
-
`).forEach(log.step):outro("no transform occured");});var
|
|
681
|
+
- 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 be=new Command().name("mcp").description("Manage your design system").action(async()=>{try{let t=new StdioServerTransport;await z.connect(t);}catch(t){console.error(t);}});var we={"@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 ke(t){return `import {${t}} from "radix-ui"`}function je(t){let e=[];return t.getImportDeclarations().forEach(r=>{let o=r.getModuleSpecifierValue();if(!(o in we))return;let a=we[o];e.push(o);let n=r.getNamespaceImport();if(n){let d=n.getText();a!==d&&(a+=` as ${d}`),r.replaceWithText(ke(a));return}let i=r.getNamedImports();if(i.length){let d=a;i.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 _=g.getText();M(_,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(ke(d));}}),{source:t.getFullText(),packages:e}}var Ce=new Command().name("radix-ui-import").action(()=>{intro("find .tsx files...");let t=ze.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}=je(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
|
|
682
|
+
<your package manager's delete command> ${r}
|
|
683
|
+
<your package manager's install command> ${le.bgGreen("radix-ui")}`.split(`
|
|
684
|
+
`).forEach(log.step):outro("no transform occured");});var Ee={version:"4.0.0"};async function lt(){new Command().name("design-system").version(Ee.version).addCommand(ve).addCommand(de).addCommand(Ce).addCommand(be).parse();}lt();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jongh/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"dist",
|
|
15
15
|
"package.json"
|
|
16
16
|
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/jongh-design-system/jds.git",
|
|
20
|
+
"directory": "packages/cli"
|
|
21
|
+
},
|
|
17
22
|
"engines": {
|
|
18
23
|
"node": ">=18.0.0"
|
|
19
24
|
},
|
|
@@ -58,7 +63,7 @@
|
|
|
58
63
|
"build:registry": "npx tsx ./src/build-script.ts --all",
|
|
59
64
|
"release": "pnpm publish -no-git-checks",
|
|
60
65
|
"lint": "eslint --max-warnings 0 --no-warn-ignored --fix",
|
|
61
|
-
"check-type": "
|
|
66
|
+
"check-type": "tsgo --noEmit",
|
|
62
67
|
"test": "vitest run"
|
|
63
68
|
}
|
|
64
69
|
}
|