@seed-design/cli 0.0.0-alpha-20241113031935 → 0.0.0-alpha-20250210081704
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 +3 -3
- package/bin/index.mjs +2 -2
- package/package.json +8 -9
- package/src/commands/add.ts +93 -73
- package/src/commands/init.ts +67 -46
- package/src/constants.ts +2 -0
- package/src/index.ts +1 -3
- package/src/schema.ts +13 -16
- package/src/test/add-relative-registries.test.ts +182 -0
- package/src/utils/add-relative-registries.ts +43 -0
- package/src/utils/color.ts +3 -0
- package/src/utils/get-config.ts +34 -15
- package/src/utils/get-metadata.ts +61 -19
- package/src/utils/get-package-info.ts +2 -1
- package/src/utils/get-package-manager.ts +2 -2
- package/src/utils/install.ts +53 -0
- package/src/commands/check-deprecated-icon-files.ts +0 -256
- package/src/test/add-relative-components.test.ts +0 -62
- package/src/utils/add-relative-components.ts +0 -29
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
### How to test
|
|
4
4
|
|
|
5
|
-
- Run `
|
|
6
|
-
- Run `
|
|
7
|
-
- You can test `
|
|
5
|
+
- Run `bun dev` in `@seed-design/component-docs` (snippet download)
|
|
6
|
+
- Run `bun dev` here (watch mode)
|
|
7
|
+
- You can test `bun seed-design <command>` in `@seed-design/example/cli` terminal
|
package/bin/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{cosmiconfig as oe}from"cosmiconfig";import k from"path";import*as M from"@clack/prompts";import{z as d}from"zod";import ne from"picocolors";var j="seed-design",te=oe(j,{searchPlaces:[`${j}.json`]}),$=d.object({$schema:d.string().optional(),rsc:d.coerce.boolean().default(!1),tsx:d.coerce.boolean().default(!0),css:d.coerce.boolean().default(!0),path:d.string()}).strict(),re=$.extend({resolvedUIPaths:d.string(),resolbedHookPaths:d.string(),resolvedUtilPaths:d.string()});async function T(e){let n=await ce(e);return n?await ie(e,n):null}async function ie(e,n){let t=k.resolve(e,n.path);return re.parse({...n,resolvedUIPaths:k.join(t,"ui"),resolbedHookPaths:k.join(t,"hook"),resolvedUtilPaths:k.join(t,"util")})}async function ce(e){try{let n=await te.search(e);return n?$.parse(n.config):(M.log.message(ne.red(`${e} \uACBD\uB85C\uC5D0 seed-design.json \uD30C\uC77C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.`)),null)}catch(n){throw console.log(n),new Error(`${e} \uACBD\uB85C\uC5D0 seed-design.json \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.`)}}import{z as c}from"zod";var se=c.union([c.literal("ui"),c.literal("hook"),c.literal("util")]),A=c.object({name:c.string(),description:c.string().optional(),dependencies:c.array(c.string()).optional(),devDependencies:c.array(c.string()).optional(),innerDependencies:c.array(c.string()).optional(),files:c.array(c.string())}),G=c.array(A),ae=A.omit({files:!0}),pe=ae.extend({registries:c.array(c.object({name:c.string(),type:se,content:c.string()}))}),He=c.array(pe);var C="https://v3.seed-design.io";async function b(e){try{return await Promise.all(e.map(async t=>await(await fetch(`${C}/__registry__/ui/${t}.json`)).json()))}catch(n){throw console.log(n),new Error(`Failed to fetch registry from ${C}.`)}}async function O(){try{let[e]=await b(["index"]);return G.parse(e)}catch(e){throw console.log(e),new Error(`Failed to fetch components from ${C}.`)}}import{detect as le}from"@antfu/ni";async function z(e){let n=await le({programmatic:!0,cwd:e});return n==="yarn@berry"?"yarn":n==="pnpm@6"?"pnpm":n==="bun"?"bun":n??"npm"}import{promises as ue}from"fs";import{tmpdir as he}from"os";import N from"path";import{transformFromAstSync as me}from"@babel/core";import _e from"@babel/plugin-transform-typescript";import*as S from"recast";import{parse as de}from"@babel/parser";var fe={sourceType:"module",allowImportExportEverywhere:!0,allowReturnOutsideFunction:!0,startLine:1,tokens:!0,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},D=async({sourceFile:e,config:n})=>{let t=e.getFullText();if(n.tsx)return t;let i=S.parse(t,{parser:{parse:r=>de(r,fe)}}),o=me(i,t,{cloneInputAst:!1,code:!1,ast:!0,plugins:[_e],configFile:!1});if(!o||!o.ast)throw new Error("Failed to transform JSX");return S.print(o.ast).code};import{SyntaxKind as ge}from"ts-morph";var E=async({sourceFile:e,config:n})=>{if(n.rsc)return e;let t=e.getFirstChildByKind(ge.ExpressionStatement);return t?.getText()==='"use client";'&&t.remove(),e};var F=async({sourceFile:e,config:n})=>{if(n.css)return e;let i=e.getImportDeclarations().filter(o=>o.getModuleSpecifierValue().endsWith(".css"));for(let o of i)o.remove();return e};import{Project as ye,ScriptKind as we}from"ts-morph";var xe=[E,F],Ie=new ye({compilerOptions:{}});async function ke(e){let n=await ue.mkdtemp(N.join(he(),"seed-deisgn-"));return N.join(n,e)}async function J(e){let n=await ke(e.filename),t=Ie.createSourceFile(n,e.raw,{scriptKind:we.TSX});for(let i of xe)i({sourceFile:t,...e});return await D({sourceFile:t,...e})}import*as s from"@clack/prompts";import{execa as L}from"execa";import v from"fs-extra";import V from"path";import P from"picocolors";import{z as x}from"zod";function H(e,n){let t=new Set;function i(o){if(t.has(o))return;t.add(o);let r=n.find(l=>l.name===o);if(r&&r.innerDependencies)for(let l of r.innerDependencies)i(l)}for(let o of e)i(o);return Array.from(t)}var Se=x.object({components:x.array(x.string()).optional(),cwd:x.string(),all:x.boolean()}),B=e=>{e.command("add [...components]","add component").option("-a, --all","Add all components",{default:!1}).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",{default:process.cwd()}).example("seed-design add box-button").example("seed-design add alert-dialog").action(async(n,t)=>{let i=Se.parse({components:n,...t}),o=a=>P.cyan(a),r=i.cwd;v.existsSync(r)||(s.log.error(`The path ${r} does not exist. Please try again.`),process.exit(1));let l=await O(),g=i.all?l.map(a=>a.name):i.components;if(!i.components?.length&&!i.all){let a=await s.multiselect({message:"Select all components to add",options:l.map(f=>({label:f.name,value:f.name,hint:f.description}))});s.isCancel(a)&&(s.log.error("Aborted."),process.exit(0)),g=a}g?.length||(s.log.error("No components found."),process.exit(0));let w=H(g,l),I=w.filter(a=>!g.includes(a)),u=await T(r),Y=await b(w);s.log.message(`Selection: ${o(g.join(", "))}`),I.length&&s.log.message(`Inner Dependencies: ${o(I.join(", "))} will be also added.`);for(let a of Y){for(let m of a.registries){let _="";switch(m.type){case"ui":_=u.resolvedUIPaths;break;case"hook":_=u.resolbedHookPaths;break;case"util":_=u.resolvedUtilPaths;break;default:break}v.existsSync(_)||await v.mkdir(_,{recursive:!0});let h=V.resolve(_,m.name),Z=await J({filename:m.name,config:u,raw:m.content});u.tsx||(h=h.replace(/\.tsx$/,".jsx"),h=h.replace(/\.ts$/,".js")),await v.writeFile(h,Z);let ee=V.relative(r,h);s.log.info(`Added ${o(m.name)} to ${o(ee)}`)}let f=await z(r),{start:U,stop:R}=s.spinner();if(a.dependencies?.length){U(P.gray("Installing dependencies"));let m=await L(f,[f==="npm"?"install":"add",...a.dependencies],{cwd:r});if(m.failed)console.error(m.all),process.exit(1);else{for(let _ of a.dependencies)s.log.info(`- ${_}`);R("Dependencies installed.")}}if(a.devDependencies?.length){U(P.gray("Installing devDependencies"));let m=await L(f,[f==="npm"?"install":"add","-D",...a.devDependencies],{cwd:r});if(m.failed)console.error(m.all),process.exit(1);else{for(let _ of a.devDependencies)s.log.info(`- ${_}`);R("Dependencies installed.")}}}s.outro("Components added.")})};import ve from"findup-sync";import Ce from"fs-extra";var be="package.json";function Pe(){let e=ve(be);if(!e)throw new Error("No package.json file found in the project.");return e}function K(){return Ce.readJSONSync(Pe())}import{cac as Ae}from"cac";import*as p from"@clack/prompts";import Ue from"fs-extra";import W from"path";import Re from"picocolors";import{z as q}from"zod";var je=q.object({cwd:q.string()}),X=e=>{e.command("init","initialize seed-design.json").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",{default:process.cwd()}).action(async n=>{let t=je.parse({...n}),i=u=>Re.cyan(u),o=await p.group({tsx:()=>p.confirm({message:`Would you like to use ${i("TypeScript")} (recommended)?`,initialValue:!0}),rsc:()=>p.confirm({message:`Are you using ${i("React Server Components")}?`,initialValue:!1}),css:()=>p.confirm({message:`Would you like to use ${i("CSS Modules")}? (If true, CSS import will be added in components)`,initialValue:!0}),path:()=>p.text({message:`Enter the path to your ${i("seed-design directory")}`,initialValue:"./seed-design",defaultValue:"./seed-design",placeholder:"./seed-design"})},{onCancel:()=>{p.cancel("Operation cancelled."),process.exit(0)}}),r={rsc:o.rsc,tsx:o.tsx,css:o.css,path:o.path},{start:l,stop:g}=p.spinner();l("Writing seed-design.json...");let w=W.resolve(t.cwd,"seed-design.json");await Ue.writeFile(w,`${JSON.stringify(r,null,2)}
|
|
3
|
-
`,"utf-8");let
|
|
2
|
+
import*as S from"@clack/prompts";import{cosmiconfig as pe}from"cosmiconfig";import{execa as me}from"execa";import I from"fs";import D from"path";import{z as h}from"zod";import ae from"picocolors";var y=e=>ae.cyan(e);import{detect as ce}from"@antfu/ni";async function M(e){let t=await ce({programmatic:!0,cwd:e});return t==="yarn@berry"?"yarn":t==="pnpm@6"?"pnpm":t==="bun"?"bun":t==="deno"?"deno":t??"npm"}var F="seed-design",le=pe(F,{searchPlaces:[`${F}.json`]}),_=h.object({$schema:h.string().optional(),rsc:h.coerce.boolean().default(!1),tsx:h.coerce.boolean().default(!0),css:h.coerce.boolean().default(!0),path:h.string()}).strict(),fe=_.extend({resolvedUIPaths:h.string(),resolvedLibPaths:h.string()});async function J(e){let t=await de(e);return t?await ge(e,t):null}async function ge(e,t){let r=D.resolve(e,t.path);I.existsSync(r)||I.mkdirSync(r,{recursive:!0});let n=D.join(r,"ui"),o=D.join(r,"lib");return I.existsSync(n)||I.mkdirSync(n,{recursive:!0}),I.existsSync(o)||I.mkdirSync(o,{recursive:!0}),fe.parse({...t,resolvedUIPaths:n,resolvedLibPaths:o})}async function de(e){try{let t=await le.search(e);return _.parse(t.config)}catch{if(S.log.error("\uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8 \uACBD\uB85C\uC5D0 `seed-design.json` \uD30C\uC77C\uC774 \uC5C6\uC5B4\uC694."),await S.confirm({message:"seed-design.json \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uC2DC\uACA0\uC5B4\uC694?"})===!0){let r=await M(e);await me(r,["seed-design","init","--default"],{cwd:e}),S.log.message("seed-design.json \uD30C\uC77C\uC774 \uC0DD\uC131\uB410\uC5B4\uC694.")}else S.outro(y("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694.")),process.exit(1)}}import*as b from"@clack/prompts";import{z as p}from"zod";var ue=p.union([p.literal("ui"),p.literal("lib")]),N=p.object({name:p.string(),description:p.string().optional(),dependencies:p.array(p.string()).optional(),devDependencies:p.array(p.string()).optional(),innerDependencies:p.array(p.string()).optional(),files:p.array(p.string())}),U=p.array(N),ye=N.omit({files:!0}),he=ye.extend({registries:p.array(p.object({name:p.string(),type:ue,content:p.string()}))}),rt=p.array(he);async function L(e,t,r="ui"){return await Promise.all(e.map(async o=>{try{return await(await fetch(`${t}/__registry__/${r}/${o}.json`)).json()}catch(s){let c=await fetch(`${t}/__registry__/${r}/index.json`).then(g=>g.json()),m=U.parse(c).map(g=>g.name);b.log.error(`${r}:${o} \uCEF4\uD3EC\uB10C\uD2B8\uB294 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC544\uC694.`),b.log.info(`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uCEF4\uD3EC\uB10C\uD2B8: ${m.join(", ")}`),b.log.info(JSON.stringify({baseUrl:t,error:s.toString()},null,2)),process.exit(1)}}))}async function B(e,t,r="ui"){let[n]=await L([e],t,r);return n}async function V(e){try{let[t]=await L(["index"],e,"ui");return U.parse(t)}catch(t){b.log.error("\uB808\uC9C0\uC2A4\uD2B8\uB9AC \uC778\uB371\uC2A4\uB97C \uAC00\uC838\uC624\uB294 \uB370 \uC2E4\uD328\uD588\uC5B4\uC694."),b.log.info(JSON.stringify({baseUrl:e,error:t.toString()},null,2)),process.exit(1)}}async function K(e){let[t]=await L(["index"],e,"lib");return U.parse(t)}import{promises as Re}from"fs";import{tmpdir as Ce}from"os";import q from"path";import{transformFromAstSync as xe}from"@babel/core";import Se from"@babel/plugin-transform-typescript";import*as $ from"recast";import{parse as we}from"@babel/parser";var Ie={sourceType:"module",allowImportExportEverywhere:!0,allowReturnOutsideFunction:!0,startLine:1,tokens:!0,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},X=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let n=$.parse(r,{parser:{parse:s=>we(s,Ie)}}),o=xe(n,r,{cloneInputAst:!1,code:!1,ast:!0,plugins:[Se],configFile:!1});if(!o||!o.ast)throw new Error("Failed to transform JSX");return $.print(o.ast).code};import{SyntaxKind as be}from"ts-morph";var W=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(be.ExpressionStatement);return r?.getText()==='"use client";'&&r.remove(),e};var Y=async({sourceFile:e,config:t})=>{if(t.css)return e;let n=e.getImportDeclarations().filter(o=>o.getModuleSpecifierValue().endsWith(".css"));for(let o of n)o.remove();return e};import{Project as ve,ScriptKind as Pe}from"ts-morph";var je=[W,Y],ke=new ve({compilerOptions:{}});async function Me(e){let t=await Re.mkdtemp(q.join(Ce(),"seed-deisgn-"));return q.join(t,e)}async function H(e){let t=await Me(e.filename),r=ke.createSourceFile(t,e.raw,{scriptKind:Pe.TSX});for(let n of je)n({sourceFile:r,...e});return await X({sourceFile:r,...e})}import*as l from"@clack/prompts";import z from"fs-extra";import te from"path";import Le from"picocolors";import{z as R}from"zod";var Q="https://v3.seed-design.io";function Z({userSelects:e,uiRegistryIndex:t,libRegistryIndex:r}){let n=[];function o({registryName:s,type:c}){if(n.some(m=>m.name===s&&m.type===c))return;n.push({type:c,name:s});let d=c==="ui"?t.find(m=>m.name===s):r.find(m=>m.name===s);if(d&&d.innerDependencies)for(let m of d.innerDependencies){let[g,k]=m.split(":");o({registryName:k,type:g})}}for(let s of e)o({registryName:s,type:"ui"});return Array.from(n)}import*as ee from"@clack/prompts";import{execa as Ae}from"execa";import De from"picocolors";import Ue from"findup-sync";import $e from"fs-extra";var Te="package.json";function Oe(){let e=Ue(Te);if(!e)throw new Error("No package.json file found in the project.");return e}function T(){let e=Oe();return $e.readJSONSync(e)}async function G({cwd:e,deps:t,dev:r=!1}){let{start:n,stop:o}=ee.spinner(),s=await M(e),c=T(),d={...c.dependencies,...c.devDependencies},m=t.filter(x=>!d[x]),g=t.filter(x=>d[x]);if(!m.length)return{installed:new Set,filtered:new Set};n(De.gray("\uC758\uC874\uC131 \uC124\uCE58\uC911..."));let O=[s==="npm"?"install":"add",r?"-D":null,...m].filter(Boolean);try{await Ae(s,O,{cwd:e})}catch(x){console.error(`\uC758\uC874\uC131 \uC124\uCE58 \uC2E4\uD328: ${x}`),process.exit(1)}return o("\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC."),{installed:m,filtered:g}}var Ge=R.object({components:R.array(R.string()).optional(),cwd:R.string(),all:R.boolean(),baseUrl:R.string().optional()}),re=e=>{e.command("add [...components]","add component").option("-a, --all","Add all components",{default:!1}).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",{default:process.cwd()}).option("-u, --baseUrl <baseUrl>","the base url of the registry. defaults to the current directory.",{default:Q}).example("seed-design add box-button").example("seed-design add alert-dialog").action(async(t,r)=>{l.intro(Le.bgCyan("seed-design add"));let n=Ge.parse({components:t,...r}),o=n.cwd,s=n.baseUrl,c=await J(o),d=await V(s),m=await K(s),g=n.all?d.map(f=>f.name):n.components;if(!n.components?.length&&!n.all){let f=await l.multiselect({message:"\uCD94\uAC00\uD560 \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uC120\uD0DD\uD574\uC8FC\uC138\uC694 (\uC2A4\uD398\uC774\uC2A4 \uBC14\uB85C \uC5EC\uB7EC \uAC1C \uC120\uD0DD \uAC00\uB2A5)",options:d.map(i=>({label:i.name,value:i.name,hint:i.description}))});l.isCancel(f)&&(l.log.error("\uCDE8\uC18C\uB418\uC5C8\uC5B4\uC694."),process.exit(0)),g=f}g?.length||(l.log.error("\uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694."),process.exit(0)),l.log.message(`\uC120\uD0DD\uB41C \uCEF4\uD3EC\uB10C\uD2B8: ${y(g.join(", "))}`);let k=Z({userSelects:g,uiRegistryIndex:d,libRegistryIndex:m}),C=[],{start:O,stop:x}=l.spinner();O("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");for(let f of k){let i=await B(f.name,s,f.type);C.push(i)}if(x(),C.length){let f=C.filter(i=>!g.includes(i.name));l.log.message(`\uCD94\uAC00\uB85C \uC124\uCE58\uB420 \uB808\uC9C0\uC2A4\uD2B8\uB9AC: ${y(f.map(i=>i.name).join(", "))}`)}let A=[],u={installed:new Set,filtered:new Set};for(let f of C){for(let i of f.registries){let v="";switch(i.type){case"ui":v=c.resolvedUIPaths;break;case"lib":v=c.resolvedLibPaths;break;default:break}z.existsSync(v)||await z.mkdir(v,{recursive:!0});let w=te.resolve(v,i.name),se=await H({filename:i.name,config:c,raw:i.content});c.tsx||(w=w.replace(/\.tsx$/,".jsx"),w=w.replace(/\.ts$/,".js")),await z.writeFile(w,se);let ie=te.relative(o,w);A.push({name:i.name,path:ie})}if(f.dependencies?.length){let i=await G({cwd:o,deps:f.dependencies});u.installed=new Set([...u.installed,...i.installed]),u.filtered=new Set([...u.filtered,...i.filtered])}if(f.devDependencies?.length){let i=await G({cwd:o,deps:f.devDependencies,dev:!0});u.installed=new Set([...u.installed,...i.installed]),u.filtered=new Set([...u.filtered,...i.filtered])}l.log.success(`${y(f.name)} \uAD00\uB828 \uD30C\uC77C \uCD94\uAC00 \uC644\uB8CC`)}if(u.installed.size&&l.log.message(`\uC124\uCE58\uB41C \uC758\uC874\uC131: ${y(Array.from(u.installed).join(", "))}`),u.filtered.size&&l.log.message(`\uC774\uBBF8 \uC124\uCE58\uB41C \uC758\uC874\uC131: ${y(Array.from(u.filtered).join(", "))}`),A.length)for(let f of A)l.log.message(`\uCD94\uAC00\uB41C \uD30C\uC77C: ${y(f.path)}`);l.outro("\uCEF4\uD3EC\uB10C\uD2B8 \uCD94\uAC00 \uC644\uB8CC.")})};import*as a from"@clack/prompts";import ze from"fs-extra";import ne from"path";import P from"picocolors";import{z as E}from"zod";var Ee=E.object({cwd:E.string(),yes:E.boolean().optional()}),oe=e=>{e.command("init","seed-design.json \uD30C\uC77C \uC0DD\uC131").option("-c, --cwd <cwd>","\uC791\uC5C5 \uB514\uB809\uD1A0\uB9AC. \uAE30\uBCF8\uAC12\uC740 \uD604\uC7AC \uB514\uB809\uD1A0\uB9AC.",{default:process.cwd()}).option("-y, --yes","\uBAA8\uB4E0 \uC9C8\uBB38\uC5D0 \uB300\uD574 \uAE30\uBCF8\uAC12\uC73C\uB85C \uB2F5\uBCC0\uD569\uB2C8\uB2E4.").action(async t=>{let r=c=>P.cyan(c);a.intro(P.bgCyan("seed-design.json \uD30C\uC77C \uC0DD\uC131"));let n=Ee.parse(t),o=n.yes,s={rsc:!1,tsx:!0,css:!0,path:"./seed-design"};o||(s={...await a.group({tsx:()=>a.confirm({message:`${r("TypeScript")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:!0}),rsc:()=>a.confirm({message:`${r("React Server Components")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:!1}),css:()=>a.confirm({message:`${r("CSS Loader")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694? (true\uC77C \uACBD\uC6B0 \uCEF4\uD3EC\uB10C\uD2B8\uC5D0 CSS import\uAC00 \uCD94\uAC00\uB429\uB2C8\uB2E4.)`,initialValue:!0}),path:()=>a.text({message:`${r("seed-design \uD3F4\uB354")} \uACBD\uB85C\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694. (\uAE30\uBCF8\uAC12\uC740 \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8\uC5D0 \uC0DD\uC131\uB429\uB2C8\uB2E4.)`,initialValue:"./seed-design",defaultValue:"./seed-design",placeholder:"./seed-design"})},{onCancel:()=>{a.cancel("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694."),process.exit(0)}})});try{let{start:c,stop:d}=a.spinner();c("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC911...");let m=ne.resolve(n.cwd,"seed-design.json");await ze.writeFile(m,`${JSON.stringify(s,null,2)}
|
|
3
|
+
`,"utf-8");let g=ne.relative(process.cwd(),m);d(`seed-design.json \uD30C\uC77C\uC774 ${r(g)}\uC5D0 \uC0DD\uC131\uB410\uC5B4\uC694.`),a.log.info(P.gray("seed-design add {component} \uBA85\uB839\uC5B4\uB85C \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCD94\uAC00\uD574\uBCF4\uC138\uC694!")),a.log.info(P.gray("seed-design add \uBA85\uB839\uC5B4\uB85C \uCD94\uAC00\uD560 \uC218 \uC788\uB294 \uBAA8\uB4E0 \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.")),a.outro("\uC791\uC5C5\uC774 \uC644\uB8CC\uB410\uC5B4\uC694.")}catch(c){a.log.error(`seed-design.json \uD30C\uC77C \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694. ${c}`),a.outro(P.bgRed("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694.")),process.exit(1)}})};import{cac as Fe}from"cac";var _e="seed-design",j=Fe(_e);async function Je(){let e=T();re(j),oe(j),j.version(e.version||"1.0.0","-v, --version"),j.help(),j.parse()}Je();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/cli",
|
|
3
|
-
"version": "0.0.0-alpha-
|
|
3
|
+
"version": "0.0.0-alpha-20250210081704",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"node": ">=18"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"prepack": "
|
|
23
|
-
"build": "ENV=prod
|
|
24
|
-
"dev": "ENV=dev
|
|
25
|
-
"test": "
|
|
22
|
+
"prepack": "bun run build",
|
|
23
|
+
"build": "ENV=prod bun ./build.mjs",
|
|
24
|
+
"dev": "ENV=dev bun ./dev.mjs",
|
|
25
|
+
"test": "bun vitest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@antfu/ni": "^
|
|
28
|
+
"@antfu/ni": "^23.3.1",
|
|
29
29
|
"@babel/core": "^7.24.9",
|
|
30
30
|
"@babel/parser": "^7.24.8",
|
|
31
31
|
"@babel/plugin-transform-typescript": "^7.24.8",
|
|
@@ -44,18 +44,17 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/babel__core": "^7.20.5",
|
|
46
46
|
"@types/fs-extra": "^11.0.4",
|
|
47
|
-
"esbuild": "^0.19.3",
|
|
48
47
|
"type-fest": "^4.23.0",
|
|
49
48
|
"typescript": "^5.4.5",
|
|
50
49
|
"ultra-runner": "^3.10.5",
|
|
51
|
-
"vitest": "^2.0.5"
|
|
50
|
+
"vitest": "^2.0.5",
|
|
51
|
+
"esbuild": "^0.25.0"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"ultra": {
|
|
57
57
|
"concurrent": [
|
|
58
|
-
"dev",
|
|
59
58
|
"build"
|
|
60
59
|
]
|
|
61
60
|
}
|
package/src/commands/add.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { getConfig } from "@/src/utils/get-config";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
fetchRegistryItem,
|
|
4
|
+
getRegistryLibIndex,
|
|
5
|
+
getRegistryUIIndex,
|
|
6
|
+
} from "@/src/utils/get-metadata";
|
|
4
7
|
import { transform } from "@/src/utils/transformers";
|
|
5
8
|
import * as p from "@clack/prompts";
|
|
6
|
-
import { execa } from "execa";
|
|
7
9
|
import fs from "fs-extra";
|
|
8
10
|
import path from "path";
|
|
9
11
|
import color from "picocolors";
|
|
10
12
|
import { z } from "zod";
|
|
11
13
|
|
|
12
14
|
import type { CAC } from "cac";
|
|
13
|
-
import {
|
|
15
|
+
import { BASE_URL } from "../constants";
|
|
16
|
+
import { addRelativeRegistries } from "../utils/add-relative-registries";
|
|
17
|
+
import { highlight } from "../utils/color";
|
|
18
|
+
import { installDependencies } from "../utils/install";
|
|
14
19
|
|
|
15
20
|
const addOptionsSchema = z.object({
|
|
16
21
|
components: z.array(z.string()).optional(),
|
|
17
22
|
cwd: z.string(),
|
|
18
23
|
all: z.boolean(),
|
|
24
|
+
baseUrl: z.string().optional(),
|
|
19
25
|
// yes: z.boolean(),
|
|
20
26
|
// overwrite: z.boolean(),
|
|
21
27
|
// path: z.string().optional(),
|
|
@@ -30,23 +36,26 @@ export const addCommand = (cli: CAC) => {
|
|
|
30
36
|
.option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", {
|
|
31
37
|
default: process.cwd(),
|
|
32
38
|
})
|
|
39
|
+
.option(
|
|
40
|
+
"-u, --baseUrl <baseUrl>",
|
|
41
|
+
"the base url of the registry. defaults to the current directory.",
|
|
42
|
+
{
|
|
43
|
+
default: BASE_URL,
|
|
44
|
+
},
|
|
45
|
+
)
|
|
33
46
|
.example("seed-design add box-button")
|
|
34
47
|
.example("seed-design add alert-dialog")
|
|
35
48
|
.action(async (components, opts) => {
|
|
49
|
+
p.intro(color.bgCyan("seed-design add"));
|
|
36
50
|
const options = addOptionsSchema.parse({
|
|
37
51
|
components,
|
|
38
52
|
...opts,
|
|
39
53
|
});
|
|
40
|
-
const highlight = (text: string) => color.cyan(text);
|
|
41
54
|
const cwd = options.cwd;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const registryComponentIndex = await getRegistryUIIndex();
|
|
49
|
-
|
|
55
|
+
const baseUrl = options.baseUrl;
|
|
56
|
+
const config = await getConfig(cwd);
|
|
57
|
+
const registryComponentIndex = await getRegistryUIIndex(baseUrl);
|
|
58
|
+
const libRegistryIndex = await getRegistryLibIndex(baseUrl);
|
|
50
59
|
let selectedComponents: string[] = options.all
|
|
51
60
|
? registryComponentIndex.map((registry) => registry.name)
|
|
52
61
|
: options.components;
|
|
@@ -56,7 +65,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
56
65
|
{ label: string; value: string; hint: string }[],
|
|
57
66
|
string
|
|
58
67
|
>({
|
|
59
|
-
message: "
|
|
68
|
+
message: "추가할 컴포넌트를 선택해주세요 (스페이스 바로 여러 개 선택 가능)",
|
|
60
69
|
options: registryComponentIndex.map((metadata) => {
|
|
61
70
|
return {
|
|
62
71
|
label: metadata.name,
|
|
@@ -67,7 +76,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
67
76
|
});
|
|
68
77
|
|
|
69
78
|
if (p.isCancel(selects)) {
|
|
70
|
-
p.log.error("
|
|
79
|
+
p.log.error("취소되었어요.");
|
|
71
80
|
process.exit(0);
|
|
72
81
|
}
|
|
73
82
|
|
|
@@ -75,35 +84,56 @@ export const addCommand = (cli: CAC) => {
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
if (!selectedComponents?.length) {
|
|
78
|
-
p.log.error("
|
|
87
|
+
p.log.error("컴포넌트를 찾을 수 없어요.");
|
|
79
88
|
process.exit(0);
|
|
80
89
|
}
|
|
81
90
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
91
|
+
p.log.message(`선택된 컴포넌트: ${highlight(selectedComponents.join(", "))}`);
|
|
92
|
+
|
|
93
|
+
const allRelativeRegistries = addRelativeRegistries({
|
|
94
|
+
userSelects: selectedComponents,
|
|
95
|
+
uiRegistryIndex: registryComponentIndex,
|
|
96
|
+
libRegistryIndex,
|
|
97
|
+
});
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
const allRegistryItems = [];
|
|
100
|
+
|
|
101
|
+
const { start, stop } = p.spinner();
|
|
102
|
+
start("Registry를 가져오고 있어요...");
|
|
103
|
+
|
|
104
|
+
for (const registry of allRelativeRegistries) {
|
|
105
|
+
const registryItem = await fetchRegistryItem(registry.name, baseUrl, registry.type);
|
|
106
|
+
allRegistryItems.push(registryItem);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
stop();
|
|
110
|
+
|
|
111
|
+
if (allRegistryItems.length) {
|
|
112
|
+
const filteredRegistryItems = allRegistryItems.filter(
|
|
113
|
+
(c) => !selectedComponents.includes(c.name),
|
|
114
|
+
);
|
|
89
115
|
p.log.message(
|
|
90
|
-
|
|
116
|
+
`추가로 설치될 레지스트리: ${highlight(
|
|
117
|
+
filteredRegistryItems.map((c) => c.name).join(", "),
|
|
118
|
+
)}`,
|
|
91
119
|
);
|
|
92
120
|
}
|
|
93
121
|
|
|
94
122
|
// 선택된 컴포넌트.json 레지스트리 파일 기반으로 컴포넌트를 추가합니다.
|
|
95
|
-
|
|
123
|
+
const registryResult = [];
|
|
124
|
+
const installResult = {
|
|
125
|
+
installed: new Set(),
|
|
126
|
+
filtered: new Set(),
|
|
127
|
+
};
|
|
128
|
+
for (const component of allRegistryItems) {
|
|
96
129
|
for (const registry of component.registries) {
|
|
97
130
|
let targetPath = "";
|
|
98
131
|
switch (registry.type) {
|
|
99
132
|
case "ui":
|
|
100
133
|
targetPath = config.resolvedUIPaths;
|
|
101
134
|
break;
|
|
102
|
-
case "
|
|
103
|
-
targetPath = config.
|
|
104
|
-
break;
|
|
105
|
-
case "util":
|
|
106
|
-
targetPath = config.resolvedUtilPaths;
|
|
135
|
+
case "lib":
|
|
136
|
+
targetPath = config.resolvedLibPaths;
|
|
107
137
|
break;
|
|
108
138
|
default:
|
|
109
139
|
break;
|
|
@@ -128,60 +158,50 @@ export const addCommand = (cli: CAC) => {
|
|
|
128
158
|
|
|
129
159
|
await fs.writeFile(filePath, content);
|
|
130
160
|
const relativePath = path.relative(cwd, filePath);
|
|
131
|
-
p.log.info(`Added ${highlight(registry.name)} to ${highlight(relativePath)}`);
|
|
132
|
-
}
|
|
133
161
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
registryResult.push({
|
|
163
|
+
name: registry.name,
|
|
164
|
+
path: relativePath,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
137
167
|
|
|
138
168
|
// Install dependencies.
|
|
139
169
|
if (component.dependencies?.length) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
packageManager,
|
|
144
|
-
[packageManager === "npm" ? "install" : "add", ...component.dependencies],
|
|
145
|
-
{
|
|
146
|
-
cwd,
|
|
147
|
-
},
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
if (result.failed) {
|
|
151
|
-
console.error(result.all);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
} else {
|
|
154
|
-
for (const deps of component.dependencies) {
|
|
155
|
-
p.log.info(`- ${deps}`);
|
|
156
|
-
}
|
|
157
|
-
stop("Dependencies installed.");
|
|
158
|
-
}
|
|
170
|
+
const result = await installDependencies({ cwd, deps: component.dependencies });
|
|
171
|
+
installResult.installed = new Set([...installResult.installed, ...result.installed]);
|
|
172
|
+
installResult.filtered = new Set([...installResult.filtered, ...result.filtered]);
|
|
159
173
|
}
|
|
160
174
|
|
|
161
175
|
// Install devDependencies.
|
|
162
176
|
if (component.devDependencies?.length) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
const result = await installDependencies({
|
|
178
|
+
cwd,
|
|
179
|
+
deps: component.devDependencies,
|
|
180
|
+
dev: true,
|
|
181
|
+
});
|
|
182
|
+
installResult.installed = new Set([...installResult.installed, ...result.installed]);
|
|
183
|
+
installResult.filtered = new Set([...installResult.filtered, ...result.filtered]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
p.log.success(`${highlight(component.name)} 관련 파일 추가 완료`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (installResult.installed.size) {
|
|
190
|
+
p.log.message(
|
|
191
|
+
`설치된 의존성: ${highlight(Array.from(installResult.installed).join(", "))}`,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (installResult.filtered.size) {
|
|
195
|
+
p.log.message(
|
|
196
|
+
`이미 설치된 의존성: ${highlight(Array.from(installResult.filtered).join(", "))}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
if (registryResult.length) {
|
|
200
|
+
for (const registry of registryResult) {
|
|
201
|
+
p.log.message(`추가된 파일: ${highlight(registry.path)}`);
|
|
182
202
|
}
|
|
183
203
|
}
|
|
184
204
|
|
|
185
|
-
p.outro("
|
|
205
|
+
p.outro("컴포넌트 추가 완료.");
|
|
186
206
|
});
|
|
187
207
|
};
|
package/src/commands/init.ts
CHANGED
|
@@ -10,63 +10,84 @@ import type { CAC } from "cac";
|
|
|
10
10
|
|
|
11
11
|
const initOptionsSchema = z.object({
|
|
12
12
|
cwd: z.string(),
|
|
13
|
+
yes: z.boolean().optional(),
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
export const initCommand = (cli: CAC) => {
|
|
16
17
|
cli
|
|
17
|
-
.command("init", "
|
|
18
|
-
.option("-c, --cwd <cwd>", "
|
|
18
|
+
.command("init", "seed-design.json 파일 생성")
|
|
19
|
+
.option("-c, --cwd <cwd>", "작업 디렉토리. 기본값은 현재 디렉토리.", {
|
|
19
20
|
default: process.cwd(),
|
|
20
21
|
})
|
|
22
|
+
.option("-y, --yes", "모든 질문에 대해 기본값으로 답변합니다.")
|
|
21
23
|
.action(async (opts) => {
|
|
22
|
-
const options = initOptionsSchema.parse({ ...opts });
|
|
23
24
|
const highlight = (text: string) => color.cyan(text);
|
|
25
|
+
p.intro(color.bgCyan("seed-design.json 파일 생성"));
|
|
24
26
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
const options = initOptionsSchema.parse(opts);
|
|
28
|
+
const isYesOption = options.yes;
|
|
29
|
+
let config: RawConfig = {
|
|
30
|
+
rsc: false,
|
|
31
|
+
tsx: true,
|
|
32
|
+
css: true,
|
|
33
|
+
path: "./seed-design",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (!isYesOption) {
|
|
37
|
+
const group = await p.group(
|
|
38
|
+
{
|
|
39
|
+
tsx: () =>
|
|
40
|
+
p.confirm({
|
|
41
|
+
message: `${highlight("TypeScript")}를 사용중이신가요?`,
|
|
42
|
+
initialValue: true,
|
|
43
|
+
}),
|
|
44
|
+
rsc: () =>
|
|
45
|
+
p.confirm({
|
|
46
|
+
message: `${highlight("React Server Components")}를 사용중이신가요?`,
|
|
47
|
+
initialValue: false,
|
|
48
|
+
}),
|
|
49
|
+
css: () =>
|
|
50
|
+
p.confirm({
|
|
51
|
+
message: `${highlight("CSS Loader")}를 사용중이신가요? (true일 경우 컴포넌트에 CSS import가 추가됩니다.)`,
|
|
52
|
+
initialValue: true,
|
|
53
|
+
}),
|
|
54
|
+
path: () =>
|
|
55
|
+
p.text({
|
|
56
|
+
message: `${highlight("seed-design 폴더")} 경로를 입력해주세요. (기본값은 프로젝트 루트에 생성됩니다.)`,
|
|
57
|
+
initialValue: "./seed-design",
|
|
58
|
+
defaultValue: "./seed-design",
|
|
59
|
+
placeholder: "./seed-design",
|
|
60
|
+
}),
|
|
54
61
|
},
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
{
|
|
63
|
+
onCancel: () => {
|
|
64
|
+
p.cancel("작업이 취소됐어요.");
|
|
65
|
+
process.exit(0);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
);
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
path: group.path,
|
|
63
|
-
};
|
|
70
|
+
config = {
|
|
71
|
+
...group,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
64
74
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
try {
|
|
76
|
+
const { start, stop } = p.spinner();
|
|
77
|
+
start("seed-design.json 파일 생성중...");
|
|
78
|
+
const targetPath = path.resolve(options.cwd, "seed-design.json");
|
|
79
|
+
await fs.writeFile(targetPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
80
|
+
const relativePath = path.relative(process.cwd(), targetPath);
|
|
81
|
+
stop(`seed-design.json 파일이 ${highlight(relativePath)}에 생성됐어요.`);
|
|
82
|
+
p.log.info(color.gray("seed-design add {component} 명령어로 컴포넌트를 추가해보세요!"));
|
|
83
|
+
p.log.info(
|
|
84
|
+
color.gray("seed-design add 명령어로 추가할 수 있는 모든 컴포넌트를 확인해보세요."),
|
|
85
|
+
);
|
|
86
|
+
p.outro("작업이 완료됐어요.");
|
|
87
|
+
} catch (error) {
|
|
88
|
+
p.log.error(`seed-design.json 파일 생성에 실패했어요. ${error}`);
|
|
89
|
+
p.outro(color.bgRed("작업이 취소됐어요."));
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
71
92
|
});
|
|
72
93
|
};
|
package/src/constants.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { addCommand } from "@/src/commands/add";
|
|
4
|
+
import { initCommand } from "@/src/commands/init";
|
|
4
5
|
import { getPackageInfo } from "@/src/utils/get-package-info";
|
|
5
6
|
import { cac } from "cac";
|
|
6
|
-
import { initCommand } from "./commands/init";
|
|
7
|
-
import { checkDeprecatedIconFilesCommand } from "@/src/commands/check-deprecated-icon-files";
|
|
8
7
|
|
|
9
8
|
const NAME = "seed-design";
|
|
10
9
|
const CLI = cac(NAME);
|
|
@@ -15,7 +14,6 @@ async function main() {
|
|
|
15
14
|
/* Commands */
|
|
16
15
|
addCommand(CLI);
|
|
17
16
|
initCommand(CLI);
|
|
18
|
-
checkDeprecatedIconFilesCommand(CLI);
|
|
19
17
|
|
|
20
18
|
CLI.version(packageInfo.version || "1.0.0", "-v, --version");
|
|
21
19
|
CLI.help();
|
package/src/schema.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// TODO: Extract to shared package
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
|
|
4
|
-
export const registryType = z.union([z.literal("ui"), z.literal("
|
|
3
|
+
export const registryType = z.union([z.literal("ui"), z.literal("lib")]);
|
|
5
4
|
|
|
6
5
|
export const registryUIItemSchema = z.object({
|
|
7
6
|
/**
|
|
@@ -25,7 +24,9 @@ export const registryUIItemSchema = z.object({
|
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* @description 레지스트리 내부의 Seed Design 컴포넌트 의존성
|
|
28
|
-
*
|
|
27
|
+
* * `:`를 기준으로 왼쪽은 {registryType}, 오른쪽은 파일 이름
|
|
28
|
+
* @example ui:action-button
|
|
29
|
+
* @example lib:manner-temp-level
|
|
29
30
|
*/
|
|
30
31
|
innerDependencies: z.array(z.string()).optional(),
|
|
31
32
|
|
|
@@ -34,7 +35,8 @@ export const registryUIItemSchema = z.object({
|
|
|
34
35
|
* 컴포넌트 코드 스니펫 경로, 여러 파일이 될 수 있어서 배열로 정의
|
|
35
36
|
* `:`를 기준으로 왼쪽은 {registryType}, 오른쪽은 파일 이름
|
|
36
37
|
* @example ui:alert-dialog.tsx
|
|
37
|
-
* @example
|
|
38
|
+
* @example ui:use-dismissible.ts
|
|
39
|
+
* @example lib:manner-temp-level.ts
|
|
38
40
|
*/
|
|
39
41
|
files: z.array(z.string()),
|
|
40
42
|
});
|
|
@@ -59,21 +61,16 @@ export const registryComponentMachineGeneratedSchema = z.array(
|
|
|
59
61
|
registryUIItemMachineGeneratedSchema,
|
|
60
62
|
);
|
|
61
63
|
|
|
62
|
-
// NOTE: 현재는
|
|
63
|
-
export const
|
|
64
|
-
export const registryUtilItemMachineGeneratedSchema = registryUIItemMachineGeneratedSchema;
|
|
64
|
+
// NOTE: 현재는 lib이 ui와 타입이 동일하지만, 따로 가져가야한다면 타입을 변경해야해요.
|
|
65
|
+
export const registryLibItemMachineGeneratedSchema = registryUIItemMachineGeneratedSchema;
|
|
65
66
|
|
|
66
|
-
// NOTE: 현재는
|
|
67
|
-
export type
|
|
68
|
-
export type
|
|
69
|
-
export type RegistryHookItem = z.infer<typeof registryUIItemSchema>;
|
|
70
|
-
export type RegistryHook = z.infer<typeof registryUISchema>;
|
|
67
|
+
// NOTE: 현재는 lib이 ui와 타입이 동일하지만, 따로 가져가야한다면 타입을 변경해야해요.
|
|
68
|
+
export type RegistryLibItem = z.infer<typeof registryUIItemSchema>;
|
|
69
|
+
export type RegistryLib = z.infer<typeof registryUISchema>;
|
|
71
70
|
export type RegistryUIItem = z.infer<typeof registryUIItemSchema>;
|
|
72
71
|
export type RegistryUI = z.infer<typeof registryUISchema>;
|
|
73
72
|
|
|
74
73
|
export type RegistryUIItemMachineGenerated = z.infer<typeof registryUIItemMachineGeneratedSchema>;
|
|
75
74
|
export type RegistryUIMachineGenerated = z.infer<typeof registryComponentMachineGeneratedSchema>;
|
|
76
|
-
export type
|
|
77
|
-
export type
|
|
78
|
-
export type RegistryUtilItemMachineGenerated = z.infer<typeof registryUIItemMachineGeneratedSchema>;
|
|
79
|
-
export type RegistryUtilMachineGenerated = z.infer<typeof registryComponentMachineGeneratedSchema>;
|
|
75
|
+
export type RegistryLibItemMachineGenerated = z.infer<typeof registryLibItemMachineGeneratedSchema>;
|
|
76
|
+
export type RegistryLibMachineGenerated = z.infer<typeof registryComponentMachineGeneratedSchema>;
|