@jongh/cli 1.6.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +296 -93
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,125 +1,328 @@
1
1
  #!/usr/bin/env node
2
- import {Command}from'commander';import {intro,confirm,outro,spinner,select,log}from'@clack/prompts';import se from'chalk';import M from'fs-extra';import k from'path';import {z as z$1}from'zod';import we 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 Fe 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 V=o=>{let e={};for(let t of o)e[t]=t;return e},N=V(["config_not_found","resolve_path_fail","failed_to_fetch"]);V(["components.json","tsconfig.json","panda.config.*","package.json"]);var b=class extends Error{issue;constructor(e){super(),this.name="NewError",this.issue=e;}get format(){return this.issue.code+`
2
+ import {Command}from'commander';import {intro,confirm,outro,spinner,select,log}from'@clack/prompts';import ae from'chalk';import D from'fs-extra';import k from'path';import {z as z$1}from'zod';import Se 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 ze 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 V=t=>{let e={};for(let o of t)e[o]=o;return e},N=V(["config_not_found","resolve_path_fail","failed_to_fetch"]);V(["components.json","tsconfig.json","panda.config.*","package.json"]);var b=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=o=>{let e;switch(o.code){case N.config_not_found:e=`error occured while config ${o.configFile}`;break;case N.resolve_path_fail:e=`failed to resolve your path, current ${o.cwd}`;break;case N.failed_to_fetch:e=`failed to fetch ${o.target} [${o.statusCode}]`;break;default:e="error occured";}return new b({...o,message:[...o.message||"",e]})};var w={fileName:"components.json",schema:z$1.object({utils:z$1.string(),components:z$1.string(),hooks:z$1.string(),styledsystem:z$1.string()}).strict()},xe=["ui","hooks","utils"],be=z$1.object({name:z$1.string(),content:z$1.string(),type:z$1.enum(xe)}),G=z$1.object({name:z$1.string(),dependencies:z$1.array(z$1.string()).optional(),files:z$1.array(be).optional()});z$1.object({name:z$1.string(),dependencies:z$1.array(z$1.string()).optional(),file:z$1.string()});function Y(o){try{return M.readJsonSync(k.resolve(o,w.fileName))}catch(e){return u({code:"config_not_found",configFile:w.fileName,message:[e instanceof Error?e.message:""]})}}function $(o){let e=loadConfig(o);if(e.resultType==="failed")throw u({code:"config_not_found",configFile:"tsconfig.json",message:["cannot found tsconfig.json"]});return e}async function Z(o){return await M.pathExists(k.join(o,"components.json"))}function Q(o,e){let t=["./","./src/","./app/","./src/app"].map(r=>k.resolve(o,r));for(let[r,s]of Object.entries(e.paths)){let a=k.join(o,e.baseUrl||"",s[0].replace(/\/\*$/,""));if(t.some(l=>l===a||l.includes(a)))return r.replace(/\/\*$/,"")}return null}function X(o,e,t){let r=k.join(o,e);for(let[s,a]of Object.entries(t.paths)){let l=a[0].replace(/\/\*$/,"");if(r===k.join(o,t.baseUrl||"",l))return s.replace(/\/\*$/,"")}return null}async function F(o){try{let e=await we.glob(["panda.config.*"],{cwd:o,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 A(o,e){let t=createMatchPath(e.absoluteBaseUrl,e.paths)(o,void 0,()=>true);if(!t)throw u({code:"resolve_path_fail",target:o,cwd:process.cwd(),message:["resolve error"]});return t}async function D(o){let e=o.match(/outdir:\s*["']([^"']+)["']/),t=o.match(/importMap:\s*({[^}]+}|["'][^"']+["'])/),r=e?e[1]:null,s=null;if(t){let a=t[1];if(a.startsWith("{")){let l=a.match(/css:\s*["']([^"']+)["']/);s=l?l[1].replace(/\/css$/,""):null;}else s=a.replace(/["']/g,"");}return {outdir:r,importMap:s}}function ee(o,e){let t=o;return [{from:/@utils\//g,to:`${e.utils}/`},{from:/@hooks\//g,to:`${e.hooks}/`},{from:/@styled-system\//g,to:`${e.styledsystem}/`},{from:/@components\//g,to:`${e.components}/`}].forEach(({from:s,to:a})=>{t=t.replace(s,a);}),t}function oe(o){let t=new Project().addSourceFileAtPath(o),r=[{namedImports:[{name:"preset"}],moduleSpecifier:"panda-animation"},{namedImports:[{name:"defaultPreset"}],moduleSpecifier:"./preset"}];t.addImportDeclarations(r);let a=t.getFirstDescendantByKind(SyntaxKind.CallExpression)?.getArguments()[0];a?(a.getProperty("presets")||a.addPropertyAssignment({name:"presets",initializer:'[preset(), "@pandacss/preset-panda", defaultPreset]'}),t.saveSync()):console.warn("Could not modify panda.config.ts. add presets : [preset(), @pandacss/preset-panda, defaultPreset] in your panda.config");}async function te(o,e){let t=await detect({cwd:o}),r=resolveCommand(t?.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()}),$e="https://whdgur.shop",S=se.bold.red,O=se.bold.blue,ae=new Command().name("add").argument("[components...]").option("-c, --cwd <cwd>","current working directory, default to process.cwd()",process.cwd()).action(async(o,e)=>{try{let t=Pe.parse({components:o,...e});intro(O("install components..."));let r=w.schema.parse(Y(t.cwd)),s=$(t.cwd),a=await F(t.cwd),l=await M.readFile(k.resolve(t.cwd,a),"utf-8"),{outdir:g}=await D(l),y=w.schema.parse({utils:await A(r.utils,s),components:await A(r.components,s),hooks:await A(r.hooks,s),styledsystem:k.join(t.cwd,g||"styled-system")},{errorMap:()=>({message:"validation failed at components.json"})}),p=t.components?.map(d=>d.toLowerCase());if(!p?.length)return;let h=await Promise.allSettled(p.map(async d=>{let n=await fetch(`${$e}/${d}.json`);if(!n.ok)throw u({code:"failed_to_fetch",target:d,statusCode:n.status,message:[n.statusText]});return await n.json()}));for(let[d,n]of h.entries()){if(n.status==="rejected"){n.reason instanceof b?console.log(S(n.reason.format)):console.log(S(n.reason));continue}try{let i=G.parse(n.value,{errorMap:()=>({message:`registry for ${p[d]} is invaliad`})}),f=k.join(y.components,p[d]);if(M.pathExistsSync(f)&&!await confirm({message:`Component ${p[d]} already exists. Do you want to overwrite it?`}))return;i.files?.forEach(x=>{let H=ee(x.content,r);x.type==="ui"?M.outputFileSync(k.join(f,x.name),H):M.outputFileSync(k.join(y[x.type],x.name),H,"utf-8");});let m=await te(t.cwd,i.dependencies||[]),P=m?`Run this command in the terminal : ${m.command} ${m.args.join(" ")}`:`Cannot find your package manager, install this dependencies: ${i.dependencies?.join(" ")}`;outro(O(`${p[d]} completed successfully
5
- ${P}`));}catch(i){i instanceof Error&&console.log(S(i.message));}}}catch(t){outro(S(O("error occured"))),t instanceof z$1.ZodError&&console.log(t.message),t instanceof b&&console.log(S(t.format)),t instanceof Error&&console.log(S(t.message)),process.exit(1);}});var ne=`
6
- import { defineSemanticTokens, definePreset } from "@pandacss/dev"
4
+ `)}},u=t=>{let e;switch(t.code){case N.config_not_found:e=`error occured while config ${t.configFile}`;break;case N.resolve_path_fail:e=`failed to resolve your path, current ${t.cwd}`;break;case N.failed_to_fetch:e=`failed to fetch ${t.target} [${t.statusCode}]`;break;default:e="error occured";}return new b({...t,message:[...t.message||"",e]})};var v={fileName:"components.json",schema:z$1.object({utils:z$1.string(),components:z$1.string(),hooks:z$1.string(),styledsystem:z$1.string()}).strict()},be=["ui","hooks","utils"],ve=z$1.object({name:z$1.string(),content:z$1.string(),type:z$1.enum(be)}),q=z$1.object({name:z$1.string(),dependencies:z$1.array(z$1.string()).optional(),files:z$1.array(ve).optional()});z$1.object({name:z$1.string(),dependencies:z$1.array(z$1.string()).optional(),file:z$1.string()});function Y(t){try{return D.readJsonSync(k.resolve(t,v.fileName))}catch(e){return u({code:"config_not_found",configFile:v.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 Q(t){return await D.pathExists(k.join(t,"components.json"))}function X(t,e){let o=["./","./src/","./app/","./src/app"].map(r=>k.resolve(t,r));for(let[r,s]of Object.entries(e.paths)){let a=k.join(t,e.baseUrl||"",s[0].replace(/\/\*$/,""));if(o.some(l=>l===a||l.includes(a)))return r.replace(/\/\*$/,"")}return null}function ee(t,e,o){let r=k.join(t,e);for(let[s,a]of Object.entries(o.paths)){let l=a[0].replace(/\/\*$/,"");if(r===k.join(t,o.baseUrl||"",l))return s.replace(/\/\*$/,"")}return null}async function z(t){try{let e=await Se.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 A(t,e){let o=createMatchPath(e.absoluteBaseUrl,e.paths)(t,void 0,()=>true);if(!o)throw u({code:"resolve_path_fail",target:t,cwd:process.cwd(),message:["resolve error"]});return o}async function W(t){let e=t.match(/outdir:\s*["']([^"']+)["']/),o=t.match(/importMap:\s*({[^}]+}|["'][^"']+["'])/),r=e?e[1]:null,s=null;if(o){let a=o[1];if(a.startsWith("{")){let l=a.match(/css:\s*["']([^"']+)["']/);s=l?l[1].replace(/\/css$/,""):null;}else s=a.replace(/["']/g,"");}return {outdir:r,importMap:s}}function te(t,e){let o=t;return [{from:/@utils\//g,to:`${e.utils}/`},{from:/@hooks\//g,to:`${e.hooks}/`},{from:/@styled-system\//g,to:`${e.styledsystem}/`},{from:/@components\//g,to:`${e.components}/`}].forEach(({from:s,to:a})=>{o=o.replace(s,a);}),o}function oe(t){let o=new Project().addSourceFileAtPath(t),r=[{namedImports:[{name:"preset"}],moduleSpecifier:"panda-animation"},{namedImports:[{name:"defaultPreset"}],moduleSpecifier:"./preset"}];o.addImportDeclarations(r);let a=o.getFirstDescendantByKind(SyntaxKind.CallExpression)?.getArguments()[0];a?(a.getProperty("presets")||a.addPropertyAssignment({name:"presets",initializer:'[preset(), "@pandacss/preset-panda", defaultPreset]'}),o.saveSync()):console.warn("Could not modify panda.config.ts. add presets : [preset(), @pandacss/preset-panda, defaultPreset] in your panda.config");}async function re(t,e){let o=await detect({cwd:t}),r=resolveCommand(o?.agent||"npm","add",e);if(r)return r}var $e=z$1.object({components:z$1.array(z$1.string()).optional(),cwd:z$1.string()}),Fe="https://jds-docs.vercel.app",C=ae.bold.red,O=ae.bold.blue,ne=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=$e.parse({components:t,...e});intro(O("install components..."));let r=v.schema.parse(Y(o.cwd)),s=F(o.cwd),a=await z(o.cwd),l=await D.readFile(k.resolve(o.cwd,a),"utf-8"),{outdir:f}=await W(l),h=v.schema.parse({utils:await A(r.utils,s),components:await A(r.components,s),hooks:await A(r.hooks,s),styledsystem:k.join(o.cwd,f||"styled-system")},{errorMap:()=>({message:"validation failed at components.json"})}),p=o.components?.map(m=>m.toLowerCase());if(!p?.length)return;let y=await Promise.allSettled(p.map(async m=>{let n=await fetch(`${Fe}/${m}.json`);if(!n.ok)throw u({code:"failed_to_fetch",target:m,statusCode:n.status,message:[n.statusText]});return await n.json()}));for(let[m,n]of y.entries()){if(n.status==="rejected"){n.reason instanceof b?console.log(C(n.reason.format)):console.log(C(n.reason));continue}try{let i=q.parse(n.value,{errorMap:()=>({message:`registry for ${p[m]} is invaliad`})}),g=k.join(h.components,p[m]);if(D.pathExistsSync(g)&&!await confirm({message:`Component ${p[m]} already exists. Do you want to overwrite it?`}))return;i.files?.forEach(x=>{let K=te(x.content,r);x.type==="ui"?D.outputFileSync(k.join(g,x.name),K):D.outputFileSync(k.join(h[x.type],x.name),K,"utf-8");});let d=await re(o.cwd,i.dependencies||[]),$=d?`Run this command in the terminal : ${d.command} ${d.args.join(" ")}`:`Cannot find your package manager, install this dependencies: ${i.dependencies?.join(" ")}`;outro(O(`${p[m]} completed successfully
5
+ ${$}`));}catch(i){i instanceof Error&&console.log(C(i.message));}}}catch(o){outro(C(O("error occured"))),o instanceof z$1.ZodError&&console.log(o.message),o instanceof b&&console.log(C(o.format)),o instanceof Error&&console.log(C(o.message)),process.exit(1);}});var ie=`
6
+ import {
7
+ definePreset,
8
+ defineSemanticTokens,
9
+ defineTextStyles,
10
+ defineTokens,
11
+ } from "@pandacss/dev"
7
12
 
8
- const colors = defineSemanticTokens.colors({
9
- "background": {
10
- "value": { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
11
- },
12
- "foreground": {
13
- "value": { "base": "{colors.{{gray}}.950}", "_dark": "{colors.{{gray}}.50}" }
14
- },
15
- "card": {
16
- "DEFAULT": {
17
- "value": { "base": "{colors.white}", "_dark": "{colors.{{gray}}.900}" }
18
- },
19
- "foreground": {
20
- "value": { "base": "{colors.{{gray}}.950}", "_dark": "{colors.{{gray}}.50}" }
21
- }
22
- },
23
- "popover": {
24
- "DEFAULT": {
25
- "value": { "base": "{colors.white}", "_dark": "{colors.{{gray}}.900}" }
13
+ const radii = defineTokens.radii({
14
+ radius: { value: "0.5rem" },
15
+ })
16
+
17
+ export const semanticColors = defineSemanticTokens.colors({
18
+ background: {
19
+ value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
26
20
  },
27
- "foreground": {
28
- "value": { "base": "{colors.{{gray}}.950}", "_dark": "{colors.{{gray}}.50}" }
29
- }
30
- },
31
- "primary": {
32
- "DEFAULT": {
33
- "value": { "base": "{colors.{{primary}}.600}", "_dark": "{colors.{{primary}}.400}" }
21
+ foreground: {
22
+ value: { "base": "{colors.{{gray}}.950}", "_dark": "{colors.{{gray}}.50}" }
34
23
  },
35
- "foreground": {
36
- "value": { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
37
- }
38
- },
39
- "secondary": {
40
- "DEFAULT": {
41
- "value": { "base": "{colors.{{secondary}}.600}", "_dark": "{colors.{{secondary}}.400}" }
24
+ primary: {
25
+ DEFAULT: {
26
+ value: { "base": "{colors.{{primary}}.600}", "_dark": "{colors.{{primary}}.700}" }
27
+ },
28
+ foreground: {
29
+ value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
30
+ },
31
+ active: {
32
+ value: { "base": "{colors.{{primary}}.700}", "_dark": "{colors.{{primary}}.300}" }
33
+ }
42
34
  },
43
- "foreground": {
44
- "value": { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
45
- }
46
- },
47
- "muted": {
48
- "DEFAULT": {
49
- "value": { "base": "{colors.{{gray}}.100}", "_dark": "{colors.{{gray}}.800}" }
35
+ secondary: {
36
+ DEFAULT: {
37
+ value: { "base": "{colors.{{secondary}}.600}", "_dark": "{colors.{{secondary}}.400}" }
38
+ },
39
+ foreground: {
40
+ value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
41
+ },
42
+ active: {
43
+ value: { "base": "{colors.{{secondary}}.700}", "_dark": "{colors.{{secondary}}.300}" }
44
+ }
50
45
  },
51
- "foreground": {
52
- "value": { "base": "{colors.{{gray}}.500}", "_dark": "{colors.{{gray}}.400}" }
53
- }
54
- },
55
- "accent": {
56
- "DEFAULT": {
57
- "value": { "base": "{colors.{{secondary}}.100}", "_dark": "{colors.{{secondary}}.800}" }
46
+ neutral: {
47
+ DEFAULT: {
48
+ value: { "base": "{colors.{{gray}}.100}", "_dark": "{colors.{{gray}}.800}" }
49
+ },
50
+ foreground: {
51
+ value: { "base": "{colors.{{gray}}.500}", "_dark": "{colors.{{gray}}.400}" }
52
+ },
53
+ active: {
54
+ value: { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.700}" }
55
+ }
58
56
  },
59
- "foreground": {
60
- "value": { "base": "{colors.{{secondary}}.900}", "_dark": "{colors.{{secondary}}.50}" }
61
- }
62
- },
63
- "destructive": {
64
- "DEFAULT": {
65
- "value": { "base": "{colors.red.500}", "_dark": "{colors.red.400}" }
57
+ accent: {
58
+ DEFAULT: {
59
+ value: { "base": "{colors.{{secondary}}.100}", "_dark": "{colors.{{secondary}}.800}" }
60
+ },
61
+ foreground: {
62
+ value: { "base": "{colors.{{secondary}}.900}", "_dark": "{colors.{{secondary}}.50}" }
63
+ },
64
+ active: {
65
+ value: { "base": "{colors.{{secondary}}.200}", "_dark": "{colors.{{secondary}}.700}" }
66
+ }
66
67
  },
67
- "foreground": {
68
- "value": { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
68
+ destructive: {
69
+ DEFAULT: {
70
+ value: { "base": "{colors.red.600}", "_dark": "{colors.red.400}" }
71
+ },
72
+ foreground: {
73
+ value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
74
+ },
75
+ active: {
76
+ value: { "base": "{colors.red.700}", "_dark": "{colors.red.300}" }
77
+ }
78
+ },
79
+ layer: {
80
+ DEFAULT: {
81
+ value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
82
+ },
83
+ overlay: {
84
+ value: { "base": "{colors.black/50}", "_dark": "{colors.black/50}" }
85
+ },
86
+ floating: {
87
+ value: { "base": "{colors.white}", "_dark": "{colors.{{gray}}.950}" }
88
+ },
89
+ active: {
90
+ value: { "base": "{colors.{{gray}}.50}", "_dark": "{colors.{{gray}}.800}" }
91
+ },
92
+ foreground: {
93
+ DEFAULT: {
94
+ value: { "base": "{colors.{{gray}}.500}", "_dark": "{colors.{{gray}}.400}" }
95
+ },
96
+ muted: {
97
+ value: { "base": "{colors.{{gray}}.400}", "_dark": "{colors.{{gray}}.500}" }
98
+ },
99
+ emphasized: {
100
+ value: { "base": "{colors.{{gray}}.700}", "_dark": "{colors.{{gray}}.200}" }
101
+ },
102
+ primary: {
103
+ value: { "base": "{colors.{{primary}}.500}", "_dark": "{colors.{{primary}}.400}" }
104
+ }
105
+ }
106
+ },
107
+ stroke: {
108
+ DEFAULT: {
109
+ value: { "base": "{colors.{{primary}}.200}", "_dark": "{colors.{{primary}}.600}" }
110
+ },
111
+ border: {
112
+ value: { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.800}" }
113
+ },
114
+ input: {
115
+ value: { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.800}" }
116
+ },
117
+ ring: {
118
+ value: { "base": "{colors.{{primary}}.500}", "_dark": "{colors.{{primary}}.400}" }
119
+ },
120
+ destructive: {
121
+ value: { "base": "{colors.red.500}", "_dark": "{colors.red.400}" }
122
+ }
69
123
  }
70
- },
71
- "border": {
72
- "value": { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.800}" }
73
- },
74
- "input": {
75
- "value": { "base": "{colors.{{gray}}.200}", "_dark": "{colors.{{gray}}.800}" }
76
- },
77
- "ring": {
78
- "value": { "base": "{colors.{{primary}}.500}", "_dark": "{colors.{{primary}}.400}" }
79
- }})
80
-
124
+ })
125
+
81
126
  const borders = defineSemanticTokens.borders({
82
- base: { value: "1px solid {colors.border}" },
83
- input: { value: "1px solid {colors.input}" },
84
- primary: { value: "1px solid {colors.primary}" },
127
+ base: { value: "1px solid {colors.stroke.border}" },
128
+ input: { value: "1px solid {colors.stroke.input}" },
129
+ primary: { value: "1px solid {colors.stroke}" },
85
130
  destructive: { value: "1px solid {colors.destructive}" },
86
131
  })
87
132
 
133
+ export const textStyles = defineTextStyles({
134
+ display1: {
135
+ value: {
136
+ fontWeight: "{fontWeights.bold}",
137
+ fontSize: "4.5rem",
138
+ lineHeight: "{lineHeights.loose}",
139
+ letterSpacing: "{letterSpacings.tight}",
140
+ },
141
+ },
142
+ display2: {
143
+ value: {
144
+ fontWeight: "{fontWeights.bold}",
145
+ fontSize: "3.75rem",
146
+ lineHeight: "{lineHeights.relaxed}",
147
+ letterSpacing: "{letterSpacings.tight}",
148
+ },
149
+ },
150
+ title1: {
151
+ value: {
152
+ fontWeight: "semibold",
153
+ fontSize: "2.25rem",
154
+ lineHeight: "{lineHeights.normal}",
155
+ letterSpacing: "{letterSpacings.tight}",
156
+ },
157
+ },
158
+ title2: {
159
+ value: {
160
+ fontWeight: "semibold",
161
+ fontSize: "1.5rem",
162
+ lineHeight: "{lineHeights.snug}",
163
+ letterSpacing: "{letterSpacings.tight}",
164
+ },
165
+ },
166
+ title3: {
167
+ value: {
168
+ fontWeight: "{fontWeights.bold}",
169
+ fontSize: "1.25rem",
170
+ lineHeight: "{lineHeights.snug}",
171
+ letterSpacing: "{letterSpacings.tight}",
172
+ },
173
+ },
174
+ heading1: {
175
+ value: {
176
+ fontWeight: "{fontWeights.semibold}",
177
+ fontSize: "1.125rem",
178
+ lineHeight: "{lineHeights.normal}",
179
+ letterSpacing: "{letterSpacings.normal}",
180
+ },
181
+ },
182
+ heading2: {
183
+ value: {
184
+ fontWeight: "{fontWeights.semibold}",
185
+ fontSize: "1rem",
186
+ lineHeight: "{lineHeights.normal}",
187
+ letterSpacing: "{letterSpacings.normal}",
188
+ },
189
+ },
190
+ body1: {
191
+ value: {
192
+ fontWeight: "{fontWeights.normal}",
193
+ fontSize: "1rem",
194
+ lineHeight: "{lineHeights.relaxed}",
195
+ letterSpacing: "{letterSpacings.normal}",
196
+ },
197
+ },
198
+ body2: {
199
+ value: {
200
+ fontWeight: "{fontWeights.normal}",
201
+ fontSize: "0.875rem",
202
+ lineHeight: "{lineHeights.normal}",
203
+ letterSpacing: "{letterSpacings.normal}",
204
+ },
205
+ },
206
+ label1: {
207
+ value: {
208
+ fontWeight: "{fontWeights.semibold}",
209
+ fontSize: "0.875rem",
210
+ lineHeight: "{lineHeights.snug}",
211
+ letterSpacing: "{letterSpacings.wide}",
212
+ },
213
+ },
214
+ label2: {
215
+ value: {
216
+ fontWeight: "{fontWeights.semibold}",
217
+ fontSize: "0.75rem",
218
+ lineHeight: "{lineHeights.snug}",
219
+ letterSpacing: "{letterSpacings.wide}",
220
+ },
221
+ },
222
+ caption1: {
223
+ value: {
224
+ fontWeight: "{fontWeights.semibold}",
225
+ fontSize: "0.75rem",
226
+ lineHeight: "{lineHeights.tight}",
227
+ letterSpacing: "{letterSpacings.wide}",
228
+ },
229
+ },
230
+ caption2: {
231
+ value: {
232
+ fontWeight: "{fontWeights.semibold}",
233
+ fontSize: "0.625rem",
234
+ lineHeight: "{lineHeights.tight}",
235
+ letterSpacing: "{letterSpacings.wide}",
236
+ },
237
+ },
238
+ })
239
+
240
+ export const utilities = {
241
+ extend: {
242
+ fluidFontSize: {
243
+ shorthand: "fluidFontSize",
244
+ values: "fontSizes",
245
+ transform(value) {
246
+ if (!value.endsWith("rem")) {
247
+ return value
248
+ }
249
+ try {
250
+ const min = parseFloat(value) * 16
251
+ const max = min + 0.5 * 16
252
+
253
+ const [minRange, maxRange] = [360, 640]
254
+ const slopePxPerVw = (100 * (max - min)) / (maxRange - minRange)
255
+ const intercept = (min - slopePxPerVw * (minRange / 100)) / 16
256
+ const calcPart = \`calc(\${intercept.toFixed(4)}rem + \${slopePxPerVw.toFixed(4)}vw)\`
257
+
258
+ return {
259
+ fontSize: \`clamp(\${value}, \${calcPart}, \${max / 16}rem)\`,
260
+ }
261
+ } catch (error) {
262
+ console.error(
263
+ "[fluidFontSize] Error transforming value:",
264
+ error,
265
+ value,
266
+ )
267
+ return {
268
+ fontSize: value
269
+ }
270
+ }
271
+ },
272
+ },
273
+ },
274
+ }
275
+
88
276
  export const defaultPreset = definePreset({
89
277
  name: "default",
90
278
  globalCss: {
91
- html: {
92
- background: 'background',
93
- color: 'foreground'
279
+ body: {
280
+ background: "background",
281
+ color: "foreground",
94
282
  },
95
283
  },
96
284
  theme: {
97
285
  extend: {
286
+ textStyles,
287
+ tokens: {
288
+ radii,
289
+ },
98
290
  semanticTokens: {
99
- colors,
291
+ colors: semanticColors,
100
292
  borders,
101
-
102
293
  },
103
294
  },
104
295
  },
296
+ utilities,
105
297
  })
106
298
 
299
+ `;var S=["rose","pink","fuchsia","purple","violet","indigo","blue","sky","cyan","teal","emerald","green","lime","yellow","amber","orange","red","neutral","stone","zinc","gray","slate"],j=["neutral","stone","zinc","gray","slate"],I=z$1.object({primary:z$1.enum(S),secondary:z$1.enum(S),gray:z$1.enum(j)}),ce=t=>ze.compile(ie)(t);var M=z$1.object({cwd:z$1.string(),default:z$1.boolean().optional(),theme:I.optional()}),J=ae.bold.red,Re=ae.bold.blue,me=new Command().name("init").description("Initialize the project").option("-c, --cwd <cwd>","current working directory, default to process.cwd()",process.cwd()).option("-d, --default","use default color",false).action(async t=>{let e=spinner();e.start("Initializing");try{let o=M.parse({cwd:k.resolve(t.cwd),default:t.default,theme:t.theme});await G(o),e.stop("successfully Initialized!");}catch(o){e.stop(J(Re("error occured"))),o instanceof z$1.ZodError&&console.log(o.message),o instanceof b&&console.log(J(o.format)),o instanceof Error&&console.log(J(o.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 o=F(e);await Q(e)&&(await confirm({message:"you already initialize,are you want to overwrite it?"})||process.exit(0));let s=await z(e),a=await D.readFile(k.join(e,s),"utf-8"),l=X(e,o);if(l===null)throw u({code:"resolve_path_fail",target:"tsconfig.json",cwd:e,message:[`cannot find paths alias in your ${k.join(e,"tsconfig.json")}`]});let f="styled-system",{outdir:h,importMap:p}=await W(a);p?f=p:f=ee(e,h||"styled-system",o)||".",h&&(f=h);let y=v.schema.parse({utils:`${l}/utils`,components:`${l}/components`,hooks:`${l}/hooks`,styledsystem:f},{errorMap:()=>({message:"components.json is invalid"})});D.writeFile(k.resolve(e,"components.json"),JSON.stringify(y),"utf-8");let m=t.theme?.primary||"neutral",n=t.theme?.secondary||"slate",i=t.theme?.gray||"gray";t.default||(m=await select({message:"Pick primary color",initialValue:m,options:S.map(d=>({value:d,label:d}))}),n=await select({message:"Pick secondary color",initialValue:n,options:S.map(d=>({value:d,label:d}))}),i=await select({message:"Pick gray color",initialValue:i,options:j.map(d=>({value:d,label:d}))}));let g=ce(I.parse({primary:m,secondary:n,gray:i}));return D.writeFile(k.join(e,"preset.ts"),g),oe(k.resolve(e,s)),y}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(M)},{name:"previewColors",description:"Generate a preview of selected color combinations.",inputSchema:zodToJsonSchema(I)}]}));_.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{cwd:e,theme:o}=t.params.arguments,r=M.parse({cwd:e,default:!0,theme:o});return await G(r),{content:[{type:"text",text:`Design system initialized for directory: ${r.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}}});_.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.
300
+
301
+ **The goal is to determine primary, secondary, and gray colors based on your preference.**
107
302
 
108
- `;var _=["rose","pink","fuchsia","purple","violet","indigo","blue","sky","cyan","teal","emerald","green","lime","yellow","amber","orange","red","neutral","stone","zinc","gray","slate"],U=["neutral","stone","zinc","gray","slate"],ie=z$1.object({primary:z$1.enum(_),secondary:z$1.enum(_),gray:z$1.enum(U)}),ce=o=>Fe.compile(ne)(o);var ze=z$1.object({primaryColor:z$1.string().optional(),secondaryColor:z$1.string().optional(),grayColor:z$1.string().optional()}),z=z$1.object({cwd:z$1.string(),default:z$1.boolean().optional(),theme:ze.optional()}),W=se.bold.red,Re=se.bold.blue,de=new Command().name("init").description("Initialize the project").option("-c, --cwd <cwd>","current working directory, default to process.cwd()",process.cwd()).option("-d, --default","use default color",false).action(async o=>{let e=spinner();e.start("Initializing");try{let t=z.parse({cwd:k.resolve(o.cwd),default:o.default});await K(t),e.stop("successfully Initialized!");}catch(t){e.stop(W(Re("error occured"))),t instanceof z$1.ZodError&&console.log(t.message),t instanceof b&&console.log(W(t.format)),t instanceof Error&&console.log(W(t.message)),process.exit(1);}});async function K(o){let e=o.cwd||await packageDirectory();if(!e)throw u({code:"config_not_found",configFile:"package.json",message:[`cannot find package.json in ${e}`]});let t=$(e);await Z(e)&&(await confirm({message:"you already initialize,are you want to overwrite it?"})||process.exit(0));let s=await F(e),a=await M.readFile(k.join(e,s),"utf-8"),l=Q(e,t);if(l===null)throw u({code:"resolve_path_fail",target:"tsconfig.json",cwd:e,message:[`cannot find paths alias in your ${k.join(e,"tsconfig.json")}`]});let g="styled-system",{outdir:y,importMap:p}=await D(a);p?g=p:g=X(e,y||"styled-system",t)||".",y&&(g=y);let h=w.schema.parse({utils:`${l}/utils`,components:`${l}/components`,hooks:`${l}/hooks`,styledsystem:g},{errorMap:()=>({message:"components.json is invalid"})});M.writeFile(k.resolve(e,"components.json"),JSON.stringify(h),"utf-8");let d=o.theme?.primaryColor||"neutral",n=o.theme?.secondaryColor||"slate",i=o.theme?.grayColor||"gray";o.default||(d=await select({message:"Pick primary color",initialValue:"neutral",options:_.map(m=>({value:m,label:m}))}),n=await select({message:"Pick secondary color",initialValue:"slate",options:_.map(m=>({value:m,label:m}))}),i=await select({message:"Pick gray color",initialValue:"gray",options:U.map(m=>({value:m,label:m}))}));let f=ce(ie.parse({primary:d,secondary:n,gray:i}));return M.writeFile(k.join(e,"preset.ts"),f),oe(k.resolve(e,s)),h}var T=new Server({name:"DesignSystemCLI",version:"1.0.0"},{capabilities:{resources:{},tools:{},prompts:{}}});T.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"init",description:"Initialize the design system and generate theme files.",inputSchema:zodToJsonSchema(z)}]}));T.setRequestHandler(CallToolRequestSchema,async o=>{try{if(!o.params.arguments)throw new Error("Arguments are required for the init tool.");switch(o.params.name){case "init":try{let{cwd:e,...t}=o.params.arguments,r=z.parse({cwd:e,default:!0,theme:t});return await K(r),{content:[{type:"text",text:`Design system initialized for directory: ${r.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 ${o.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 ${o.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}}});T.setRequestHandler(ListPromptsRequestSchema,async()=>({prompts:[{name:"selectThemeColors",description:"Theme color selection guide for AI",arguments:[{name:"primaryColor",description:"The primary color using design system"},{name:"secondaryColor",description:"The secondary color using design system."},{name:"grayColor",description:"The gray color using design system."}]}]}));T.setRequestHandler(GetPromptRequestSchema,async o=>o.params.name!=="selectThemeColors"?{jsonrpc:"2.0",error:{code:-32601,message:`Prompt ${o.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:`You are an AI assistant helping the user configure their design system theme colors.
303
+ **Available color palettes:**
304
+ - primary,secondary colors: ${S.join(", ")}
305
+ - Gray shades (for gray selection): ${j.join(", ")}
109
306
 
110
- **Your goal is to determine the primary, secondary, and gray colors based on user preference.**
307
+ **Guidelines:**
308
+ 1. **Guide the user to select the primary color only from the list above.**
309
+ 2. **If the user requests a color not on the list, suggest the closest available color and guide them to choose from the list.**
310
+ 3. **Secondary and gray colors must also be selected only from the list above.**
311
+ 4. **Recommend secondary and gray colors that complement the primary color according to color theory and harmony principles.**
312
+ - 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.
313
+ - Secondary is a supporting color, used throughout components that play a secondary role in the UI.
314
+ - Gray is used for text, backgrounds, borders, etc., serving to convey information and indicate hierarchy.
315
+ - The color contrast ratio must be checked to ensure it meets the WCAG (Web Content Accessibility Guidelines) AA level
316
+ 5. **Strictly avoid color overlap.** Primary, secondary, and gray colors must be different from each other.
317
+ 6. **Confirm the finalized color combination with the user.**
318
+ 7. **Explain to the user the reason for the color selection.**
319
+ 8. **Execute the 'init' tool with the final colors. Use only values exactly as they appear in the color list above.**
111
320
 
112
- **Follow these steps:**
113
- 1. **Start by asking the user** (e.g., "What is your preferred color for the primary theme color?").
114
- 2. **Based on the user's preferred color, determine the secondary and gray colors.** You should use color theory and harmony principles to select colors that complement the primary color.
115
- 3. **When selecting secondary and gray colors, prioritize color harmony and contrast.**
116
- 4. **Ensure all selected colors comply with WCAG (Web Content Accessibility Guidelines) Contrast Ratio of at least 4.5** against standard background and foreground text colors where applicable.
117
- 5. **Strictly avoid color overlap.** The primary, secondary, and gray colors must be distinct from each other (e.g., the chosen primary color should not be the same as the chosen secondary or gray, secondary should not be the same as gray, etc.).
118
- 6. Once you have determined a suitable primary, secondary, and gray color (either directly provided by the user or chosen based on their preference and the criteria above), **confirm the selected colors with the user** if necessary.
119
- 7. Inform the user of the reason for the selection of the colors.
120
- 8. Finally, with the determined primary, secondary, and gray color values, **execute the 'init' tool** provided by the DesignSystemCLI server, passing the colors as arguments.
121
321
 
122
- **Tool to use after color determination:** 'DesignSystemCLI init'`}},{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:"Okay, I can help you with that. Let's start by selecting the theme colors. To begin, what is your preferred color for the primary theme color?"}}]});var me=new Command().name("mcp").description("Manage your design system").action(async()=>{try{let o=new StdioServerTransport;await T.connect(o);}catch(o){console.error(o);}});var pe={"@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 R(o,e,t){return t?o===t:o===e}function fe(o){return `import {${o}} from "radix-ui"`}function ge(o){let e=[];return o.getImportDeclarations().forEach(t=>{let r=t.getModuleSpecifierValue();if(!(r in pe))return;let s=pe[r];e.push(r);let a=t.getNamespaceImport();if(a){let g=a.getText();s!==g&&(s+=` as ${g}`),t.replaceWithText(fe(s));return}let l=t.getNamedImports();if(l.length){let g=s;l.forEach(y=>{let p=y.getName(),h=y.getAliasNode()?.getText(),d=`${g}.${p}`;for(let n of [SyntaxKind.JsxOpeningElement,SyntaxKind.JsxClosingElement,SyntaxKind.JsxSelfClosingElement])o.getDescendantsOfKind(n).forEach(i=>{let f=i.getTagNameNode().getText();R(f,p,h)&&i.getTagNameNode().replaceWithText(d);});o.getDescendantsOfKind(SyntaxKind.TypeQuery).forEach(n=>{n.getChildren().forEach(i=>{let f=i.getText();R(f,p,h)&&i.replaceWithText(d);});}),o.getDescendantsOfKind(SyntaxKind.ExpressionStatement).forEach(n=>{n.getChildrenOfKind(SyntaxKind.BinaryExpression).forEach(f=>{f.getRight().getChildren().forEach(P=>{let x=P.getText();R(x,p,h)&&P.replaceWithText(d);});});}),o.getDescendantsOfKind(SyntaxKind.VariableDeclaration).forEach(n=>{let i=n.getInitializer();i&&i.getChildren().forEach(f=>{let m=f.getText();R(m,p,h)&&f.replaceWithText(d);});});}),t.replaceWithText(fe(g));}}),{source:o.getFullText(),packages:e}}var ye=new Command().name("radix-ui-import").action(()=>{intro("find .tsx files...");let o=we.sync("**/*.tsx",{ignore:["**/node_modules/**"],dot:false}),e=new Project,t="";o.forEach(r=>{let s=e.addSourceFileAtPathIfExists(k.join(process.cwd(),r));if(s)try{let{packages:a}=ge(s);t+=a.join(" "),s.save();}catch(a){log.error(`failed to transform ${r} ${a}`);}}),t.length?`copy this to delete and install new package
123
- <your package manager's delete command> ${t}
124
- <your package manager's install command> ${se.bgGreen("radix-ui")}`.split(`
125
- `).forEach(log.step):outro("no transform occured");});var he={version:"1.6.02"};async function ro(){new Command().name("design-system").version(he.version).addCommand(de).addCommand(ae).addCommand(ye).addCommand(me).parse();}ro();
322
+ **Important notes:**
323
+ - Color values must only be used from the lists above.
324
+ - 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 pe=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 ge={"@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 L(t,e,o){return o?t===o:t===e}function fe(t){return `import {${t}} from "radix-ui"`}function ue(t){let e=[];return t.getImportDeclarations().forEach(o=>{let r=o.getModuleSpecifierValue();if(!(r in ge))return;let s=ge[r];e.push(r);let a=o.getNamespaceImport();if(a){let f=a.getText();s!==f&&(s+=` as ${f}`),o.replaceWithText(fe(s));return}let l=o.getNamedImports();if(l.length){let f=s;l.forEach(h=>{let p=h.getName(),y=h.getAliasNode()?.getText(),m=`${f}.${p}`;for(let n of [SyntaxKind.JsxOpeningElement,SyntaxKind.JsxClosingElement,SyntaxKind.JsxSelfClosingElement])t.getDescendantsOfKind(n).forEach(i=>{let g=i.getTagNameNode().getText();L(g,p,y)&&i.getTagNameNode().replaceWithText(m);});t.getDescendantsOfKind(SyntaxKind.TypeQuery).forEach(n=>{n.getChildren().forEach(i=>{let g=i.getText();L(g,p,y)&&i.replaceWithText(m);});}),t.getDescendantsOfKind(SyntaxKind.ExpressionStatement).forEach(n=>{n.getChildrenOfKind(SyntaxKind.BinaryExpression).forEach(g=>{g.getRight().getChildren().forEach($=>{let x=$.getText();L(x,p,y)&&$.replaceWithText(m);});});}),t.getDescendantsOfKind(SyntaxKind.VariableDeclaration).forEach(n=>{let i=n.getInitializer();i&&i.getChildren().forEach(g=>{let d=g.getText();L(d,p,y)&&g.replaceWithText(m);});});}),o.replaceWithText(fe(f));}}),{source:t.getFullText(),packages:e}}var ye=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 s=e.addSourceFileAtPathIfExists(k.join(process.cwd(),r));if(s)try{let{packages:a}=ue(s);o+=a.join(" "),s.save();}catch(a){log.error(`failed to transform ${r} ${a}`);}}),o.length?`copy this to delete and install new package
326
+ <your package manager's delete command> ${o}
327
+ <your package manager's install command> ${ae.bgGreen("radix-ui")}`.split(`
328
+ `).forEach(log.step):outro("no transform occured");});var xe={version:"2.1.0"};async function ot(){new Command().name("design-system").version(xe.version).addCommand(me).addCommand(ne).addCommand(ye).addCommand(pe).parse();}ot();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jongh/cli",
3
- "version": "1.6.02",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "bin": "./dist/index.js",
6
6
  "type": "module",