@seed-design/cli 0.0.0-alpha-20241113031935 → 0.0.0-alpha-20241204134404
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/bin/index.mjs +2 -2
- package/package.json +1 -2
- package/src/commands/add.ts +26 -23
- package/src/commands/init.ts +68 -46
- package/src/constants.ts +2 -0
- package/src/index.ts +1 -3
- package/src/utils/color.ts +3 -0
- package/src/utils/get-config.ts +39 -13
- package/src/utils/get-metadata.ts +44 -18
- package/src/commands/check-deprecated-icon-files.ts +0 -256
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 ie}from"cosmiconfig";import{execa as ae}from"execa";import u from"fs";import k from"path";import{z as d}from"zod";import ne from"picocolors";var x=e=>ne.cyan(e);import{detect as se}from"@antfu/ni";async function R(e){let t=await se({programmatic:!0,cwd:e});return t==="yarn@berry"?"yarn":t==="pnpm@6"?"pnpm":t==="bun"?"bun":t??"npm"}var E="seed-design",ce=ie(E,{searchPlaces:[`${E}.json`]}),D=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(),pe=D.extend({resolvedUIPaths:d.string(),resolbedHookPaths:d.string(),resolvedUtilPaths:d.string()});async function F(e){let t=await fe(e);return t?await me(e,t):null}async function me(e,t){let r=k.resolve(e,t.path);u.existsSync(r)||u.mkdirSync(r,{recursive:!0});let n=k.join(r,"ui"),o=k.join(r,"hook"),c=k.join(r,"util");return u.existsSync(n)||u.mkdirSync(n,{recursive:!0}),u.existsSync(o)||u.mkdirSync(o,{recursive:!0}),u.existsSync(c)||u.mkdirSync(c,{recursive:!0}),pe.parse({...t,resolvedUIPaths:n,resolbedHookPaths:o,resolvedUtilPaths:c})}async function fe(e){try{let t=await ce.search(e);return D.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 R(e);await ae(r,["seed-design","init","--default"],{cwd:e}),S.log.message("seed-design.json \uD30C\uC77C\uC774 \uC0DD\uC131\uB410\uC5B4\uC694.")}else S.outro(x("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694.")),process.exit(1)}}import*as w from"@clack/prompts";import{z as s}from"zod";var le=s.union([s.literal("ui"),s.literal("hook"),s.literal("util")]),_=s.object({name:s.string(),description:s.string().optional(),dependencies:s.array(s.string()).optional(),devDependencies:s.array(s.string()).optional(),innerDependencies:s.array(s.string()).optional(),files:s.array(s.string())}),b=s.array(_),ge=_.omit({files:!0}),de=ge.extend({registries:s.array(s.object({name:s.string(),type:le,content:s.string()}))}),qe=s.array(de);async function M(e,t){return await Promise.all(e.map(async n=>{try{return await(await fetch(`${t}/__registry__/ui/${n}.json`)).json()}catch(o){let c=await fetch(`${t}/__registry__/ui/index.json`).then(f=>f.json()),h=b.parse(c).map(f=>f.name);w.log.error(`${n} \uCEF4\uD3EC\uB10C\uD2B8\uB294 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC544\uC694.`),w.log.info(`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uCEF4\uD3EC\uB10C\uD2B8: ${h.join(", ")}`),w.log.info(JSON.stringify({baseUrl:t,error:o.toString()},null,2)),process.exit(1)}}))}async function J(e){try{let[t]=await M(["index"],e);return b.parse(t)}catch(t){w.log.error("\uB808\uC9C0\uC2A4\uD2B8\uB9AC \uC778\uB371\uC2A4\uB97C \uAC00\uC838\uC624\uB294 \uB370 \uC2E4\uD328\uD588\uC5B4\uC694."),w.log.info(JSON.stringify({baseUrl:e,error:t.toString()},null,2)),process.exit(1)}}import{promises as Ie}from"fs";import{tmpdir as we}from"os";import V from"path";import{transformFromAstSync as ye}from"@babel/core";import ue from"@babel/plugin-transform-typescript";import*as j from"recast";import{parse as he}from"@babel/parser";var xe={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"]},N=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let n=j.parse(r,{parser:{parse:c=>he(c,xe)}}),o=ye(n,r,{cloneInputAst:!1,code:!1,ast:!0,plugins:[ue],configFile:!1});if(!o||!o.ast)throw new Error("Failed to transform JSX");return j.print(o.ast).code};import{SyntaxKind as Se}from"ts-morph";var H=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(Se.ExpressionStatement);return r?.getText()==='"use client";'&&r.remove(),e};var L=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 Ce,ScriptKind as ve}from"ts-morph";var Pe=[H,L],Ue=new Ce({compilerOptions:{}});async function Re(e){let t=await Ie.mkdtemp(V.join(we(),"seed-deisgn-"));return V.join(t,e)}async function B(e){let t=await Re(e.filename),r=Ue.createSourceFile(t,e.raw,{scriptKind:ve.TSX});for(let n of Pe)n({sourceFile:r,...e});return await N({sourceFile:r,...e})}import*as a from"@clack/prompts";import{execa as W}from"execa";import O from"fs-extra";import q from"path";import $ from"picocolors";import{z as C}from"zod";function K(e,t){let r=new Set;function n(o){if(r.has(o))return;r.add(o);let c=t.find(p=>p.name===o);if(c&&c.innerDependencies)for(let p of c.innerDependencies)n(p)}for(let o of e)n(o);return Array.from(r)}var X="https://v3.seed-design.io";var ke=C.object({components:C.array(C.string()).optional(),cwd:C.string(),all:C.boolean(),baseUrl:C.string().optional()}),Q=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:X}).example("seed-design add box-button").example("seed-design add alert-dialog").action(async(t,r)=>{a.intro($.bgCyan("\uCEF4\uD3EC\uB10C\uD2B8 \uCD94\uAC00\uD558\uAE30"));let n=ke.parse({components:t,...r}),o=n.cwd,c=n.baseUrl,p=await F(o),h=await J(c),f=n.all?h.map(m=>m.name):n.components;if(!n.components?.length&&!n.all){let m=await a.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:h.map(y=>({label:y.name,value:y.name,hint:y.description}))});a.isCancel(m)&&(a.log.error("\uCDE8\uC18C\uB418\uC5C8\uC5B4\uC694."),process.exit(0)),f=m}f?.length||(a.log.error("\uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694."),process.exit(0));let U=K(f,h),T=U.filter(m=>!f.includes(m)),te=await M(U,c);a.log.message(`\uC120\uD0DD\uB41C \uCEF4\uD3EC\uB10C\uD2B8: ${x(f.join(", "))}`),T.length&&a.log.message(`\uB0B4\uBD80 \uC758\uC874\uC131: ${x(T.join(", "))} \uCD94\uAC00\uB429\uB2C8\uB2E4.`);for(let m of te){for(let l of m.registries){let g="";switch(l.type){case"ui":g=p.resolvedUIPaths;break;case"hook":g=p.resolbedHookPaths;break;case"util":g=p.resolvedUtilPaths;break;default:break}O.existsSync(g)||await O.mkdir(g,{recursive:!0});let I=q.resolve(g,l.name),re=await B({filename:l.name,config:p,raw:l.content});p.tsx||(I=I.replace(/\.tsx$/,".jsx"),I=I.replace(/\.ts$/,".js")),await O.writeFile(I,re);let oe=q.relative(o,I);a.log.info(`${x(l.name)} \uCD94\uAC00\uB428: ${x(oe)}`)}let y=await R(o),{start:z,stop:A}=a.spinner();if(m.dependencies?.length){z($.gray("\uC758\uC874\uC131 \uC124\uCE58\uC911..."));let l=await W(y,[y==="npm"?"install":"add",...m.dependencies],{cwd:o});if(l.failed)console.error(l.all),process.exit(1);else{for(let g of m.dependencies)a.log.info(`- ${g}`);A("\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC.")}}if(m.devDependencies?.length){z($.gray("\uAC1C\uBC1C \uC758\uC874\uC131 \uC124\uCE58\uC911..."));let l=await W(y,[y==="npm"?"install":"add","-D",...m.devDependencies],{cwd:o});if(l.failed)console.error(l.all),process.exit(1);else{for(let g of m.devDependencies)a.log.info(`- ${g}`);A("\uAC1C\uBC1C \uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC.")}}}a.outro(`${t.join(", ")} \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCD94\uAC00\uD588\uC5B4\uC694.`)})};import*as i from"@clack/prompts";import je from"fs-extra";import Y from"path";import v from"picocolors";import{z as G}from"zod";var be=G.object({cwd:G.string(),default:G.boolean().optional()}),Z=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("-d, --default","\uBAA8\uB4E0 \uC9C8\uBB38\uC5D0 \uB300\uD574 \uAE30\uBCF8\uAC12\uC73C\uB85C \uB2F5\uBCC0\uD569\uB2C8\uB2E4.").action(async t=>{let r=p=>v.cyan(p);i.intro(v.bgCyan("seed-design.json \uD30C\uC77C \uC0DD\uC131"));let n=be.parse(t),o=n.default,c={rsc:!1,tsx:!0,css:!0,path:"./seed-design"};o||(c={...await i.group({tsx:()=>i.confirm({message:`${r("TypeScript")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:!0}),rsc:()=>i.confirm({message:`${r("React Server Components")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:!1}),css:()=>i.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:()=>i.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:()=>{i.cancel("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694."),process.exit(0)}})});try{let{start:p,stop:h}=i.spinner();p("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC911...");let f=Y.resolve(n.cwd,"seed-design.json");await je.writeFile(f,`${JSON.stringify(c,null,2)}
|
|
3
|
+
`,"utf-8");let U=Y.relative(process.cwd(),f);h(`seed-design.json \uD30C\uC77C\uC774 ${r(U)}\uC5D0 \uC0DD\uC131\uB410\uC5B4\uC694.`),i.log.info(v.gray("seed-design add {component} \uBA85\uB839\uC5B4\uB85C \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCD94\uAC00\uD574\uBCF4\uC138\uC694!")),i.log.info(v.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.")),i.outro("\uC791\uC5C5\uC774 \uC644\uB8CC\uB410\uC5B4\uC694.")}catch(p){i.log.error(`seed-design.json \uD30C\uC77C \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694. ${p}`),i.outro(v.bgRed("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694.")),process.exit(1)}})};import Me from"findup-sync";import Oe from"fs-extra";var $e="package.json";function Ge(){let e=Me($e);if(!e)throw new Error("No package.json file found in the project.");return e}function ee(){return Oe.readJSONSync(Ge())}import{cac as Te}from"cac";var ze="seed-design",P=Te(ze);async function Ae(){let e=ee();Q(P),Z(P),P.version(e.version||"1.0.0","-v, --version"),P.help(),P.parse()}Ae();
|
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-20241204134404",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
},
|
|
56
56
|
"ultra": {
|
|
57
57
|
"concurrent": [
|
|
58
|
-
"dev",
|
|
59
58
|
"build"
|
|
60
59
|
]
|
|
61
60
|
}
|
package/src/commands/add.ts
CHANGED
|
@@ -11,11 +11,14 @@ import { z } from "zod";
|
|
|
11
11
|
|
|
12
12
|
import type { CAC } from "cac";
|
|
13
13
|
import { addRelativeComponents } from "../utils/add-relative-components";
|
|
14
|
+
import { BASE_URL } from "../constants";
|
|
15
|
+
import { highlight } from "../utils/color";
|
|
14
16
|
|
|
15
17
|
const addOptionsSchema = z.object({
|
|
16
18
|
components: z.array(z.string()).optional(),
|
|
17
19
|
cwd: z.string(),
|
|
18
20
|
all: z.boolean(),
|
|
21
|
+
baseUrl: z.string().optional(),
|
|
19
22
|
// yes: z.boolean(),
|
|
20
23
|
// overwrite: z.boolean(),
|
|
21
24
|
// path: z.string().optional(),
|
|
@@ -30,22 +33,25 @@ export const addCommand = (cli: CAC) => {
|
|
|
30
33
|
.option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", {
|
|
31
34
|
default: process.cwd(),
|
|
32
35
|
})
|
|
36
|
+
.option(
|
|
37
|
+
"-u, --baseUrl <baseUrl>",
|
|
38
|
+
"the base url of the registry. defaults to the current directory.",
|
|
39
|
+
{
|
|
40
|
+
default: BASE_URL,
|
|
41
|
+
},
|
|
42
|
+
)
|
|
33
43
|
.example("seed-design add box-button")
|
|
34
44
|
.example("seed-design add alert-dialog")
|
|
35
45
|
.action(async (components, opts) => {
|
|
46
|
+
p.intro(color.bgCyan("컴포넌트 추가하기"));
|
|
36
47
|
const options = addOptionsSchema.parse({
|
|
37
48
|
components,
|
|
38
49
|
...opts,
|
|
39
50
|
});
|
|
40
|
-
const highlight = (text: string) => color.cyan(text);
|
|
41
51
|
const cwd = options.cwd;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const registryComponentIndex = await getRegistryUIIndex();
|
|
52
|
+
const baseUrl = options.baseUrl;
|
|
53
|
+
const config = await getConfig(cwd);
|
|
54
|
+
const registryComponentIndex = await getRegistryUIIndex(baseUrl);
|
|
49
55
|
|
|
50
56
|
let selectedComponents: string[] = options.all
|
|
51
57
|
? registryComponentIndex.map((registry) => registry.name)
|
|
@@ -56,7 +62,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
56
62
|
{ label: string; value: string; hint: string }[],
|
|
57
63
|
string
|
|
58
64
|
>({
|
|
59
|
-
message: "
|
|
65
|
+
message: "추가할 컴포넌트를 선택해주세요 (스페이스바로 여러 개 선택 가능)",
|
|
60
66
|
options: registryComponentIndex.map((metadata) => {
|
|
61
67
|
return {
|
|
62
68
|
label: metadata.name,
|
|
@@ -67,7 +73,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
67
73
|
});
|
|
68
74
|
|
|
69
75
|
if (p.isCancel(selects)) {
|
|
70
|
-
p.log.error("
|
|
76
|
+
p.log.error("취소되었어요.");
|
|
71
77
|
process.exit(0);
|
|
72
78
|
}
|
|
73
79
|
|
|
@@ -75,20 +81,17 @@ export const addCommand = (cli: CAC) => {
|
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
if (!selectedComponents?.length) {
|
|
78
|
-
p.log.error("
|
|
84
|
+
p.log.error("컴포넌트를 찾을 수 없어요.");
|
|
79
85
|
process.exit(0);
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
const allComponents = addRelativeComponents(selectedComponents, registryComponentIndex);
|
|
83
89
|
const addedComponents = allComponents.filter((c) => !selectedComponents.includes(c));
|
|
84
|
-
const
|
|
85
|
-
const registryComponentItems = await fetchRegistryUIItem(allComponents);
|
|
90
|
+
const registryComponentItems = await fetchRegistryUIItem(allComponents, baseUrl);
|
|
86
91
|
|
|
87
|
-
p.log.message(
|
|
92
|
+
p.log.message(`선택된 컴포넌트: ${highlight(selectedComponents.join(", "))}`);
|
|
88
93
|
if (addedComponents.length) {
|
|
89
|
-
p.log.message(
|
|
90
|
-
`Inner Dependencies: ${highlight(addedComponents.join(", "))} will be also added.`,
|
|
91
|
-
);
|
|
94
|
+
p.log.message(`내부 의존성: ${highlight(addedComponents.join(", "))} 추가됩니다.`);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
// 선택된 컴포넌트.json 레지스트리 파일 기반으로 컴포넌트를 추가합니다.
|
|
@@ -128,7 +131,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
128
131
|
|
|
129
132
|
await fs.writeFile(filePath, content);
|
|
130
133
|
const relativePath = path.relative(cwd, filePath);
|
|
131
|
-
p.log.info(
|
|
134
|
+
p.log.info(`${highlight(registry.name)} 추가됨: ${highlight(relativePath)}`);
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
const packageManager = await getPackageManager(cwd);
|
|
@@ -137,7 +140,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
137
140
|
|
|
138
141
|
// Install dependencies.
|
|
139
142
|
if (component.dependencies?.length) {
|
|
140
|
-
start(color.gray("
|
|
143
|
+
start(color.gray("의존성 설치중..."));
|
|
141
144
|
|
|
142
145
|
const result = await execa(
|
|
143
146
|
packageManager,
|
|
@@ -154,13 +157,13 @@ export const addCommand = (cli: CAC) => {
|
|
|
154
157
|
for (const deps of component.dependencies) {
|
|
155
158
|
p.log.info(`- ${deps}`);
|
|
156
159
|
}
|
|
157
|
-
stop("
|
|
160
|
+
stop("의존성 설치 완료.");
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
// Install devDependencies.
|
|
162
165
|
if (component.devDependencies?.length) {
|
|
163
|
-
start(color.gray("
|
|
166
|
+
start(color.gray("개발 의존성 설치중..."));
|
|
164
167
|
|
|
165
168
|
const result = await execa(
|
|
166
169
|
packageManager,
|
|
@@ -177,11 +180,11 @@ export const addCommand = (cli: CAC) => {
|
|
|
177
180
|
for (const deps of component.devDependencies) {
|
|
178
181
|
p.log.info(`- ${deps}`);
|
|
179
182
|
}
|
|
180
|
-
stop("
|
|
183
|
+
stop("개발 의존성 설치 완료.");
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
p.outro("
|
|
188
|
+
p.outro(`${components.join(", ")} 컴포넌트를 추가했어요.`);
|
|
186
189
|
});
|
|
187
190
|
};
|
package/src/commands/init.ts
CHANGED
|
@@ -10,63 +10,85 @@ import type { CAC } from "cac";
|
|
|
10
10
|
|
|
11
11
|
const initOptionsSchema = z.object({
|
|
12
12
|
cwd: z.string(),
|
|
13
|
+
default: 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("-d, --default", "모든 질문에 대해 기본값으로 답변합니다.")
|
|
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
|
-
tsx: () =>
|
|
28
|
-
p.confirm({
|
|
29
|
-
message: `Would you like to use ${highlight("TypeScript")} (recommended)?`,
|
|
30
|
-
initialValue: true,
|
|
31
|
-
}),
|
|
32
|
-
rsc: () =>
|
|
33
|
-
p.confirm({
|
|
34
|
-
message: `Are you using ${highlight("React Server Components")}?`,
|
|
35
|
-
initialValue: false,
|
|
36
|
-
}),
|
|
37
|
-
css: () =>
|
|
38
|
-
p.confirm({
|
|
39
|
-
message: `Would you like to use ${highlight("CSS Modules")}? (If true, CSS import will be added in components)`,
|
|
40
|
-
initialValue: true,
|
|
41
|
-
}),
|
|
42
|
-
path: () =>
|
|
43
|
-
p.text({
|
|
44
|
-
message: `Enter the path to your ${highlight("seed-design directory")}`,
|
|
45
|
-
initialValue: "./seed-design",
|
|
46
|
-
defaultValue: "./seed-design",
|
|
47
|
-
placeholder: "./seed-design",
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
onCancel: () => {
|
|
52
|
-
p.cancel("Operation cancelled.");
|
|
53
|
-
process.exit(0);
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
);
|
|
27
|
+
const options = initOptionsSchema.parse(opts);
|
|
28
|
+
const isDefaultOption = options.default;
|
|
57
29
|
|
|
58
|
-
|
|
59
|
-
rsc:
|
|
60
|
-
tsx:
|
|
61
|
-
css:
|
|
62
|
-
path:
|
|
30
|
+
let config: RawConfig = {
|
|
31
|
+
rsc: false,
|
|
32
|
+
tsx: true,
|
|
33
|
+
css: true,
|
|
34
|
+
path: "./seed-design",
|
|
63
35
|
};
|
|
64
36
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
37
|
+
if (!isDefaultOption) {
|
|
38
|
+
const group = await p.group(
|
|
39
|
+
{
|
|
40
|
+
tsx: () =>
|
|
41
|
+
p.confirm({
|
|
42
|
+
message: `${highlight("TypeScript")}를 사용중이신가요?`,
|
|
43
|
+
initialValue: true,
|
|
44
|
+
}),
|
|
45
|
+
rsc: () =>
|
|
46
|
+
p.confirm({
|
|
47
|
+
message: `${highlight("React Server Components")}를 사용중이신가요?`,
|
|
48
|
+
initialValue: false,
|
|
49
|
+
}),
|
|
50
|
+
css: () =>
|
|
51
|
+
p.confirm({
|
|
52
|
+
message: `${highlight("CSS Loader")}를 사용중이신가요? (true일 경우 컴포넌트에 CSS import가 추가됩니다.)`,
|
|
53
|
+
initialValue: true,
|
|
54
|
+
}),
|
|
55
|
+
path: () =>
|
|
56
|
+
p.text({
|
|
57
|
+
message: `${highlight("seed-design 폴더")} 경로를 입력해주세요. (기본값은 프로젝트 루트에 생성됩니다.)`,
|
|
58
|
+
initialValue: "./seed-design",
|
|
59
|
+
defaultValue: "./seed-design",
|
|
60
|
+
placeholder: "./seed-design",
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
onCancel: () => {
|
|
65
|
+
p.cancel("작업이 취소됐어요.");
|
|
66
|
+
process.exit(0);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
config = {
|
|
72
|
+
...group,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const { start, stop } = p.spinner();
|
|
78
|
+
start("seed-design.json 파일 생성중...");
|
|
79
|
+
const targetPath = path.resolve(options.cwd, "seed-design.json");
|
|
80
|
+
await fs.writeFile(targetPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
81
|
+
const relativePath = path.relative(process.cwd(), targetPath);
|
|
82
|
+
stop(`seed-design.json 파일이 ${highlight(relativePath)}에 생성됐어요.`);
|
|
83
|
+
p.log.info(color.gray("seed-design add {component} 명령어로 컴포넌트를 추가해보세요!"));
|
|
84
|
+
p.log.info(
|
|
85
|
+
color.gray("seed-design add 명령어로 추가할 수 있는 모든 컴포넌트를 확인해보세요."),
|
|
86
|
+
);
|
|
87
|
+
p.outro("작업이 완료됐어요.");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
p.log.error(`seed-design.json 파일 생성에 실패했어요. ${error}`);
|
|
90
|
+
p.outro(color.bgRed("작업이 취소됐어요."));
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
71
93
|
});
|
|
72
94
|
};
|
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/utils/get-config.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
1
2
|
import { cosmiconfig } from "cosmiconfig";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import fs from "fs";
|
|
2
5
|
import path from "path";
|
|
3
|
-
import * as p from "@clack/prompts";
|
|
4
6
|
import { z } from "zod";
|
|
5
|
-
import
|
|
7
|
+
import { highlight } from "./color";
|
|
8
|
+
import { getPackageManager } from "./get-package-manager";
|
|
6
9
|
|
|
7
10
|
const MODULE_NAME = "seed-design";
|
|
8
11
|
|
|
@@ -43,26 +46,49 @@ export type Config = z.infer<typeof configSchema>;
|
|
|
43
46
|
export async function resolveConfigPaths(cwd: string, config: RawConfig) {
|
|
44
47
|
const seedComponentRootPath = path.resolve(cwd, config.path);
|
|
45
48
|
|
|
49
|
+
if (!fs.existsSync(seedComponentRootPath)) {
|
|
50
|
+
fs.mkdirSync(seedComponentRootPath, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const resolvedUIPaths = path.join(seedComponentRootPath, "ui");
|
|
54
|
+
const resolbedHookPaths = path.join(seedComponentRootPath, "hook");
|
|
55
|
+
const resolvedUtilPaths = path.join(seedComponentRootPath, "util");
|
|
56
|
+
|
|
57
|
+
if (!fs.existsSync(resolvedUIPaths)) {
|
|
58
|
+
fs.mkdirSync(resolvedUIPaths, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!fs.existsSync(resolbedHookPaths)) {
|
|
62
|
+
fs.mkdirSync(resolbedHookPaths, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!fs.existsSync(resolvedUtilPaths)) {
|
|
66
|
+
fs.mkdirSync(resolvedUtilPaths, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
|
|
46
69
|
return configSchema.parse({
|
|
47
70
|
...config,
|
|
48
|
-
resolvedUIPaths
|
|
49
|
-
resolbedHookPaths
|
|
50
|
-
resolvedUtilPaths
|
|
71
|
+
resolvedUIPaths,
|
|
72
|
+
resolbedHookPaths,
|
|
73
|
+
resolvedUtilPaths,
|
|
51
74
|
});
|
|
52
75
|
}
|
|
53
76
|
|
|
54
77
|
export async function getRawConfig(cwd: string): Promise<RawConfig | null> {
|
|
55
78
|
try {
|
|
56
79
|
const configResult = await explorer.search(cwd);
|
|
80
|
+
return rawConfigSchema.parse(configResult.config);
|
|
81
|
+
} catch {
|
|
82
|
+
p.log.error("프로젝트 루트 경로에 `seed-design.json` 파일이 없어요.");
|
|
57
83
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
const isConfirm = await p.confirm({ message: "seed-design.json 파일을 생성하시겠어요?" });
|
|
85
|
+
if (isConfirm === true) {
|
|
86
|
+
const packageManager = await getPackageManager(cwd);
|
|
87
|
+
await execa(packageManager, ["seed-design", "init", "--default"], { cwd });
|
|
88
|
+
p.log.message("seed-design.json 파일이 생성됐어요.");
|
|
89
|
+
} else {
|
|
90
|
+
p.outro(highlight("작업이 취소됐어요."));
|
|
91
|
+
process.exit(1);
|
|
61
92
|
}
|
|
62
|
-
|
|
63
|
-
return rawConfigSchema.parse(configResult.config);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.log(error);
|
|
66
|
-
throw new Error(`${cwd} 경로에 seed-design.json 파일을 읽을 수 없습니다.`);
|
|
67
93
|
}
|
|
68
94
|
}
|
|
@@ -1,33 +1,59 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
1
2
|
import { registryUISchema, type RegistryUIMachineGenerated } from "@/src/schema";
|
|
2
3
|
|
|
3
|
-
const BASE_URL =
|
|
4
|
-
process.env.NODE_ENV === "prod" ? "https://v3.seed-design.io" : "http://localhost:3000";
|
|
5
|
-
|
|
6
4
|
export async function fetchRegistryUIItem(
|
|
7
5
|
fileNames?: string[],
|
|
6
|
+
baseUrl?: string,
|
|
8
7
|
): Promise<RegistryUIMachineGenerated> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const response = await fetch(`${
|
|
8
|
+
const results = await Promise.all(
|
|
9
|
+
fileNames.map(async (fileName) => {
|
|
10
|
+
try {
|
|
11
|
+
const response = await fetch(`${baseUrl}/__registry__/ui/${fileName}.json`);
|
|
13
12
|
return await response.json();
|
|
14
|
-
})
|
|
15
|
-
|
|
13
|
+
} catch (error) {
|
|
14
|
+
const index = await fetch(`${baseUrl}/__registry__/ui/index.json`).then((res) =>
|
|
15
|
+
res.json(),
|
|
16
|
+
);
|
|
17
|
+
const parsedIndex = registryUISchema.parse(index);
|
|
18
|
+
const availableComponents = parsedIndex.map((component) => component.name);
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
p.log.error(`${fileName} 컴포넌트는 레지스트리에 존재하지 않아요.`);
|
|
21
|
+
p.log.info(`사용 가능한 컴포넌트: ${availableComponents.join(", ")}`);
|
|
22
|
+
p.log.info(
|
|
23
|
+
JSON.stringify(
|
|
24
|
+
{
|
|
25
|
+
baseUrl,
|
|
26
|
+
error: error.toString(),
|
|
27
|
+
},
|
|
28
|
+
null,
|
|
29
|
+
2,
|
|
30
|
+
),
|
|
31
|
+
);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return results;
|
|
22
38
|
}
|
|
23
39
|
|
|
24
|
-
export async function getRegistryUIIndex() {
|
|
40
|
+
export async function getRegistryUIIndex(baseUrl?: string) {
|
|
25
41
|
try {
|
|
26
|
-
const [result] = await fetchRegistryUIItem(["index"]);
|
|
42
|
+
const [result] = await fetchRegistryUIItem(["index"], baseUrl);
|
|
27
43
|
|
|
28
44
|
return registryUISchema.parse(result);
|
|
29
45
|
} catch (error) {
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
p.log.error("레지스트리 인덱스를 가져오는 데 실패했어요.");
|
|
47
|
+
p.log.info(
|
|
48
|
+
JSON.stringify(
|
|
49
|
+
{
|
|
50
|
+
baseUrl,
|
|
51
|
+
error: error.toString(),
|
|
52
|
+
},
|
|
53
|
+
null,
|
|
54
|
+
2,
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
process.exit(1);
|
|
32
58
|
}
|
|
33
59
|
}
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import type { CAC } from "cac";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
|
|
4
|
-
export const checkDeprecatedIconFilesCommand = (cli: CAC) => {
|
|
5
|
-
cli
|
|
6
|
-
.command("check-deprecated-icon-files [path]", "Check deprecated icon files")
|
|
7
|
-
.action(async (path) => {
|
|
8
|
-
const files = fs.readdirSync(path, { recursive: true });
|
|
9
|
-
|
|
10
|
-
const deprecatedIconFileNames = deprecatedIconNames.flatMap((name) => {
|
|
11
|
-
const nameTrimmed = name.replace("icon_", "");
|
|
12
|
-
|
|
13
|
-
return [
|
|
14
|
-
// icon_arrow_downward
|
|
15
|
-
name,
|
|
16
|
-
// arrow_downward
|
|
17
|
-
nameTrimmed,
|
|
18
|
-
// icon-arrow-downward
|
|
19
|
-
name.replace(/_/g, "-"),
|
|
20
|
-
// iconarrowdownward
|
|
21
|
-
name.replace(/_/g, ""),
|
|
22
|
-
// iconarrowdownwardthin
|
|
23
|
-
`${name.replace(/_/g, "")}thin`,
|
|
24
|
-
// iconarrowdownwardregular
|
|
25
|
-
`${name.replace(/_/g, "")}regular`,
|
|
26
|
-
// iconarrowdownwardfill
|
|
27
|
-
`${name.replace(/_/g, "")}fill`,
|
|
28
|
-
// arrow-downward
|
|
29
|
-
nameTrimmed.replace(/_/g, "-"),
|
|
30
|
-
// arrowdownward
|
|
31
|
-
nameTrimmed.replace(/_/g, ""),
|
|
32
|
-
// arrowdownwardthin
|
|
33
|
-
`${nameTrimmed.replace(/_/g, "")}thin`,
|
|
34
|
-
// arrowdownwardregular
|
|
35
|
-
`${nameTrimmed.replace(/_/g, "")}regular`,
|
|
36
|
-
// arrowdownwardfill
|
|
37
|
-
`${nameTrimmed.replace(/_/g, "")}fill`,
|
|
38
|
-
];
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
for (const file of files) {
|
|
42
|
-
if (typeof file !== "string") continue;
|
|
43
|
-
if (file.includes("node_modules/")) continue;
|
|
44
|
-
|
|
45
|
-
const fileNameLowered = file.split("/").pop().split(".")[0].toLowerCase();
|
|
46
|
-
if (extensionsToCheck.every((ext) => file.endsWith(ext) === false)) continue;
|
|
47
|
-
|
|
48
|
-
if (deprecatedIconFileNames.includes(fileNameLowered)) {
|
|
49
|
-
console.log(`Possible deprecated icon file found: ${file}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const extensionsToCheck = [".tsx", ".jsx", ".svg", ".png"];
|
|
56
|
-
|
|
57
|
-
const deprecatedIconNames = [
|
|
58
|
-
"icon_add",
|
|
59
|
-
"icon_add_circle",
|
|
60
|
-
"icon_aeb",
|
|
61
|
-
"icon_ai",
|
|
62
|
-
"icon_android_share",
|
|
63
|
-
"icon_arrow",
|
|
64
|
-
"icon_arrow_downward",
|
|
65
|
-
"icon_arrow_drop_down",
|
|
66
|
-
"icon_arrow_drop_up",
|
|
67
|
-
"icon_arrow_upward",
|
|
68
|
-
"icon_article",
|
|
69
|
-
"icon_backward",
|
|
70
|
-
"icon_bill",
|
|
71
|
-
"icon_bold",
|
|
72
|
-
"icon_bookmark",
|
|
73
|
-
"icon_bookmark_list",
|
|
74
|
-
"icon_calendar",
|
|
75
|
-
"icon_call",
|
|
76
|
-
"icon_call_declined",
|
|
77
|
-
"icon_camera",
|
|
78
|
-
"icon_car",
|
|
79
|
-
"icon_car_around_view",
|
|
80
|
-
"icon_car_blind_spot",
|
|
81
|
-
"icon_car_cruise_control",
|
|
82
|
-
"icon_car_epb",
|
|
83
|
-
"icon_car_heated_seat",
|
|
84
|
-
"icon_car_heated_steering_wheel",
|
|
85
|
-
"icon_car_ldws",
|
|
86
|
-
"icon_car_leather_seat",
|
|
87
|
-
"icon_car_navigation",
|
|
88
|
-
"icon_car_power_trunk",
|
|
89
|
-
"icon_car_rear_camera",
|
|
90
|
-
"icon_car_rear_sensor",
|
|
91
|
-
"icon_car_smart_key",
|
|
92
|
-
"icon_car_ventilation_seat",
|
|
93
|
-
"icon_cart",
|
|
94
|
-
"icon_certification",
|
|
95
|
-
"icon_challenge",
|
|
96
|
-
"icon_chart",
|
|
97
|
-
"icon_chat_bubble_check",
|
|
98
|
-
"icon_chatting",
|
|
99
|
-
"icon_chatting_send",
|
|
100
|
-
"icon_check",
|
|
101
|
-
"icon_check_flower",
|
|
102
|
-
"icon_chevron_left",
|
|
103
|
-
"icon_chevron_right",
|
|
104
|
-
"icon_click",
|
|
105
|
-
"icon_clock",
|
|
106
|
-
"icon_close",
|
|
107
|
-
"icon_cobuying",
|
|
108
|
-
"icon_community",
|
|
109
|
-
"icon_condo",
|
|
110
|
-
"icon_confirmation",
|
|
111
|
-
"icon_confirmation_pay",
|
|
112
|
-
"icon_confirmation_profile",
|
|
113
|
-
"icon_contents",
|
|
114
|
-
"icon_convert",
|
|
115
|
-
"icon_copy",
|
|
116
|
-
"icon_coupon",
|
|
117
|
-
"icon_coupon_download_done",
|
|
118
|
-
"icon_coupon_used",
|
|
119
|
-
"icon_delete_keyboard",
|
|
120
|
-
"icon_delivery",
|
|
121
|
-
"icon_direction",
|
|
122
|
-
"icon_download",
|
|
123
|
-
"icon_edit",
|
|
124
|
-
"icon_emoticon",
|
|
125
|
-
"icon_emoticon_bad",
|
|
126
|
-
"icon_expand",
|
|
127
|
-
"icon_expand_less",
|
|
128
|
-
"icon_expand_more",
|
|
129
|
-
"icon_file",
|
|
130
|
-
"icon_filter02",
|
|
131
|
-
"icon_forward",
|
|
132
|
-
"icon_gender",
|
|
133
|
-
"icon_global",
|
|
134
|
-
"icon_gps",
|
|
135
|
-
"icon_gps_enable",
|
|
136
|
-
"icon_gps_enable2",
|
|
137
|
-
"icon_groupchat_king",
|
|
138
|
-
"icon_handle",
|
|
139
|
-
"icon_hashtag",
|
|
140
|
-
"icon_headphone",
|
|
141
|
-
"icon_heart",
|
|
142
|
-
"icon_help",
|
|
143
|
-
"icon_helpcenter",
|
|
144
|
-
"icon_helper",
|
|
145
|
-
"icon_home",
|
|
146
|
-
"icon_house",
|
|
147
|
-
"icon_housekeeping_book",
|
|
148
|
-
"icon_import",
|
|
149
|
-
"icon_info",
|
|
150
|
-
"icon_interest",
|
|
151
|
-
"icon_interest_list",
|
|
152
|
-
"icon_invite",
|
|
153
|
-
"icon_invite_friend",
|
|
154
|
-
"icon_ios_share",
|
|
155
|
-
"icon_jobs",
|
|
156
|
-
"icon_keyboard_hiding",
|
|
157
|
-
"icon_keyword",
|
|
158
|
-
"icon_laptop",
|
|
159
|
-
"icon_leaf",
|
|
160
|
-
"icon_list",
|
|
161
|
-
"icon_list_card",
|
|
162
|
-
"icon_list_check",
|
|
163
|
-
"icon_list_select",
|
|
164
|
-
"icon_list_thumbnail",
|
|
165
|
-
"icon_location",
|
|
166
|
-
"icon_lock",
|
|
167
|
-
"icon_loudspeaker",
|
|
168
|
-
"icon_map",
|
|
169
|
-
"icon_market",
|
|
170
|
-
"icon_market_check",
|
|
171
|
-
"icon_market_write",
|
|
172
|
-
"icon_mention",
|
|
173
|
-
"icon_menu",
|
|
174
|
-
"icon_mic",
|
|
175
|
-
"icon_mic_off",
|
|
176
|
-
"icon_mission",
|
|
177
|
-
"icon_mobile",
|
|
178
|
-
"icon_money_send",
|
|
179
|
-
"icon_money_won",
|
|
180
|
-
"icon_moon",
|
|
181
|
-
"icon_more_horiz",
|
|
182
|
-
"icon_more_vert",
|
|
183
|
-
"icon_my",
|
|
184
|
-
"icon_my_profile",
|
|
185
|
-
"icon_near_me",
|
|
186
|
-
"icon_newtopic",
|
|
187
|
-
"icon_note",
|
|
188
|
-
"icon_notification",
|
|
189
|
-
"icon_notification_fall",
|
|
190
|
-
"icon_notification_off",
|
|
191
|
-
"icon_order",
|
|
192
|
-
"icon_pause",
|
|
193
|
-
"icon_payment",
|
|
194
|
-
"icon_percent",
|
|
195
|
-
"icon_photo",
|
|
196
|
-
"icon_photo_edit",
|
|
197
|
-
"icon_photo_edit_crop",
|
|
198
|
-
"icon_photo_edit_draw",
|
|
199
|
-
"icon_photo_edit_rotate",
|
|
200
|
-
"icon_photo_several",
|
|
201
|
-
"icon_play",
|
|
202
|
-
"icon_poll",
|
|
203
|
-
"icon_price_won",
|
|
204
|
-
"icon_product",
|
|
205
|
-
"icon_profile",
|
|
206
|
-
"icon_profile_badge",
|
|
207
|
-
"icon_prohibition",
|
|
208
|
-
"icon_pushpin",
|
|
209
|
-
"icon_question_check",
|
|
210
|
-
"icon_redo",
|
|
211
|
-
"icon_refund",
|
|
212
|
-
"icon_remove_circle",
|
|
213
|
-
"icon_reply",
|
|
214
|
-
"icon_reply_mission",
|
|
215
|
-
"icon_reply_re",
|
|
216
|
-
"icon_report",
|
|
217
|
-
"icon_reservation",
|
|
218
|
-
"icon_restaurant",
|
|
219
|
-
"icon_retry",
|
|
220
|
-
"icon_review_star",
|
|
221
|
-
"icon_scanner",
|
|
222
|
-
"icon_search",
|
|
223
|
-
"icon_search_doc",
|
|
224
|
-
"icon_sell",
|
|
225
|
-
"icon_setting",
|
|
226
|
-
"icon_signout",
|
|
227
|
-
"icon_sort",
|
|
228
|
-
"icon_story",
|
|
229
|
-
"icon_story_article",
|
|
230
|
-
"icon_subtract_circle",
|
|
231
|
-
"icon_subtraction",
|
|
232
|
-
"icon_suggest",
|
|
233
|
-
"icon_sun",
|
|
234
|
-
"icon_talkingdown",
|
|
235
|
-
"icon_talkingup",
|
|
236
|
-
"icon_text",
|
|
237
|
-
"icon_thumb_down",
|
|
238
|
-
"icon_thumb_up",
|
|
239
|
-
"icon_toolbox",
|
|
240
|
-
"icon_translate",
|
|
241
|
-
"icon_trash",
|
|
242
|
-
"icon_undo",
|
|
243
|
-
"icon_user_group",
|
|
244
|
-
"icon_video",
|
|
245
|
-
"icon_view_count",
|
|
246
|
-
"icon_view_count_off",
|
|
247
|
-
"icon_volume_off",
|
|
248
|
-
"icon_volume_on",
|
|
249
|
-
"icon_vote",
|
|
250
|
-
"icon_voucher",
|
|
251
|
-
"icon_walk",
|
|
252
|
-
"icon_warning",
|
|
253
|
-
"icon_write",
|
|
254
|
-
"icon_write_frequent_use",
|
|
255
|
-
"icon_write_story",
|
|
256
|
-
];
|