@seed-design/cli 1.2.2 → 1.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.mjs +12 -11
- package/package.json +1 -1
- package/src/commands/add-all.ts +9 -3
- package/src/commands/add.ts +9 -3
- package/src/commands/compat.ts +15 -7
- package/src/commands/docs.ts +312 -0
- package/src/commands/init.ts +9 -2
- package/src/index.ts +2 -0
- package/src/schema.ts +46 -10
- package/src/tests/resolve-dependencies.test.ts +13 -13
- package/src/utils/analytics.ts +1 -2
- package/src/utils/compatibility.ts +38 -11
- package/src/utils/fetch.ts +39 -6
- package/src/utils/get-config.ts +1 -0
- package/src/utils/init-config.ts +29 -1
- package/src/utils/write.ts +3 -0
package/bin/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import*as
|
|
3
|
-
[verbose] stack trace`)),
|
|
4
|
-
`,"utf-8"),{relativePath:
|
|
5
|
-
${
|
|
6
|
-
`)}`),
|
|
7
|
-
${
|
|
8
|
-
`),D.log.message(R),D.select({message:"\uD604\uC7AC \uD30C\uC77C\uC5D0 \uC2A4\uD0C0\uC77C \uBCC0\uACBD, \uB85C\uAE45 \uB4F1 \uCEE4\uC2A4\uD130\uB9C8\uC774\uC9D5\uC774 \uC801\uC6A9\uB418\uC5B4 \uC788\uB294 \uACBD\uC6B0 \uC2E0\uADDC \uD30C\uC77C\uC5D0 \uB3D9\uC77C\uD55C \uCEE4\uC2A4\uD130\uB9C8\uC774\uC9D5\uC744 \uC801\uC6A9\uD558\uB294 \uAC83\uC744 \uAC80\uD1A0\uD574\uBCF4\uC138\uC694.",options:[{value:"overwrite",label:`${V} \uB36E\uC5B4\uC4F0\uAE30`},{value:"backup",label:`\uAE30\uC874 \uD30C\uC77C \uB0B4\uC6A9\uC744 ${I}\uC73C\uB85C \uC62E\uAE30\uACE0 ${V} \uBC1B\uAE30`},{value:"skip",label:"\uC0C8 \uD30C\uC77C \uBC1B\uC9C0 \uC54A\uACE0 \uADF8\uB300\uB85C \uB450\uAE30"}]})})();if(D.isCancel(p)||p==="skip"){D.log.info(`${a(v)}: \uD30C\uC77C\uC744 \uBC1B\uC9C0 \uC54A\uACE0 \uAC74\uB108\uB6F0\uC5C8\uC5B4\uC694.`);continue}if(p==="backup"){let m=M.dirname(g),R=M.join(m,I);await re.rename(g,R),D.log.info(`${a(v)}: \uAE30\uC874 \uD30C\uC77C\uC744 ${a(M.relative(r,R))}\uB85C \uC62E\uACBC\uC5B4\uC694.`)}}await re.writeFile(g,w),y.push(f)}if(y.length>0){let f=y.map(({name:g,relativePath:w})=>({name:g,path:w}));o.push(...f),D.log.success(`${a(`${c}:${b}`)} \uAD00\uB828 \uC2A4\uB2C8\uD3AB \uB2E4\uC6B4\uB85C\uB4DC \uC644\uB8CC: ${a(f.map(g=>g.path).join(", "))}`)}}}}import*as C from"@clack/prompts";import Dt from"path";import{z as X}from"zod";var ie="https://seed-design.io";import*as Te from"@clack/prompts";import{execa as ht}from"execa";import{detect as dt}from"@antfu/ni";async function je(e){let t=await dt({programmatic:!0,cwd:e});return t==="yarn@berry"?"yarn":t==="pnpm@6"?"pnpm":t==="bun"?"bun":t==="deno"?"deno":t??"npm"}import ft from"findup-sync";import gt from"fs-extra";var ut="package.json";function yt(e=process.cwd()){let t=ft(ut,{cwd:e});if(!t)throw new Error("No package.json file found in the project.");return t}function se(e=process.cwd()){let t=yt(e);return gt.readJSONSync(t)}async function ye({cwd:e,deps:t,dev:r=!1}){let{start:s,stop:n}=Te.spinner(),i=await je(e),c={...se(e).dependencies},l=new Set(t.filter(y=>!c[y])),d=new Set(t.filter(y=>c[y]));if(!l.size)return{installed:new Set,filtered:l};s("\uC758\uC874\uC131 \uC124\uCE58\uC911...");let $=[i==="npm"?"install":"add",r?"-D":null,...l].filter(Boolean),k=`${i} ${$.join(" ")}`;try{await ht(i,$,{cwd:e})}catch(y){throw n("\uC758\uC874\uC131 \uC124\uCE58\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."),new x({message:"\uC758\uC874\uC131 \uC124\uCE58\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",hint:"\uB124\uD2B8\uC6CC\uD06C \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uACE0, \uC124\uCE58 \uBA85\uB839\uC5B4\uB97C \uC9C1\uC811 \uC2E4\uD589\uD574 \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",details:[`\uC2E4\uD589 \uBA85\uB839\uC5B4: ${k}`],cause:y})}return n("\uC758\uC874\uC131 \uC124\uCE58\uAC00 \uC644\uB8CC\uB410\uC5B4\uC694."),{installed:l,filtered:d}}import{randomUUID as wt}from"node:crypto";import*as De from"@clack/prompts";var bt="seed_cli";async function It(e){if(process.env.DISABLE_TELEMETRY==="true"||process.env.SEED_DISABLE_TELEMETRY==="true")return!1;try{if((await pe(e))?.telemetry===!1)return!1}catch{}return!0}function Ct(){return wt()}var $t=Ct(),_e=!1;async function Pt(e,{event:t,properties:r={}}){if(!await It(e))return;let n=`${bt}.${t}`;_e||(De.log.info("\u{1F4CA} \uC0AC\uC6A9 \uB370\uC774\uD130 \uC218\uC9D1 \uC911 (\uBE44\uD65C\uC131\uD654: seed-design.json \uB610\uB294 DISABLE_TELEMETRY \uD658\uACBD \uBCC0\uC218)"),_e=!0);try{let i="https://us.i.posthog.com/capture",o={"Content-Type":"application/json"},c={api_key:"phc_seod8HhifElOP1R92KmvsQybrtUmkOTgZBsq0mfCelR",event:n,distinct_id:$t,properties:{...r,$process_person_profile:!1},timestamp:new Date().toISOString()},l=new AbortController,d=setTimeout(()=>l.abort(),5e3);try{await fetch(i,{method:"POST",headers:o,body:JSON.stringify(c),signal:l.signal})}finally{clearTimeout(d)}}catch{}}var z={track:Pt};import*as Y from"@clack/prompts";import xt from"fs-extra";import Rt from"path";import{intersects as kt,satisfies as Et,valid as Me,validRange as Ke}from"semver";var le=["@seed-design/react","@seed-design/css"],Oe="workspace:",St="npm:";function oe(e){try{let t=se(e),r={...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies},s={};for(let n of le){let i=r[n];typeof i=="string"&&(s[n]=i)}return s}catch{return{}}}function ne({publicRegistries:e,itemKeys:t,projectPackageVersions:r}){let s=Array.from(new Set(t)),n=new Map(e.flatMap(o=>o.items.map(c=>[`${o.id}:${c.id}`,c]))),i=[];for(let o of s){let c=n.get(o);if(!c)continue;let l=vt(c);for(let d of le){let h=Array.from(l[d]??[]);if(!h.length)continue;let b=r[d];if(!b){i.push({itemKey:o,packageName:d,requiredRanges:h,type:"missing-package"});continue}let $=At(b);if(!$){i.push({itemKey:o,packageName:d,requiredRanges:h,installedVersionSpec:b,type:"invalid-version-spec"});continue}h.every(y=>jt({currentVersionSpec:$,requiredRange:y}))||i.push({itemKey:o,packageName:d,requiredRanges:h,installedVersionSpec:b,type:"incompatible-version"})}}return{checkedItemKeys:s,projectPackageVersions:r,issues:i}}function ae({report:e,title:t}){if(!e.issues.length)return;Y.log.warn(t),Y.log.info(`\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804: ${le.map(s=>`${s}@${a(e.projectPackageVersions[s]??"\uBBF8\uC124\uCE58")}`).join(", ")}`);let r=new Map;for(let s of e.issues){let n=r.get(s.itemKey)??[];n.push(s),r.set(s.itemKey,n)}for(let[s,n]of r.entries()){Y.log.warn(a(s));for(let i of n){let o=i.requiredRanges.join(" | ");if(i.type==="missing-package"){Y.log.info(` - ${i.packageName}: \uD328\uD0A4\uC9C0\uAC00 \uC124\uCE58\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC544\uC694. \uD544\uC694 \uBC94\uC704: ${o}`);continue}if(i.type==="invalid-version-spec"){Y.log.info(` - ${i.packageName}: \uD604\uC7AC \uBC84\uC804 \uD615\uC2DD\uC744 \uD574\uC11D\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694 (${i.installedVersionSpec}). \uD544\uC694 \uBC94\uC704: ${o}`);continue}Y.log.info(` - ${i.packageName}: \uD604\uC7AC ${i.installedVersionSpec}, \uD544\uC694 \uBC94\uC704 ${o}`)}}}function Ne({publicRegistries:e,rootPath:t}){let r=[];for(let s of e)for(let n of s.items)n.snippets.some(o=>Tt(o.path).some(c=>xt.existsSync(Rt.join(t,s.id,c))))&&r.push(`${s.id}:${n.id}`);return r}function vt(e){let t=Object.fromEntries(le.map(r=>[r,new Set]));for(let r of e.snippets)for(let[s,n]of Object.entries(r.dependencies??{}))_t(s)&&t[s].add(n);return t}function At(e){let t=e.trim();if(t.startsWith(Oe)&&(t=t.slice(Oe.length).trim()),t.startsWith(St)){let r=t.split("@").at(-1);if(!r)return null;t=r}return!t||t==="*"?null:Me(t)||Ke(t)?t:null}function jt({currentVersionSpec:e,requiredRange:t}){let r=Ke(t);return r?Me(e)?Et(e,r,{includePrerelease:!0}):kt(e,r,{includePrerelease:!0}):!1}function Tt(e){let t=new Set([e]);return e.endsWith(".tsx")&&t.add(`${e.slice(0,-4)}.jsx`),e.endsWith(".ts")&&t.add(`${e.slice(0,-3)}.js`),e.endsWith(".jsx")&&t.add(`${e.slice(0,-4)}.tsx`),e.endsWith(".js")&&t.add(`${e.slice(0,-3)}.ts`),Array.from(t)}function _t(e){return le.includes(e)}var Ot=X.object({itemIds:X.array(X.string()).optional(),all:X.boolean(),cwd:X.string(),baseUrl:X.string().optional(),onDiff:X.enum(["overwrite","backup"]).optional()}),Fe=e=>{e.command("add [...item-ids]","add items").option("-a, --all","[Deprecated] Add all items",{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:ie}).option("--on-diff <mode>","Action when file differs: overwrite or backup").example("seed-design add ui:action-button").example("seed-design add ui:alert-dialog").action(async(t,r)=>{let s=Date.now(),n=L(r);C.intro("seed-design add");try{let i=Ot.safeParse({itemIds:t,...r});if(!i.success)throw i.error;let{data:{all:o,...c}}=i;if(o)throw new x({message:"`--all` \uC635\uC158\uC740 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC544\uC694. \uB300\uC2E0 `seed-design add-all` \uBA85\uB839\uC5B4\uB97C \uC0AC\uC6A9\uD574\uC8FC\uC138\uC694."});let l=c.cwd,d=c.baseUrl,h=await de(l),b=Dt.resolve(l,h.path),{start:$,stop:k}=C.spinner();$("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let y=await(async()=>{try{let p=await Promise.all((await ee({baseUrl:d})).map(async({id:m})=>te({baseUrl:d,registryId:m})));return k("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),p}catch(p){throw k("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),p}})(),f=await(async()=>{if(c.itemIds?.length)return c.itemIds;let p=await C.multiselect({message:"\uCD94\uAC00\uD560 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694 (\uC2A4\uD398\uC774\uC2A4 \uBC14\uB85C \uC5EC\uB7EC \uAC1C \uC120\uD0DD \uAC00\uB2A5)",options:y.filter(({hideFromCLICatalog:m})=>!m).flatMap(({id:m,items:R})=>R.filter(({hideFromCLICatalog:T})=>!T).sort((T,A)=>T.id.localeCompare(A.id)).map(({id:T,description:A,deprecated:N})=>({label:`${N?"(deprecated) ":""}${a(m)}:${T}`,value:`${m}:${T}`,hint:A,deprecated:N,registryItemCount:R.length}))).sort((m,R)=>m.deprecated!==R.deprecated?m.deprecated?1:-1:R.registryItemCount-m.registryItemCount)});if(C.isCancel(p))throw new E;return p})();if(!f?.length)throw new E("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC5B4\uC694.");C.log.message(`\uC120\uD0DD\uB41C \uD56D\uBAA9: ${a(f.join(", "))}`);let g=[];for(let p of f){let[m,...R]=p.split(":"),T=R.join(":");if(!m||!T)throw new x({message:`${a(p)}: \uD56D\uBAA9 \uC774\uB984\uC774 \uC798\uBABB\uB418\uC5C8\uC5B4\uC694.`,hint:`${a("ui:action-button")}\uACFC \uAC19\uC740 \uD615\uC2DD\uC73C\uB85C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});let A=y.find(N=>N.id===m)?.items.find(N=>N.id===T);if(!A)throw new x({message:`${a(p)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});if(A.deprecated){let N=await C.confirm({message:`${a(A.id)}: deprecated \uB418\uC5C8\uC5B4\uC694. \uCD94\uAC00\uD560\uAE4C\uC694?`,initialValue:!1});if(C.isCancel(N))throw new E;if(N===!1){C.log.info(`${a(A.id)}: \uCD94\uAC00\uD558\uC9C0 \uC54A\uC744\uAC8C\uC694.`);continue}}g.push(p)}let{registryItemsToAdd:w,npmDependenciesToAdd:v}=fe({selectedItemKeys:g,publicRegistries:y}),J=ne({publicRegistries:y,itemKeys:w.flatMap(({registryId:p,items:m})=>m.map(R=>`${p}:${R.id}`)),projectPackageVersions:oe(c.cwd)});ae({report:J,title:"\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804\uACFC \uD638\uD658\uB418\uC9C0 \uC54A\uC744 \uC218 \uC788\uB294 \uC2A4\uB2C8\uD3AB\uC774 \uC788\uC5B4\uC694."}),C.log.info(`\uCD94\uAC00\uD560 \uD56D\uBAA9: ${a(w.map(p=>p.items.map(m=>`${p.registryId}:${m.id}`).join(", ")).join(", ")||"\uC5C6\uC74C")}
|
|
2
|
+
import*as re from"@clack/prompts";import{cosmiconfig as pt}from"cosmiconfig";import{z as te}from"zod";import*as W from"@clack/prompts";import{ZodError as tt}from"zod";import et from"picocolors";var p=e=>et.cyan(e);var P=class extends Error{hint;details;constructor({message:t,hint:r,details:n=[],cause:o}){super(t,{cause:o}),this.name="CliError",this.hint=r,this.details=n}},E=class extends Error{constructor(t="\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694."){super(t),this.name="CliCancelError"}};function F(e){return e instanceof E}function z(e){return!e||typeof e!="object"||!("verbose"in e)?!1:e.verbose===!0}function rt(e,t){if(e instanceof P)return{reason:e.message,hint:e.hint??t,details:e.details,stack:st(e.cause??e)};if(e instanceof tt){let r=e.issues.map(n=>`${n.path.join(".")||"(root)"}: ${n.message}`);return{reason:"\uC785\uB825\uAC12 \uB610\uB294 \uC124\uC815 \uD30C\uC77C \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC544\uC694.",hint:t,details:r,stack:e.stack}}if(e instanceof Error){let r=e,n=[];return(r.escapedCommand||r.command)&&n.push(`\uC2E4\uD589 \uBA85\uB839\uC5B4: ${r.escapedCommand??r.command}`),typeof r.exitCode=="number"&&n.push(`\uC885\uB8CC \uCF54\uB4DC: ${r.exitCode}`),r.stderr?.trim()?n.push(`stderr: ${r.stderr.trim()}`):r.stdout?.trim()&&n.push(`stdout: ${r.stdout.trim()}`),{reason:r.shortMessage??e.message,hint:t,details:n,stack:e.stack}}return typeof e=="string"?{reason:e,hint:t,details:[]}:{reason:"\uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC5B4\uC694.",hint:t,details:[]}}function st(e){if(e instanceof Error)return e.stack}function V(e,{defaultMessage:t,defaultHint:r,verbose:n=!1}){let o=rt(e,r);W.log.error(t),W.log.error(`\uC6D0\uC778: ${o.reason}`);for(let s of o.details)W.log.info(s);o.hint&&W.log.info(`\uD574\uACB0 \uD78C\uD2B8: ${o.hint}`),n&&o.stack&&(W.log.message(p(`
|
|
3
|
+
[verbose] stack trace`)),W.log.message(o.stack)),W.outro(p("\uC791\uC5C5\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."))}import*as q from"@clack/prompts";import ct from"fs-extra";import Se from"path";import it from"findup-sync";import ot from"fs-extra";var nt="package.json";function at(e=process.cwd()){let t=it(nt,{cwd:e});if(!t)throw new Error("No package.json file found in the project.");return t}function Q(e=process.cwd()){let t=at(e);return ot.readJSONSync(t)}var K={rsc:!1,tsx:!0,framework:"react",path:"./seed-design",telemetry:!0};function $e(e){try{let t=Q(e),r={...t.dependencies,...t.devDependencies,...t.peerDependencies};if("@lynx-js/react"in r||"@seed-design/lynx-react"in r)return"lynx"}catch{}return"react"}async function Re(e){let t=$e(e);return await q.group({tsx:()=>q.confirm({message:`${p("TypeScript")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:K.tsx}),rsc:()=>q.confirm({message:`${p("React Server Components")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:K.rsc}),framework:()=>q.select({message:`\uC5B4\uB5A4 ${p("\uD504\uB808\uC784\uC6CC\uD06C")}\uB97C \uC0AC\uC6A9\uD558\uC2DC\uB098\uC694?`,initialValue:t,options:[{value:"react",label:"React"},{value:"lynx",label:"Lynx"}]}),path:()=>q.text({message:`${p("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:K.path,defaultValue:K.path,placeholder:K.path}),telemetry:()=>q.confirm({message:`\uAC1C\uC120\uC744 \uC704\uD574 ${p("\uC775\uBA85 \uC0AC\uC6A9 \uB370\uC774\uD130")}\uB97C \uC218\uC9D1\uD560\uAE4C\uC694?`,initialValue:K.telemetry})},{onCancel:()=>{throw new E}})}async function ge({cwd:e,config:t}){let r=Se.resolve(e,"seed-design.json");return await ct.writeFile(r,`${JSON.stringify(t,null,2)}
|
|
4
|
+
`,"utf-8"),{relativePath:Se.relative(process.cwd(),r),targetPath:r}}var Ee="seed-design",lt=pt(Ee,{searchPlaces:[`${Ee}.json`]}),ve=te.object({$schema:te.string().optional(),rsc:te.coerce.boolean().default(!1),tsx:te.coerce.boolean().default(!0),framework:te.enum(["react","lynx"]).default("react"),path:te.string(),telemetry:te.coerce.boolean().optional().default(!0)}).strict();async function ue(e){let t=await oe(e);if(t)return t;re.log.error("\uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8 \uACBD\uB85C\uC5D0 `seed-design.json` \uD30C\uC77C\uC774 \uC5C6\uC5B4\uC694.");let r=await re.confirm({message:"seed-design.json \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uC2DC\uACA0\uC5B4\uC694?"});if(re.isCancel(r)||!r)throw new E;try{return await ge({cwd:e,config:K}),re.log.message("seed-design.json \uD30C\uC77C\uC774 \uC0DD\uC131\uB410\uC5B4\uC694."),ve.parse(K)}catch(n){throw new P({message:"seed-design.json \uD30C\uC77C \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",hint:"\uB514\uB809\uD1A0\uB9AC \uC4F0\uAE30 \uAD8C\uD55C\uACFC \uACBD\uB85C\uB97C \uD655\uC778\uD55C \uB4A4 \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uBCF4\uC138\uC694.",cause:n})}}async function oe(e){let t=await lt.search(e);if(!t||t.isEmpty)return null;try{return ve.parse(t.config)}catch(r){throw new P({message:"seed-design.json \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC544\uC694.",hint:"https://seed-design.com/react/getting-started/cli/configuration \uBB38\uC11C\uB97C \uCC38\uACE0\uD574 \uC8FC\uC138\uC694.",cause:r})}}function ye({selectedItemKeys:e,publicRegistries:t}){let r=[],n=new Set;function o(s,i){let c=r.find(a=>a.registryId===s);if(!c?.items.some(a=>a.id===i.id)){if(c?c.items.push(i):r.push({registryId:s,items:[i]}),i.dependencies?.length)for(let a of i.dependencies)n.add(a);if(i.innerDependencies?.length)for(let a of i.innerDependencies)for(let w of a.itemIds){let C=t.find($=>$.id===a.registryId)?.items.find($=>$.id===w);if(!C)throw new Error(`Cannot find dependency item: ${a.registryId}:${w}`);o(a.registryId,C)}}}for(let s of e){let[i,...c]=s.split(":"),a=c.join(":");if(!i||!a)throw new Error(`Invalid snippet format: "${s}"`);let w=t.find(C=>C.id===i)?.items.find(C=>C.id===a);if(!w)throw new Error(`Cannot find snippet: "${s}"`);o(i,w)}return{registryItemsToAdd:r,npmDependenciesToAdd:n}}import*as Pe from"@clack/prompts";import{z as l}from"zod";var xe=l.object({id:l.string(),description:l.string().optional(),deprecated:l.boolean().optional(),hideFromCLICatalog:l.boolean().optional(),dependencies:l.array(l.string()).optional(),innerDependencies:l.array(l.object({registryId:l.string(),itemIds:l.array(l.string())})).optional(),snippets:l.array(l.object({path:l.string(),dependencies:l.record(l.string(),l.string()).optional(),content:l.string()}))}),Ie=l.object({id:l.string(),hideFromCLICatalog:l.boolean().optional(),items:l.array(xe.omit({snippets:!0}).extend({snippets:l.array(l.object({path:l.string(),dependencies:l.record(l.string(),l.string()).optional()}))}))}),Ae=l.array(l.object({id:l.string()})),mt=l.object({label:l.string(),path:l.string()}),dt=l.object({id:l.string(),title:l.string(),description:l.string().optional(),docUrl:l.string(),deprecated:l.boolean().optional(),snippetKey:l.string().optional(),snippets:l.array(mt).optional()}),ft=l.object({id:l.string(),label:l.string(),items:l.array(dt)}),gt=l.object({id:l.string(),label:l.string(),sections:l.array(ft)}),je=l.object({categories:l.array(gt)});async function Te({baseUrl:e}){let t=await fetch(`${e}/__docs__/index.json`);if(!t.ok)throw new P({message:`\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694: ${t.status} ${t.statusText}`});let r=await t.json(),{success:n,data:o,error:s}=je.safeParse(r);if(!n)throw new P({message:`\uBB38\uC11C \uBAA9\uB85D \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694: ${s?.message}`});return o}async function ne({baseUrl:e,framework:t}){let r=await fetch(`${e}/__registry__/${t}/index.json`);if(!r.ok)throw new Error(`Failed to fetch registries: ${r.status} ${r.statusText}`);let n=await r.json(),{success:o,data:s,error:i}=Ae.safeParse(n);if(!o)throw new Error(`Failed to parse registries: ${i?.message}`);return s}async function ae({baseUrl:e,framework:t,registryId:r}){let n=await fetch(`${e}/__registry__/${t}/${r}/index.json`);if(!n.ok)throw new Error(`Failed to fetch ${r} registry: ${n.status} ${n.statusText}`);let o=await n.json(),{success:s,data:i,error:c}=Ie.safeParse(o);if(!s)throw new Error(`Failed to parse ${r} registry: ${c?.message}`);return i}async function ut({baseUrl:e,framework:t,registryId:r,registryItemId:n}){let o=await fetch(`${e}/__registry__/${t}/${r}/${n}.json`);if(!o.ok)throw new Error(`Failed to fetch ${n}: ${o.status} ${o.statusText}`);let s=await o.json(),{success:i,data:c,error:a}=xe.safeParse(s);if(!i)throw new Error(`Failed to parse ${n}: ${a?.message}`);return c}async function _e({baseUrl:e,framework:t,registryId:r,registryItemIds:n}){return await Promise.all(n.map(async o=>{try{return await ut({baseUrl:e,framework:t,registryId:r,registryItemId:o})}catch(s){let i=await fetch(`${e}/__registry__/${t}/${r}/index.json`);if(!i.ok)throw new Error(`${r} \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694: ${i.status} ${i.statusText}`);let c=await i.json(),{success:a,data:w}=Ie.safeParse(c);throw a?(Pe.log.error(`${o} \uC2A4\uB2C8\uD3AB\uC774 ${r} \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC5C6\uC5B4\uC694.`),Pe.log.info(`${r} \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC874\uC7AC\uD558\uB294 \uC2A4\uB2C8\uD3AB:
|
|
5
|
+
${w.items.map(C=>C.id).join(`
|
|
6
|
+
`)}`),s):new Error(`Failed to parse registry index for ${r}`)}}))}import{promises as $t}from"fs";import{tmpdir as xt}from"os";import Me from"path";import{transformFromAstSync as yt}from"@babel/core";import ht from"@babel/plugin-transform-typescript";import*as he from"recast";import{parse as wt}from"@babel/parser";var bt={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"]},De=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let n=he.parse(r,{parser:{parse:s=>wt(s,bt)}}),o=yt(n,r,{cloneInputAst:!1,code:!1,ast:!0,plugins:[ht],configFile:!1});if(!o||!o.ast)throw new Error("Failed to transform JSX");return he.print(o.ast).code};import{SyntaxKind as Ct}from"ts-morph";var Oe=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(Ct.ExpressionStatement);if(!r)return e;let n=r.getExpression();if(!n)return e;let o=n.getText().trim();if(o!=='"use client"'&&o!=="'use client'")return e;let s=r.getText(),i=r.getFullText();if(s.trim()===i.trim())return e;let a=i.replace(s,"").replace(/^\s*\n/,"").replace(/\n\s*$/,"");return r.replaceWithText(a),e};import{Project as It,ScriptKind as Pt}from"ts-morph";var kt=[Oe],St=new It({compilerOptions:{}});async function Rt(e){let t=await $t.mkdtemp(Me.join(xt(),"seed-design-"));return Me.join(t,e)}async function Ke(e){let t=await Rt(e.filename),r=St.createSourceFile(t,e.raw,{scriptKind:Pt.TSX});for(let n of kt)n({sourceFile:r,...e});return await De({sourceFile:r,...e})}import*as L from"@clack/prompts";import ce from"fs-extra";import B from"path";import{createPatch as Et}from"diff";import vt from"@npmcli/disparity-colors";async function we({registryItemsToAdd:e,rootPath:t,cwd:r,baseUrl:n,framework:o,config:s,onDiff:i}){let c=[];for(let{registryId:a,items:w}of e){let C=B.join(t,a);ce.ensureDirSync(C);let $=await _e({baseUrl:n,framework:o,registryId:a,registryItemIds:w.map(u=>u.id)});for(let{id:u,snippets:A}of $){let g=await Promise.all(A.map(async f=>{let h=await Ke({filename:f.path,config:s,raw:f.content}),d=B.join(C,f.path);return s.tsx||(d=d.replace(/\.tsx$/,".jsx"),d=d.replace(/\.ts$/,".js")),{filePath:d,content:h,relativePath:B.relative(r,d),name:`${a}:${u}`}})),x=[];for(let f of g){let{filePath:h,content:d,relativePath:b}=f;if(await ce.ensureDir(B.dirname(h)),ce.existsSync(h)){let I=await ce.readFile(h,"utf-8");if(I===d){L.log.info(`${p(b)}: \uC774\uBBF8 \uCD5C\uC2E0 \uC0C1\uD0DC\uC608\uC694.`);continue}let U=B.basename(h),H=B.extname(h),ie=B.basename(h,H),de=Date.now(),k=`legacy-${ie}-${de}${H}`,m=await(async()=>{if(i)return i;let y=Et(b,I,d),j=vt(y);return L.log.message(`
|
|
7
|
+
${p(b)}: \uD604\uC7AC \uD30C\uC77C\uACFC \uBC1B\uC73C\uB824\uB294 \uD30C\uC77C\uC758 \uB0B4\uC6A9\uC774 \uB2EC\uB77C\uC694.
|
|
8
|
+
`),L.log.message(j),L.select({message:"\uD604\uC7AC \uD30C\uC77C\uC5D0 \uC2A4\uD0C0\uC77C \uBCC0\uACBD, \uB85C\uAE45 \uB4F1 \uCEE4\uC2A4\uD130\uB9C8\uC774\uC9D5\uC774 \uC801\uC6A9\uB418\uC5B4 \uC788\uB294 \uACBD\uC6B0 \uC2E0\uADDC \uD30C\uC77C\uC5D0 \uB3D9\uC77C\uD55C \uCEE4\uC2A4\uD130\uB9C8\uC774\uC9D5\uC744 \uC801\uC6A9\uD558\uB294 \uAC83\uC744 \uAC80\uD1A0\uD574\uBCF4\uC138\uC694.",options:[{value:"overwrite",label:`${U} \uB36E\uC5B4\uC4F0\uAE30`},{value:"backup",label:`\uAE30\uC874 \uD30C\uC77C \uB0B4\uC6A9\uC744 ${k}\uC73C\uB85C \uC62E\uAE30\uACE0 ${U} \uBC1B\uAE30`},{value:"skip",label:"\uC0C8 \uD30C\uC77C \uBC1B\uC9C0 \uC54A\uACE0 \uADF8\uB300\uB85C \uB450\uAE30"}]})})();if(L.isCancel(m)||m==="skip"){L.log.info(`${p(b)}: \uD30C\uC77C\uC744 \uBC1B\uC9C0 \uC54A\uACE0 \uAC74\uB108\uB6F0\uC5C8\uC5B4\uC694.`);continue}if(m==="backup"){let y=B.dirname(h),j=B.join(y,k);await ce.rename(h,j),L.log.info(`${p(b)}: \uAE30\uC874 \uD30C\uC77C\uC744 ${p(B.relative(r,j))}\uB85C \uC62E\uACBC\uC5B4\uC694.`)}}await ce.writeFile(h,d),x.push(f)}if(x.length>0){let f=x.map(({name:h,relativePath:d})=>({name:h,path:d}));c.push(...f),L.log.success(`${p(`${a}:${u}`)} \uAD00\uB828 \uC2A4\uB2C8\uD3AB \uB2E4\uC6B4\uB85C\uB4DC \uC644\uB8CC: ${p(f.map(h=>h.path).join(", "))}`)}}}}import*as S from"@clack/prompts";import Yt from"path";import{z as ee}from"zod";var G="https://seed-design.io";import*as Ne from"@clack/prompts";import{execa as jt}from"execa";import{detect as At}from"@antfu/ni";async function Le(e){let t=await At({programmatic:!0,cwd:e});return t==="yarn@berry"?"yarn":t==="pnpm@6"?"pnpm":t==="bun"?"bun":t==="deno"?"deno":t??"npm"}async function be({cwd:e,deps:t,dev:r=!1}){let{start:n,stop:o}=Ne.spinner(),s=await Le(e),c={...Q(e).dependencies},a=new Set(t.filter(g=>!c[g])),w=new Set(t.filter(g=>c[g]));if(!a.size)return{installed:new Set,filtered:a};n("\uC758\uC874\uC131 \uC124\uCE58\uC911...");let u=[s==="npm"?"install":"add",r?"-D":null,...a].filter(Boolean),A=`${s} ${u.join(" ")}`;try{await jt(s,u,{cwd:e})}catch(g){throw o("\uC758\uC874\uC131 \uC124\uCE58\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."),new P({message:"\uC758\uC874\uC131 \uC124\uCE58\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",hint:"\uB124\uD2B8\uC6CC\uD06C \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uACE0, \uC124\uCE58 \uBA85\uB839\uC5B4\uB97C \uC9C1\uC811 \uC2E4\uD589\uD574 \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",details:[`\uC2E4\uD589 \uBA85\uB839\uC5B4: ${A}`],cause:g})}return o("\uC758\uC874\uC131 \uC124\uCE58\uAC00 \uC644\uB8CC\uB410\uC5B4\uC694."),{installed:a,filtered:w}}import{randomUUID as Tt}from"node:crypto";import*as Fe from"@clack/prompts";var _t="seed_cli";async function Dt(e){if(process.env.DISABLE_TELEMETRY==="true"||process.env.SEED_DISABLE_TELEMETRY==="true")return!1;try{if((await oe(e))?.telemetry===!1)return!1}catch{}return!0}function Ot(){return Tt()}var Mt=Ot(),Ue=!1;async function Kt(e,{event:t,properties:r={}}){if(!await Dt(e))return;let o=`${_t}.${t}`;Ue||(Fe.log.info("\u{1F4CA} \uC0AC\uC6A9 \uB370\uC774\uD130 \uC218\uC9D1 \uC911 (\uBE44\uD65C\uC131\uD654: seed-design.json \uB610\uB294 DISABLE_TELEMETRY \uD658\uACBD \uBCC0\uC218)"),Ue=!0);try{let s="https://us.i.posthog.com/capture",i={"Content-Type":"application/json"},c={api_key:"phc_seod8HhifElOP1R92KmvsQybrtUmkOTgZBsq0mfCelR",event:o,distinct_id:Mt,properties:{...r,$process_person_profile:!1},timestamp:new Date().toISOString()},a=new AbortController,w=setTimeout(()=>a.abort(),5e3);try{await fetch(s,{method:"POST",headers:i,body:JSON.stringify(c),signal:a.signal})}finally{clearTimeout(w)}}catch{}}var N={track:Kt};import*as se from"@clack/prompts";import Lt from"fs-extra";import Nt from"path";import{intersects as Ut,satisfies as Ft,valid as Ve,validRange as qe}from"semver";var zt=["@seed-design/react","@seed-design/css"],Vt=["@seed-design/lynx-react","@seed-design/lynx-css"];function Z(e){return e==="lynx"?Vt:zt}var ze="workspace:",qt="npm:";function pe(e,t="react"){try{let r=Q(e),n={...r.dependencies,...r.devDependencies,...r.peerDependencies,...r.optionalDependencies},o={},s=Z(t);for(let i of s){let c=n[i];typeof c=="string"&&(o[i]=c)}return o}catch{return{}}}function le({publicRegistries:e,itemKeys:t,projectPackageVersions:r,framework:n="react"}){let o=Array.from(new Set(t)),s=new Map(e.flatMap(a=>a.items.map(w=>[`${a.id}:${w.id}`,w]))),i=[],c=Z(n);for(let a of o){let w=s.get(a);if(!w)continue;let C=Bt(w,n);for(let $ of c){let u=Array.from(C[$]??[]);if(!u.length)continue;let A=r[$];if(!A){i.push({itemKey:a,packageName:$,requiredRanges:u,type:"missing-package"});continue}let g=Gt(A);if(!g){i.push({itemKey:a,packageName:$,requiredRanges:u,installedVersionSpec:A,type:"invalid-version-spec"});continue}u.every(f=>Ht({currentVersionSpec:g,requiredRange:f}))||i.push({itemKey:a,packageName:$,requiredRanges:u,installedVersionSpec:A,type:"incompatible-version"})}}return{checkedItemKeys:o,projectPackageVersions:r,issues:i}}function me({report:e,title:t,framework:r="react"}){if(!e.issues.length)return;let n=Z(r);se.log.warn(t),se.log.info(`\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804: ${n.map(s=>`${s}@${p(e.projectPackageVersions[s]??"\uBBF8\uC124\uCE58")}`).join(", ")}`);let o=new Map;for(let s of e.issues){let i=o.get(s.itemKey)??[];i.push(s),o.set(s.itemKey,i)}for(let[s,i]of o.entries()){se.log.warn(p(s));for(let c of i){let a=c.requiredRanges.join(" | ");if(c.type==="missing-package"){se.log.info(` - ${c.packageName}: \uD328\uD0A4\uC9C0\uAC00 \uC124\uCE58\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC544\uC694. \uD544\uC694 \uBC94\uC704: ${a}`);continue}if(c.type==="invalid-version-spec"){se.log.info(` - ${c.packageName}: \uD604\uC7AC \uBC84\uC804 \uD615\uC2DD\uC744 \uD574\uC11D\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694 (${c.installedVersionSpec}). \uD544\uC694 \uBC94\uC704: ${a}`);continue}se.log.info(` - ${c.packageName}: \uD604\uC7AC ${c.installedVersionSpec}, \uD544\uC694 \uBC94\uC704 ${a}`)}}}function Be({publicRegistries:e,rootPath:t}){let r=[];for(let n of e)for(let o of n.items)o.snippets.some(i=>Jt(i.path).some(c=>Lt.existsSync(Nt.join(t,n.id,c))))&&r.push(`${n.id}:${o.id}`);return r}function Bt(e,t="react"){let r=Z(t),n=Object.fromEntries(r.map(o=>[o,new Set]));for(let o of e.snippets)for(let[s,i]of Object.entries(o.dependencies??{}))Wt(s,t)&&n[s].add(i);return n}function Gt(e){let t=e.trim();if(t.startsWith(ze)&&(t=t.slice(ze.length).trim()),t.startsWith(qt)){let r=t.split("@").at(-1);if(!r)return null;t=r}return!t||t==="*"?null:Ve(t)||qe(t)?t:null}function Ht({currentVersionSpec:e,requiredRange:t}){let r=qe(t);return r?Ve(e)?Ft(e,r,{includePrerelease:!0}):Ut(e,r,{includePrerelease:!0}):!1}function Jt(e){let t=new Set([e]);return e.endsWith(".tsx")&&t.add(`${e.slice(0,-4)}.jsx`),e.endsWith(".ts")&&t.add(`${e.slice(0,-3)}.js`),e.endsWith(".jsx")&&t.add(`${e.slice(0,-4)}.tsx`),e.endsWith(".js")&&t.add(`${e.slice(0,-3)}.ts`),Array.from(t)}function Wt(e,t="react"){return Z(t).includes(e)}var Xt=ee.object({itemIds:ee.array(ee.string()).optional(),all:ee.boolean(),cwd:ee.string(),baseUrl:ee.string().optional(),framework:ee.enum(["react","lynx"]).optional(),onDiff:ee.enum(["overwrite","backup"]).optional()}),Ge=e=>{e.command("add [...item-ids]","add items").option("-a, --all","[Deprecated] Add all items",{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:G}).option("-f, --framework <framework>","\uD504\uB808\uC784\uC6CC\uD06C (react \uB610\uB294 lynx)").option("--on-diff <mode>","Action when file differs: overwrite or backup").example("seed-design add ui:action-button").example("seed-design add ui:alert-dialog").action(async(t,r)=>{let n=Date.now(),o=z(r);S.intro("seed-design add");try{let s=Xt.safeParse({itemIds:t,...r});if(!s.success)throw s.error;let{data:{all:i,...c}}=s;if(i)throw new P({message:"`--all` \uC635\uC158\uC740 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC544\uC694. \uB300\uC2E0 `seed-design add-all` \uBA85\uB839\uC5B4\uB97C \uC0AC\uC6A9\uD574\uC8FC\uC138\uC694."});let a=c.cwd,w=c.baseUrl,C=await ue(a),$=c.framework??C.framework,u=Yt.resolve(a,C.path),{start:A,stop:g}=S.spinner();A("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let x=await(async()=>{try{let m=await Promise.all((await ne({baseUrl:w,framework:$})).map(async({id:y})=>ae({baseUrl:w,framework:$,registryId:y})));return g("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),m}catch(m){throw g("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),m}})(),f=await(async()=>{if(c.itemIds?.length)return c.itemIds;let m=await S.multiselect({message:"\uCD94\uAC00\uD560 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694 (\uC2A4\uD398\uC774\uC2A4 \uBC14\uB85C \uC5EC\uB7EC \uAC1C \uC120\uD0DD \uAC00\uB2A5)",options:x.filter(({hideFromCLICatalog:y})=>!y).flatMap(({id:y,items:j})=>j.filter(({hideFromCLICatalog:M})=>!M).sort((M,_)=>M.id.localeCompare(_.id)).map(({id:M,description:_,deprecated:J})=>({label:`${J?"(deprecated) ":""}${p(y)}:${M}`,value:`${y}:${M}`,hint:_,deprecated:J,registryItemCount:j.length}))).sort((y,j)=>y.deprecated!==j.deprecated?y.deprecated?1:-1:j.registryItemCount-y.registryItemCount)});if(S.isCancel(m))throw new E;return m})();if(!f?.length)throw new E("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC5B4\uC694.");S.log.message(`\uC120\uD0DD\uB41C \uD56D\uBAA9: ${p(f.join(", "))}`);let h=[];for(let m of f){let[y,...j]=m.split(":"),M=j.join(":");if(!y||!M)throw new P({message:`${p(m)}: \uD56D\uBAA9 \uC774\uB984\uC774 \uC798\uBABB\uB418\uC5C8\uC5B4\uC694.`,hint:`${p("ui:action-button")}\uACFC \uAC19\uC740 \uD615\uC2DD\uC73C\uB85C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});let _=x.find(J=>J.id===y)?.items.find(J=>J.id===M);if(!_)throw new P({message:`${p(m)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});if(_.deprecated){let J=await S.confirm({message:`${p(_.id)}: deprecated \uB418\uC5C8\uC5B4\uC694. \uCD94\uAC00\uD560\uAE4C\uC694?`,initialValue:!1});if(S.isCancel(J))throw new E;if(J===!1){S.log.info(`${p(_.id)}: \uCD94\uAC00\uD558\uC9C0 \uC54A\uC744\uAC8C\uC694.`);continue}}h.push(m)}let{registryItemsToAdd:d,npmDependenciesToAdd:b}=ye({selectedItemKeys:h,publicRegistries:x}),I=le({publicRegistries:x,itemKeys:d.flatMap(({registryId:m,items:y})=>y.map(j=>`${m}:${j.id}`)),projectPackageVersions:pe(c.cwd,$),framework:$});me({report:I,title:"\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804\uACFC \uD638\uD658\uB418\uC9C0 \uC54A\uC744 \uC218 \uC788\uB294 \uC2A4\uB2C8\uD3AB\uC774 \uC788\uC5B4\uC694.",framework:$}),S.log.info(`\uCD94\uAC00\uD560 \uD56D\uBAA9: ${p(d.map(m=>m.items.map(y=>`${m.registryId}:${y.id}`).join(", ")).join(", ")||"\uC5C6\uC74C")}
|
|
9
9
|
|
|
10
|
-
\uC124\uCE58\uD560 \uC758\uC874\uC131: ${a(Array.from(v).join(", ")||"\uC5C6\uC74C")}`),await ue({registryItemsToAdd:w,rootPath:b,cwd:l,baseUrl:d,config:h,onDiff:c.onDiff});let{installed:V,filtered:K}=await ye({cwd:l,deps:Array.from(v)});V.size===0&&C.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),V.size&&(C.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${a(Array.from(V).join(", "))}`),K.size&&C.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${a(Array.from(K).join(", "))}`)),C.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let Z=Date.now()-s,ce=new Set(w.map(p=>p.registryId)),I=f.some(p=>{let[m,...R]=p.split(":"),T=R.join(":");return y.find(A=>A.id===m)?.items.find(A=>A.id===T)?.deprecated});try{await z.track(c.cwd,{event:"add",properties:{items_count:g.length,registries:Array.from(ce),has_deprecated:I,dependencies_count:v.size,duration_ms:Z}})}catch(p){n&&console.error("[Telemetry] add tracking failed:",p)}}catch(i){U(i)&&(C.outro(a(i.message)),process.exit(0)),B(i,{defaultMessage:"\uCD94\uAC00\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:n}),process.exit(1)}})};import*as P from"@clack/prompts";import Mt from"path";import{z as H}from"zod";var Kt=H.object({registryIds:H.array(H.string()).optional(),all:H.boolean(),includeDeprecated:H.boolean().optional(),cwd:H.string(),baseUrl:H.string().optional(),onDiff:H.enum(["overwrite","backup"]).optional()}),ze=e=>{e.command("add-all [...registry-ids]","add all items from registries").option("-a, --all","Add all items from all registries",{default:!1}).option("--include-deprecated","Include deprecated items when used with `--all`",{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:ie}).option("--on-diff <mode>","Action when file differs: overwrite or backup").example("seed-design add-all ui --include-deprecated").example("seed-design add-all ui lib breeze").action(async(t,r)=>{let s=Date.now(),n=L(r);P.intro("seed-design add-all");try{let i=Kt.safeParse({registryIds:t,...r});if(!i.success)throw i.error;let{data:o}=i,c=o.cwd,l=o.baseUrl,d=await de(c),h=Mt.resolve(c,d.path),{start:b,stop:$}=P.spinner();b("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let k=await(async()=>{try{let I=await Promise.all((await ee({baseUrl:l})).map(async({id:p})=>te({baseUrl:l,registryId:p})));return $("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),I}catch(I){throw $("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),I}})(),y=await(async()=>{if(o.all){let p=k.map(m=>m.id);return P.log.message(`\uBAA8\uB4E0 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${a(p.join(", "))}`),p}if(o.registryIds?.length){let p=k.map(m=>m.id);for(let m of o.registryIds)if(!p.includes(m))throw new x({message:`\uB808\uC9C0\uC2A4\uD2B8\uB9AC '${m}'\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,details:[`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uB808\uC9C0\uC2A4\uD2B8\uB9AC: ${p.join(", ")}`]});return P.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${a(o.registryIds.join(", "))}`),o.registryIds}let I=await P.multiselect({message:"\uCD94\uAC00\uD560 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uB97C \uC120\uD0DD\uD574\uC8FC\uC138\uC694 (\uC2A4\uD398\uC774\uC2A4 \uBC14\uB85C \uC5EC\uB7EC \uAC1C \uC120\uD0DD \uAC00\uB2A5)",options:k.filter(({hideFromCLICatalog:p})=>!p).sort((p,m)=>m.items.length-p.items.length).map(p=>{let m=p.items[0]?.id,R=m?`${p.items.length}\uAC1C \uD56D\uBAA9 (${m} \uB4F1)`:`${p.items.length}\uAC1C \uD56D\uBAA9 (\uD56D\uBAA9 \uC5C6\uC74C)`;return{label:p.id,value:p.id,hint:R}})});if(P.isCancel(I))throw new E;return P.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${a(I.join(", "))}`),I})(),f=k.filter(I=>y.includes(I.id)),g=f.flatMap(I=>I.items.filter(p=>p.deprecated?o.includeDeprecated:!0).map(p=>`${I.id}:${p.id}`)),w=f.reduce((I,p)=>I+p.items.filter(m=>m.deprecated).length,0);if(!o.includeDeprecated&&w>0&&P.log.info(`${w}\uAC1C\uC758 deprecated \uD56D\uBAA9\uC740 \uC81C\uC678\uB418\uC5C8\uC5B4\uC694. --include-deprecated \uC635\uC158\uC744 \uC0AC\uC6A9\uD558\uBA74 \uCD94\uAC00\uD560 \uC218 \uC788\uC5B4\uC694.`),!g.length)throw new E("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694.");P.log.message(`\uCD1D ${a(g.length.toString())}\uAC1C\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4.`);let{registryItemsToAdd:v,npmDependenciesToAdd:J}=fe({selectedItemKeys:g,publicRegistries:k}),V=ne({publicRegistries:k,itemKeys:v.flatMap(({registryId:I,items:p})=>p.map(m=>`${I}:${m.id}`)),projectPackageVersions:oe(o.cwd)});ae({report:V,title:"\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804\uACFC \uD638\uD658\uB418\uC9C0 \uC54A\uC744 \uC218 \uC788\uB294 \uC2A4\uB2C8\uD3AB\uC774 \uC788\uC5B4\uC694."}),await ue({registryItemsToAdd:v,rootPath:h,cwd:c,baseUrl:l,config:d,onDiff:o.onDiff});let{installed:K,filtered:Z}=await ye({cwd:c,deps:Array.from(J)});K.size===0&&P.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),K.size&&(P.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${a(Array.from(K).join(", "))}`),Z.size&&P.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${a(Array.from(Z).join(", "))}`)),P.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let ce=Date.now()-s;try{await z.track(o.cwd,{event:"add-all",properties:{registries:y,items_count:g.length,include_deprecated:o.includeDeprecated||!1,dependencies_count:J.size,duration_ms:ce}})}catch(I){n&&console.error("[Telemetry] add-all tracking failed:",I)}}catch(i){U(i)&&(P.outro(a(i.message)),process.exit(0)),B(i,{defaultMessage:"\uCD94\uAC00\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:n}),process.exit(1)}})};import*as S from"@clack/prompts";import Ve from"path";import{z as O}from"zod";var Nt=O.object({itemIds:O.array(O.string()).optional(),component:O.union([O.string(),O.array(O.string())]).optional(),all:O.boolean(),registry:O.string().optional(),cwd:O.string(),baseUrl:O.string().optional()});function Ft({itemIds:e,component:t}){let r=i=>i.trim().replace(/\s+/g,"-"),s=(e??[]).map(r).filter(Boolean),n=(Array.isArray(t)?t:[t]).filter(i=>!!i).flatMap(i=>i.split(",")).map(r).filter(Boolean);return Array.from(new Set([...s,...n]))}function zt({publicRegistries:e,targetInputs:t,defaultRegistry:r}){let s=e.filter(i=>typeof i.id=="string"&&Array.isArray(i.items)).flatMap(i=>i.items.filter(o=>typeof o.id=="string").map(o=>`${i.id}:${o.id}`)),n=new Set;for(let i of t){let o=i.includes(":")?i:r?`${r}:${i}`:(()=>{let c=s.filter(l=>l.endsWith(`:${i}`));if(!c.length)throw new x({message:`${a(i)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:`${a("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});if(c.length>1)throw new x({message:`${a(i)}: \uAC19\uC740 \uC774\uB984\uC758 \uD56D\uBAA9\uC774 \uC5EC\uB7EC \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC788\uC5B4\uC694.`,details:c.map(l=>`- ${l}`),hint:`${a("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});return c[0]})();if(!s.includes(o))throw new x({message:`${a(o)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});n.add(o)}return Array.from(n)}var Ue=e=>{e.command("compat [...item-ids]","check snippet compatibility").option("-c, --component <component>","\uAC80\uC0AC\uD560 \uCEF4\uD3EC\uB10C\uD2B8. \uC5EC\uB7EC \uBC88 \uB610\uB294 \uC27C\uD45C\uB85C \uC9C0\uC815 \uAC00\uB2A5").option("-a, --all","\uBAA8\uB4E0 registry \uD56D\uBAA9\uC744 \uAC80\uC0AC",{default:!1}).option("-r, --registry <registryId>","\uCEF4\uD3EC\uB10C\uD2B8 shorthand \uC785\uB825 \uC2DC \uAE30\uBCF8 registry").option("--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:ie}).example("seed-design compat").example("seed-design compat -c action-button").example("seed-design compat ui:action-button ui:alert-dialog").example("seed-design compat --all").action(async(t,r)=>{let s=Date.now(),n=L(r);S.intro("seed-design compat");try{let i=Nt.safeParse({itemIds:t,...r});if(!i.success)throw i.error;let{data:o}=i,{start:c,stop:l}=S.spinner();c("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let d=await(async()=>{try{let f=await Promise.all((await ee({baseUrl:o.baseUrl})).map(async({id:g})=>te({baseUrl:o.baseUrl,registryId:g})));return l("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),f}catch(f){throw l("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),f}})(),h=Ft({itemIds:o.itemIds,component:o.component}),b=o.all?d.flatMap(g=>g.items.map(w=>`${g.id}:${w.id}`)):h.length>0?zt({publicRegistries:d,targetInputs:h,defaultRegistry:o.registry}):pe(o.cwd),$=Array.isArray(b)?b:await(async()=>{let f=await b;if(!f)throw new x({message:"seed-design.json \uD30C\uC77C\uC774 \uC5C6\uC5B4 \uC124\uCE58\uB41C \uC2A4\uB2C8\uD3AB \uACBD\uB85C\uB97C \uC54C \uC218 \uC5C6\uC5B4\uC694.",hint:"`seed-design init`\uC73C\uB85C \uC124\uC815\uC744 \uB9CC\uB4E0 \uB4A4 \uC2E4\uD589\uD558\uAC70\uB098, `--all`/`-c`\uB85C \uAC80\uC0AC \uB300\uC0C1\uC744 \uC9C1\uC811 \uC9C0\uC815\uD574\uC8FC\uC138\uC694."});let g=Ve.resolve(o.cwd,f.path),w=Ne({publicRegistries:d,rootPath:g});return w.length?w:(S.log.info(`${a(Ve.relative(o.cwd,g)||f.path)}\uC5D0\uC11C \uC124\uCE58\uB41C \uC2A4\uB2C8\uD3AB\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.`),[])})();$.length||(S.outro("\uAC80\uC0AC\uD560 \uC2A4\uB2C8\uD3AB\uC774 \uC5C6\uC5B4\uC694."),process.exit(0));let k=oe(o.cwd),y=ne({publicRegistries:d,itemKeys:$,projectPackageVersions:k});if(S.log.info(`\uAC80\uC0AC \uB300\uC0C1: ${a(y.checkedItemKeys.join(", "))}`),!y.issues.length){S.outro("\uBAA8\uB4E0 \uC2A4\uB2C8\uD3AB\uC774 \uD604\uC7AC @seed-design/react, @seed-design/css\uC640 \uD638\uD658\uB3FC\uC694.");try{await z.track(o.cwd,{event:"compat",properties:{checked_items_count:y.checkedItemKeys.length,incompatible_items_count:0,duration_ms:Date.now()-s}})}catch(f){n&&console.error("[Telemetry] compat tracking failed:",f)}process.exit(0)}ae({report:y,title:"\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804\uACFC \uD638\uD658\uB418\uC9C0 \uC54A\uB294 \uC2A4\uB2C8\uD3AB\uC744 \uCC3E\uC558\uC5B4\uC694."}),S.log.info("\uD544\uC694\uD55C \uBC84\uC804\uC73C\uB85C @seed-design/react \uB610\uB294 @seed-design/css\uB97C \uB9DE\uCD98 \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574\uBCF4\uC138\uC694."),S.outro("\uD638\uD658\uC131 \uC774\uC288\uAC00 \uC788\uC5B4\uC694.");try{await z.track(o.cwd,{event:"compat",properties:{checked_items_count:y.checkedItemKeys.length,incompatible_items_count:new Set(y.issues.map(f=>f.itemKey)).size,issue_count:y.issues.length,duration_ms:Date.now()-s}})}catch(f){n&&console.error("[Telemetry] compat tracking failed:",f)}process.exit(1)}catch(i){U(i)&&(S.outro(a(i.message)),process.exit(0)),B(i,{defaultMessage:"\uD638\uD658\uC131 \uAC80\uC0AC\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:n}),process.exit(1)}})};import*as j from"@clack/prompts";import{z as he}from"zod";import Vt from"dedent";var Ut=he.object({cwd:he.string(),yes:he.boolean().optional(),default:he.boolean().optional()}),Le=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.").option("--default","Deprecated. --yes\uC640 \uB3D9\uC77C\uD558\uAC8C \uAE30\uBCF8\uAC12\uC73C\uB85C \uC0DD\uC131\uD569\uB2C8\uB2E4.").action(async t=>{let r=Date.now(),s=L(t);j.intro("seed-design.json \uD30C\uC77C \uC0DD\uC131");try{let n=Ut.safeParse(t);if(!n.success)throw n.error;let i=n.data,o=i.yes||i.default,c=o?_:await $e(),{start:l,stop:d}=j.spinner();l("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC911...");let h=await(async()=>{try{return(await me({cwd:i.cwd,config:c})).relativePath}catch($){throw d("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC774 \uC911\uB2E8\uB410\uC5B4\uC694."),$}})();d(`seed-design.json \uD30C\uC77C\uC774 ${a(h)}\uC5D0 \uC0DD\uC131\uB410\uC5B4\uC694.`),j.log.info(a("seed-design add {component} \uBA85\uB839\uC5B4\uB85C \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCD94\uAC00\uD574\uBCF4\uC138\uC694!")),j.log.info(a("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.")),j.note(Vt(`SEED Design CLI\uB294 \uAC1C\uC120\uC744 \uC704\uD574 \uC775\uBA85 \uC0AC\uC6A9 \uB370\uC774\uD130\uB97C \uC218\uC9D1\uD574\uC694.
|
|
10
|
+
\uC124\uCE58\uD560 \uC758\uC874\uC131: ${p(Array.from(b).join(", ")||"\uC5C6\uC74C")}`),await we({registryItemsToAdd:d,rootPath:u,cwd:a,baseUrl:w,framework:$,config:C,onDiff:c.onDiff});let{installed:U,filtered:H}=await be({cwd:a,deps:Array.from(b)});U.size===0&&S.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),U.size&&(S.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${p(Array.from(U).join(", "))}`),H.size&&S.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${p(Array.from(H).join(", "))}`)),S.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let ie=Date.now()-n,de=new Set(d.map(m=>m.registryId)),k=f.some(m=>{let[y,...j]=m.split(":"),M=j.join(":");return x.find(_=>_.id===y)?.items.find(_=>_.id===M)?.deprecated});try{await N.track(c.cwd,{event:"add",properties:{items_count:h.length,registries:Array.from(de),has_deprecated:k,dependencies_count:b.size,duration_ms:ie}})}catch(m){o&&console.error("[Telemetry] add tracking failed:",m)}}catch(s){F(s)&&(S.outro(p(s.message)),process.exit(0)),V(s,{defaultMessage:"\uCD94\uAC00\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:o}),process.exit(1)}})};import*as v from"@clack/prompts";import Qt from"path";import{z as Y}from"zod";var Zt=Y.object({registryIds:Y.array(Y.string()).optional(),all:Y.boolean(),includeDeprecated:Y.boolean().optional(),cwd:Y.string(),baseUrl:Y.string().optional(),framework:Y.enum(["react","lynx"]).optional(),onDiff:Y.enum(["overwrite","backup"]).optional()}),He=e=>{e.command("add-all [...registry-ids]","add all items from registries").option("-a, --all","Add all items from all registries",{default:!1}).option("--include-deprecated","Include deprecated items when used with `--all`",{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:G}).option("-f, --framework <framework>","\uD504\uB808\uC784\uC6CC\uD06C (react \uB610\uB294 lynx)").option("--on-diff <mode>","Action when file differs: overwrite or backup").example("seed-design add-all ui --include-deprecated").example("seed-design add-all ui lib breeze").action(async(t,r)=>{let n=Date.now(),o=z(r);v.intro("seed-design add-all");try{let s=Zt.safeParse({registryIds:t,...r});if(!s.success)throw s.error;let{data:i}=s,c=i.cwd,a=i.baseUrl,w=await ue(c),C=i.framework??w.framework,$=Qt.resolve(c,w.path),{start:u,stop:A}=v.spinner();u("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let g=await(async()=>{try{let k=await Promise.all((await ne({baseUrl:a,framework:C})).map(async({id:m})=>ae({baseUrl:a,framework:C,registryId:m})));return A("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),k}catch(k){throw A("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),k}})(),x=await(async()=>{if(i.all){let m=g.map(y=>y.id);return v.log.message(`\uBAA8\uB4E0 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${p(m.join(", "))}`),m}if(i.registryIds?.length){let m=g.map(y=>y.id);for(let y of i.registryIds)if(!m.includes(y))throw new P({message:`\uB808\uC9C0\uC2A4\uD2B8\uB9AC '${y}'\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,details:[`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uB808\uC9C0\uC2A4\uD2B8\uB9AC: ${m.join(", ")}`]});return v.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${p(i.registryIds.join(", "))}`),i.registryIds}let k=await v.multiselect({message:"\uCD94\uAC00\uD560 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uB97C \uC120\uD0DD\uD574\uC8FC\uC138\uC694 (\uC2A4\uD398\uC774\uC2A4 \uBC14\uB85C \uC5EC\uB7EC \uAC1C \uC120\uD0DD \uAC00\uB2A5)",options:g.filter(({hideFromCLICatalog:m})=>!m).sort((m,y)=>y.items.length-m.items.length).map(m=>{let y=m.items[0]?.id,j=y?`${m.items.length}\uAC1C \uD56D\uBAA9 (${y} \uB4F1)`:`${m.items.length}\uAC1C \uD56D\uBAA9 (\uD56D\uBAA9 \uC5C6\uC74C)`;return{label:m.id,value:m.id,hint:j}})});if(v.isCancel(k))throw new E;return v.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${p(k.join(", "))}`),k})(),f=g.filter(k=>x.includes(k.id)),h=f.flatMap(k=>k.items.filter(m=>m.deprecated?i.includeDeprecated:!0).map(m=>`${k.id}:${m.id}`)),d=f.reduce((k,m)=>k+m.items.filter(y=>y.deprecated).length,0);if(!i.includeDeprecated&&d>0&&v.log.info(`${d}\uAC1C\uC758 deprecated \uD56D\uBAA9\uC740 \uC81C\uC678\uB418\uC5C8\uC5B4\uC694. --include-deprecated \uC635\uC158\uC744 \uC0AC\uC6A9\uD558\uBA74 \uCD94\uAC00\uD560 \uC218 \uC788\uC5B4\uC694.`),!h.length)throw new E("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694.");v.log.message(`\uCD1D ${p(h.length.toString())}\uAC1C\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4.`);let{registryItemsToAdd:b,npmDependenciesToAdd:I}=ye({selectedItemKeys:h,publicRegistries:g}),U=le({publicRegistries:g,itemKeys:b.flatMap(({registryId:k,items:m})=>m.map(y=>`${k}:${y.id}`)),projectPackageVersions:pe(i.cwd,C),framework:C});me({report:U,title:"\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804\uACFC \uD638\uD658\uB418\uC9C0 \uC54A\uC744 \uC218 \uC788\uB294 \uC2A4\uB2C8\uD3AB\uC774 \uC788\uC5B4\uC694.",framework:C}),await we({registryItemsToAdd:b,rootPath:$,cwd:c,baseUrl:a,framework:C,config:w,onDiff:i.onDiff});let{installed:H,filtered:ie}=await be({cwd:c,deps:Array.from(I)});H.size===0&&v.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),H.size&&(v.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${p(Array.from(H).join(", "))}`),ie.size&&v.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${p(Array.from(ie).join(", "))}`)),v.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let de=Date.now()-n;try{await N.track(i.cwd,{event:"add-all",properties:{registries:x,items_count:h.length,include_deprecated:i.includeDeprecated||!1,dependencies_count:I.size,duration_ms:de}})}catch(k){o&&console.error("[Telemetry] add-all tracking failed:",k)}}catch(s){F(s)&&(v.outro(p(s.message)),process.exit(0)),V(s,{defaultMessage:"\uCD94\uAC00\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:o}),process.exit(1)}})};import*as T from"@clack/prompts";import Je from"path";import{z as D}from"zod";var er=D.object({itemIds:D.array(D.string()).optional(),component:D.union([D.string(),D.array(D.string())]).optional(),all:D.boolean(),registry:D.string().optional(),cwd:D.string(),baseUrl:D.string().optional(),framework:D.enum(["react","lynx"]).optional()});function tr({itemIds:e,component:t}){let r=s=>s.trim().replace(/\s+/g,"-"),n=(e??[]).map(r).filter(Boolean),o=(Array.isArray(t)?t:[t]).filter(s=>!!s).flatMap(s=>s.split(",")).map(r).filter(Boolean);return Array.from(new Set([...n,...o]))}function rr({publicRegistries:e,targetInputs:t,defaultRegistry:r}){let n=e.filter(s=>typeof s.id=="string"&&Array.isArray(s.items)).flatMap(s=>s.items.filter(i=>typeof i.id=="string").map(i=>`${s.id}:${i.id}`)),o=new Set;for(let s of t){let i=s.includes(":")?s:r?`${r}:${s}`:(()=>{let c=n.filter(a=>a.endsWith(`:${s}`));if(!c.length)throw new P({message:`${p(s)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:`${p("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});if(c.length>1)throw new P({message:`${p(s)}: \uAC19\uC740 \uC774\uB984\uC758 \uD56D\uBAA9\uC774 \uC5EC\uB7EC \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC788\uC5B4\uC694.`,details:c.map(a=>`- ${a}`),hint:`${p("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});return c[0]})();if(!n.includes(i))throw new P({message:`${p(i)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});o.add(i)}return Array.from(o)}var We=e=>{e.command("compat [...item-ids]","check snippet compatibility").option("-c, --component <component>","\uAC80\uC0AC\uD560 \uCEF4\uD3EC\uB10C\uD2B8. \uC5EC\uB7EC \uBC88 \uB610\uB294 \uC27C\uD45C\uB85C \uC9C0\uC815 \uAC00\uB2A5").option("-a, --all","\uBAA8\uB4E0 registry \uD56D\uBAA9\uC744 \uAC80\uC0AC",{default:!1}).option("-r, --registry <registryId>","\uCEF4\uD3EC\uB10C\uD2B8 shorthand \uC785\uB825 \uC2DC \uAE30\uBCF8 registry").option("--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:G}).option("-f, --framework <framework>","\uD504\uB808\uC784\uC6CC\uD06C (react \uB610\uB294 lynx)").example("seed-design compat").example("seed-design compat -c action-button").example("seed-design compat ui:action-button ui:alert-dialog").example("seed-design compat --all").action(async(t,r)=>{let n=Date.now(),o=z(r);T.intro("seed-design compat");try{let s=er.safeParse({itemIds:t,...r});if(!s.success)throw s.error;let{data:i}=s,c=await oe(i.cwd),a=i.framework??c?.framework??"react",{start:w,stop:C}=T.spinner();w("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let $=await(async()=>{try{let d=await Promise.all((await ne({baseUrl:i.baseUrl,framework:a})).map(async({id:b})=>ae({baseUrl:i.baseUrl,framework:a,registryId:b})));return C("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),d}catch(d){throw C("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),d}})(),u=tr({itemIds:i.itemIds,component:i.component}),A=i.all?$.flatMap(b=>b.items.map(I=>`${b.id}:${I.id}`)):u.length>0?rr({publicRegistries:$,targetInputs:u,defaultRegistry:i.registry}):oe(i.cwd),g=Array.isArray(A)?A:await(async()=>{let d=await A;if(!d)throw new P({message:"seed-design.json \uD30C\uC77C\uC774 \uC5C6\uC5B4 \uC124\uCE58\uB41C \uC2A4\uB2C8\uD3AB \uACBD\uB85C\uB97C \uC54C \uC218 \uC5C6\uC5B4\uC694.",hint:"`seed-design init`\uC73C\uB85C \uC124\uC815\uC744 \uB9CC\uB4E0 \uB4A4 \uC2E4\uD589\uD558\uAC70\uB098, `--all`/`-c`\uB85C \uAC80\uC0AC \uB300\uC0C1\uC744 \uC9C1\uC811 \uC9C0\uC815\uD574\uC8FC\uC138\uC694."});let b=Je.resolve(i.cwd,d.path),I=Be({publicRegistries:$,rootPath:b});return I.length?I:(T.log.info(`${p(Je.relative(i.cwd,b)||d.path)}\uC5D0\uC11C \uC124\uCE58\uB41C \uC2A4\uB2C8\uD3AB\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.`),[])})();g.length||(T.outro("\uAC80\uC0AC\uD560 \uC2A4\uB2C8\uD3AB\uC774 \uC5C6\uC5B4\uC694."),process.exit(0));let x=pe(i.cwd,a),f=le({publicRegistries:$,itemKeys:g,projectPackageVersions:x,framework:a});if(T.log.info(`\uAC80\uC0AC \uB300\uC0C1: ${p(f.checkedItemKeys.join(", "))}`),!f.issues.length){let d=Z(a);T.outro(`\uBAA8\uB4E0 \uC2A4\uB2C8\uD3AB\uC774 \uD604\uC7AC ${d.join(", ")}\uC640 \uD638\uD658\uB3FC\uC694.`);try{await N.track(i.cwd,{event:"compat",properties:{checked_items_count:f.checkedItemKeys.length,incompatible_items_count:0,duration_ms:Date.now()-n}})}catch(b){o&&console.error("[Telemetry] compat tracking failed:",b)}process.exit(0)}me({report:f,title:"\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804\uACFC \uD638\uD658\uB418\uC9C0 \uC54A\uB294 \uC2A4\uB2C8\uD3AB\uC744 \uCC3E\uC558\uC5B4\uC694.",framework:a});let h=Z(a);T.log.info(`\uD544\uC694\uD55C \uBC84\uC804\uC73C\uB85C ${h.join(" \uB610\uB294 ")}\uB97C \uB9DE\uCD98 \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574\uBCF4\uC138\uC694.`),T.outro("\uD638\uD658\uC131 \uC774\uC288\uAC00 \uC788\uC5B4\uC694.");try{await N.track(i.cwd,{event:"compat",properties:{checked_items_count:f.checkedItemKeys.length,incompatible_items_count:new Set(f.issues.map(d=>d.itemKey)).size,issue_count:f.issues.length,duration_ms:Date.now()-n}})}catch(d){o&&console.error("[Telemetry] compat tracking failed:",d)}process.exit(1)}catch(s){F(s)&&(T.outro(p(s.message)),process.exit(0)),V(s,{defaultMessage:"\uD638\uD658\uC131 \uAC80\uC0AC\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:o}),process.exit(1)}})};import*as R from"@clack/prompts";import{z as ke}from"zod";var sr="https://raw.githubusercontent.com/daangn/seed-design/refs/heads/dev/docs/registry",ir=ke.object({query:ke.string().optional(),baseUrl:ke.string().optional()});function Ye(e,t){return`${sr}/${e}/${t}`}function or(e,t){let r=`${t}${e.docUrl}`,n=`${t}/llms${e.docUrl}.txt`,o=[e.id,`- docs: ${r}`,`- llms.txt: ${n}`];if(e.snippetKey&&e.snippets&&e.snippets.length>0){let[s]=e.snippetKey.split(":");if(s==="ui"||s==="breeze")if(e.snippets.length===1)o.push(`- snippet: ${Ye(s,e.snippets[0].path)}`);else{o.push("- snippet:");for(let i of e.snippets)o.push(` - ${i.label}: ${Ye(s,i.path)}`)}}R.log.message(o.join(`
|
|
11
|
+
`))}function nr(e){return e.split("/").map(t=>t.trim()).filter(Boolean)}function ar(e,t){let r=t.toLowerCase();return e.flatMap(n=>n.sections.flatMap(o=>o.items.filter(s=>s.id.toLowerCase().includes(r)||s.title.toLowerCase().includes(r)).map(s=>({item:s,categoryLabel:n.label,sectionLabel:o.label}))))}async function fe(e){let t=await R.select({message:"\uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694",options:e.map(r=>({label:`${r.deprecated?"(deprecated) ":""}${r.title}`,value:r,hint:r.description}))});if(R.isCancel(t))throw new E;return t}async function Xe(e){let t=await R.select({message:"\uC139\uC158\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694",options:e.map(r=>({label:r.label,value:r,hint:`${r.items.length}\uAC1C \uD56D\uBAA9`}))});if(R.isCancel(t))throw new E;return t}async function cr(e){let t=await R.select({message:"\uCE74\uD14C\uACE0\uB9AC\uB97C \uC120\uD0DD\uD574\uC8FC\uC138\uC694",options:e.map(r=>({label:r.label,value:r,hint:`${r.sections.reduce((n,o)=>n+o.items.length,0)}\uAC1C \uD56D\uBAA9`}))});if(R.isCancel(t))throw new E;return t}var Qe=e=>{e.command("docs [query]","\uBB38\uC11C \uB9C1\uD06C, llms.txt \uB9C1\uD06C, \uC2A4\uB2C8\uD3AB \uB9C1\uD06C\uB97C \uC870\uD68C\uD569\uB2C8\uB2E4").option("-u, --baseUrl <baseUrl>",`\uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uAE30\uBCF8 URL (\uAE30\uBCF8\uAC12: ${G})`,{default:G}).example("seed-design docs").example("seed-design docs action-button").example("seed-design docs react").example("seed-design docs react/components").example("seed-design docs react/components/action-button").action(async(t,r)=>{let n=Date.now(),o=z(r);R.intro("seed-design docs");try{let s=ir.safeParse({query:t,...r});if(!s.success)throw s.error;let{data:i}=s,c=i.baseUrl??G,{start:a,stop:w}=R.spinner();a("\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let C=await(async()=>{try{let g=await Te({baseUrl:c});return w("\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC654\uC5B4\uC694."),g}catch(g){throw w("\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),g}})(),{categories:$}=C,u;if(i.query){let g=nr(i.query),x=$.find(f=>f.id===g[0]);if(x&&g.length>=2){let f=x.sections.find(h=>h.id===g[1]);if(f&&g.length>=3){let h=f.items.find(d=>d.id===g[2]);if(h)u=h;else{let d=g[2].toLowerCase(),b=f.items.filter(I=>I.id.toLowerCase().includes(d)||I.title.toLowerCase().includes(d));if(b.length===0)throw new P({message:`${p(i.query)}: \uBB38\uC11C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:`\`seed-design docs ${x.id}/${f.id}\`\uB85C \uBAA9\uB85D\uC744 \uD655\uC778\uD574\uBCF4\uC138\uC694.`});b.length===1?u=b[0]:u=await fe(b)}}else if(f)u=await fe(f.items);else{let h=g[1].toLowerCase(),d=x.sections.flatMap(b=>b.items.filter(I=>I.id.toLowerCase().includes(h)||I.title.toLowerCase().includes(h)).map(I=>({item:I,sectionLabel:b.label})));if(d.length===0)throw new P({message:`${p(i.query)}: \uBB38\uC11C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:`\`seed-design docs ${x.id}\`\uB85C \uBAA9\uB85D\uC744 \uD655\uC778\uD574\uBCF4\uC138\uC694.`});if(d.length===1)u=d[0].item;else{let b=await R.select({message:`${p(g[1])}\uC5D0 \uD574\uB2F9\uD558\uB294 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694`,options:d.map(({item:I,sectionLabel:U})=>({label:`[${U}] ${I.title}`,value:I,hint:I.description}))});if(R.isCancel(b))throw new E;u=b}}}else if(x)if(x.sections.length===1)u=await fe(x.sections[0].items);else{let f=await Xe(x.sections);u=await fe(f.items)}else{let f=ar($,i.query);if(f.length===0)throw new P({message:`${p(i.query)}: \uBB38\uC11C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:"`seed-design docs`\uB85C \uC804\uCCB4 \uBAA9\uB85D\uC744 \uD655\uC778\uD574\uBCF4\uC138\uC694."});if(f.length===1)u=f[0].item;else{let h=await R.select({message:`${p(i.query)}\uC5D0 \uD574\uB2F9\uD558\uB294 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694`,options:f.map(({item:d,categoryLabel:b,sectionLabel:I})=>({label:`[${b} > ${I}] ${d.title}`,value:d,hint:d.description}))});if(R.isCancel(h))throw new E;u=h}}}else{let g=await cr($),x;g.sections.length===1?x=g.sections[0]:x=await Xe(g.sections),u=await fe(x.items)}or(u,c),R.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let A=Date.now()-n;try{await N.track(process.cwd(),{event:"docs",properties:{query:i.query??null,item_id:u.id,has_snippet:!!(u.snippets&&u.snippets.length>0),duration_ms:A}})}catch(g){o&&console.error("[Telemetry] docs tracking failed:",g)}}catch(s){F(s)&&(R.outro(p(s.message)),process.exit(0)),V(s,{defaultMessage:"\uBB38\uC11C \uC870\uD68C\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:o}),process.exit(1)}})};import*as O from"@clack/prompts";import{z as Ce}from"zod";import pr from"dedent";var lr=Ce.object({cwd:Ce.string(),yes:Ce.boolean().optional(),default:Ce.boolean().optional()}),Ze=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.").option("--default","Deprecated. --yes\uC640 \uB3D9\uC77C\uD558\uAC8C \uAE30\uBCF8\uAC12\uC73C\uB85C \uC0DD\uC131\uD569\uB2C8\uB2E4.").action(async t=>{let r=Date.now(),n=z(t);O.intro("seed-design.json \uD30C\uC77C \uC0DD\uC131");try{let o=lr.safeParse(t);if(!o.success)throw o.error;let s=o.data,i=s.yes||s.default,c=i?{...K,framework:$e(s.cwd)}:await Re(s.cwd),{start:a,stop:w}=O.spinner();a("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC911...");let C=await(async()=>{try{return(await ge({cwd:s.cwd,config:c})).relativePath}catch(u){throw w("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC774 \uC911\uB2E8\uB410\uC5B4\uC694."),u}})();w(`seed-design.json \uD30C\uC77C\uC774 ${p(C)}\uC5D0 \uC0DD\uC131\uB410\uC5B4\uC694.`),O.log.info(p("seed-design add {component} \uBA85\uB839\uC5B4\uB85C \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCD94\uAC00\uD574\uBCF4\uC138\uC694!")),O.log.info(p("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.")),O.note(pr(`SEED Design CLI\uB294 \uAC1C\uC120\uC744 \uC704\uD574 \uC775\uBA85 \uC0AC\uC6A9 \uB370\uC774\uD130\uB97C \uC218\uC9D1\uD574\uC694.
|
|
11
12
|
|
|
12
13
|
\uBE44\uD65C\uC131\uD654\uD558\uB824\uBA74:
|
|
13
|
-
\u2022 seed-design.json\uC5D0\uC11C ${
|
|
14
|
-
\u2022 ${
|
|
14
|
+
\u2022 seed-design.json\uC5D0\uC11C ${p('"telemetry": false')}\uB85C \uC124\uC815
|
|
15
|
+
\u2022 ${p("DISABLE_TELEMETRY=true")} \uD658\uACBD \uBCC0\uC218 \uC124\uC815
|
|
15
16
|
|
|
16
|
-
\uC790\uC138\uD55C \uB0B4\uC6A9: https://seed-design.com/react/getting-started/cli/configuration#telemetry`),"Telemetry \uC548\uB0B4"),
|
|
17
|
+
\uC790\uC138\uD55C \uB0B4\uC6A9: https://seed-design.com/react/getting-started/cli/configuration#telemetry`),"Telemetry \uC548\uB0B4"),O.outro("\uC791\uC5C5\uC774 \uC644\uB8CC\uB410\uC5B4\uC694.");let $=Date.now()-r;try{await N.track(s.cwd,{event:"init",properties:{tsx:c.tsx,rsc:c.rsc,telemetry:c.telemetry,yes_option:i,duration_ms:$}})}catch(u){n&&console.error("[Telemetry] init tracking failed:",u)}}catch(o){F(o)&&(O.outro(p(o.message)),process.exit(0)),V(o,{defaultMessage:"seed-design.json \uD30C\uC77C \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.",defaultHint:"`--verbose` \uC635\uC158\uC73C\uB85C \uC0C1\uC138 \uC624\uB958\uB97C \uD655\uC778\uD574\uBCF4\uC138\uC694.",verbose:n}),process.exit(1)}})};import{cac as mr}from"cac";var dr="seed-design",X=mr(dr);async function fr(){let e=Q();X.option("--verbose","\uC624\uB958 \uC0C1\uC138 \uC815\uBCF4\uB97C \uCD9C\uB825\uD569\uB2C8\uB2E4."),Ge(X),He(X),We(X),Qe(X),Ze(X),X.version(e.version||"1.0.0","-v, --version"),X.help(),X.parse()}fr();
|
package/package.json
CHANGED
package/src/commands/add-all.ts
CHANGED
|
@@ -30,6 +30,7 @@ const addAllOptionsSchema = z.object({
|
|
|
30
30
|
includeDeprecated: z.boolean().optional(),
|
|
31
31
|
cwd: z.string(),
|
|
32
32
|
baseUrl: z.string().optional(),
|
|
33
|
+
framework: z.enum(["react", "lynx"]).optional(),
|
|
33
34
|
onDiff: z.enum(["overwrite", "backup"]).optional(),
|
|
34
35
|
});
|
|
35
36
|
|
|
@@ -50,6 +51,7 @@ export const addAllCommand = (cli: CAC) => {
|
|
|
50
51
|
"the base url of the registry. defaults to the current directory.",
|
|
51
52
|
{ default: BASE_URL },
|
|
52
53
|
)
|
|
54
|
+
.option("-f, --framework <framework>", "프레임워크 (react 또는 lynx)")
|
|
53
55
|
.option("--on-diff <mode>", "Action when file differs: overwrite or backup")
|
|
54
56
|
.example("seed-design add-all ui --include-deprecated")
|
|
55
57
|
.example("seed-design add-all ui lib breeze")
|
|
@@ -69,6 +71,7 @@ export const addAllCommand = (cli: CAC) => {
|
|
|
69
71
|
const cwd = options.cwd;
|
|
70
72
|
const baseUrl = options.baseUrl;
|
|
71
73
|
const config = await getConfig(cwd);
|
|
74
|
+
const framework = options.framework ?? config.framework;
|
|
72
75
|
const rootPath = path.resolve(cwd, config.path);
|
|
73
76
|
|
|
74
77
|
const { start, stop } = p.spinner();
|
|
@@ -77,8 +80,8 @@ export const addAllCommand = (cli: CAC) => {
|
|
|
77
80
|
const publicRegistries = await (async () => {
|
|
78
81
|
try {
|
|
79
82
|
const registries = await Promise.all(
|
|
80
|
-
(await fetchAvailableRegistries({ baseUrl })).map(async ({ id }) =>
|
|
81
|
-
fetchRegistry({ baseUrl, registryId: id }),
|
|
83
|
+
(await fetchAvailableRegistries({ baseUrl, framework })).map(async ({ id }) =>
|
|
84
|
+
fetchRegistry({ baseUrl, framework, registryId: id }),
|
|
82
85
|
),
|
|
83
86
|
);
|
|
84
87
|
stop("Registry를 가져왔어요.");
|
|
@@ -186,12 +189,14 @@ export const addAllCommand = (cli: CAC) => {
|
|
|
186
189
|
itemKeys: registryItemsToAdd.flatMap(({ registryId, items }) =>
|
|
187
190
|
items.map((item) => `${registryId}:${item.id}`),
|
|
188
191
|
),
|
|
189
|
-
projectPackageVersions: getProjectSeedPackageVersionSpecs(options.cwd),
|
|
192
|
+
projectPackageVersions: getProjectSeedPackageVersionSpecs(options.cwd, framework),
|
|
193
|
+
framework,
|
|
190
194
|
});
|
|
191
195
|
|
|
192
196
|
logCompatibilityReport({
|
|
193
197
|
report: compatibilityReport,
|
|
194
198
|
title: "현재 프로젝트 버전과 호환되지 않을 수 있는 스니펫이 있어요.",
|
|
199
|
+
framework,
|
|
195
200
|
});
|
|
196
201
|
|
|
197
202
|
await writeRegistryItemSnippets({
|
|
@@ -199,6 +204,7 @@ export const addAllCommand = (cli: CAC) => {
|
|
|
199
204
|
rootPath,
|
|
200
205
|
cwd,
|
|
201
206
|
baseUrl,
|
|
207
|
+
framework,
|
|
202
208
|
config,
|
|
203
209
|
onDiff: options.onDiff,
|
|
204
210
|
});
|
package/src/commands/add.ts
CHANGED
|
@@ -32,6 +32,7 @@ const addOptionsSchema = z.object({
|
|
|
32
32
|
all: z.boolean(),
|
|
33
33
|
cwd: z.string(),
|
|
34
34
|
baseUrl: z.string().optional(),
|
|
35
|
+
framework: z.enum(["react", "lynx"]).optional(),
|
|
35
36
|
onDiff: z.enum(["overwrite", "backup"]).optional(),
|
|
36
37
|
});
|
|
37
38
|
|
|
@@ -49,6 +50,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
49
50
|
"the base url of the registry. defaults to the current directory.",
|
|
50
51
|
{ default: BASE_URL },
|
|
51
52
|
)
|
|
53
|
+
.option("-f, --framework <framework>", "프레임워크 (react 또는 lynx)")
|
|
52
54
|
.option("--on-diff <mode>", "Action when file differs: overwrite or backup")
|
|
53
55
|
.example("seed-design add ui:action-button")
|
|
54
56
|
.example("seed-design add ui:alert-dialog")
|
|
@@ -77,6 +79,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
77
79
|
const cwd = options.cwd;
|
|
78
80
|
const baseUrl = options.baseUrl;
|
|
79
81
|
const config = await getConfig(cwd);
|
|
82
|
+
const framework = options.framework ?? config.framework;
|
|
80
83
|
const rootPath = path.resolve(cwd, config.path);
|
|
81
84
|
|
|
82
85
|
const { start, stop } = p.spinner();
|
|
@@ -85,8 +88,8 @@ export const addCommand = (cli: CAC) => {
|
|
|
85
88
|
const publicRegistries = await (async () => {
|
|
86
89
|
try {
|
|
87
90
|
const registries = await Promise.all(
|
|
88
|
-
(await fetchAvailableRegistries({ baseUrl })).map(async ({ id }) =>
|
|
89
|
-
fetchRegistry({ baseUrl, registryId: id }),
|
|
91
|
+
(await fetchAvailableRegistries({ baseUrl, framework })).map(async ({ id }) =>
|
|
92
|
+
fetchRegistry({ baseUrl, framework, registryId: id }),
|
|
90
93
|
),
|
|
91
94
|
);
|
|
92
95
|
stop("Registry를 가져왔어요.");
|
|
@@ -193,12 +196,14 @@ export const addCommand = (cli: CAC) => {
|
|
|
193
196
|
itemKeys: registryItemsToAdd.flatMap(({ registryId, items }) =>
|
|
194
197
|
items.map((item) => `${registryId}:${item.id}`),
|
|
195
198
|
),
|
|
196
|
-
projectPackageVersions: getProjectSeedPackageVersionSpecs(options.cwd),
|
|
199
|
+
projectPackageVersions: getProjectSeedPackageVersionSpecs(options.cwd, framework),
|
|
200
|
+
framework,
|
|
197
201
|
});
|
|
198
202
|
|
|
199
203
|
logCompatibilityReport({
|
|
200
204
|
report: compatibilityReport,
|
|
201
205
|
title: "현재 프로젝트 버전과 호환되지 않을 수 있는 스니펫이 있어요.",
|
|
206
|
+
framework,
|
|
202
207
|
});
|
|
203
208
|
|
|
204
209
|
p.log.info(
|
|
@@ -212,6 +217,7 @@ export const addCommand = (cli: CAC) => {
|
|
|
212
217
|
rootPath,
|
|
213
218
|
cwd,
|
|
214
219
|
baseUrl,
|
|
220
|
+
framework,
|
|
215
221
|
config,
|
|
216
222
|
onDiff: options.onDiff,
|
|
217
223
|
});
|
package/src/commands/compat.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { highlight } from "../utils/color";
|
|
|
11
11
|
import {
|
|
12
12
|
analyzeRegistryItemCompatibility,
|
|
13
13
|
findInstalledSnippetItemKeys,
|
|
14
|
+
getCompatPackageNames,
|
|
14
15
|
getProjectSeedPackageVersionSpecs,
|
|
15
16
|
logCompatibilityReport,
|
|
16
17
|
} from "../utils/compatibility";
|
|
@@ -23,6 +24,7 @@ const compatOptionsSchema = z.object({
|
|
|
23
24
|
registry: z.string().optional(),
|
|
24
25
|
cwd: z.string(),
|
|
25
26
|
baseUrl: z.string().optional(),
|
|
27
|
+
framework: z.enum(["react", "lynx"]).optional(),
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
function parseTargetInputs({
|
|
@@ -116,6 +118,7 @@ export const compatCommand = (cli: CAC) => {
|
|
|
116
118
|
"the base url of the registry. defaults to the current directory.",
|
|
117
119
|
{ default: BASE_URL },
|
|
118
120
|
)
|
|
121
|
+
.option("-f, --framework <framework>", "프레임워크 (react 또는 lynx)")
|
|
119
122
|
.example("seed-design compat")
|
|
120
123
|
.example("seed-design compat -c action-button")
|
|
121
124
|
.example("seed-design compat ui:action-button ui:alert-dialog")
|
|
@@ -132,14 +135,17 @@ export const compatCommand = (cli: CAC) => {
|
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
const { data: options } = parsed;
|
|
138
|
+
const rawConfig = await getRawConfig(options.cwd);
|
|
139
|
+
const framework = options.framework ?? rawConfig?.framework ?? "react";
|
|
135
140
|
const { start, stop } = p.spinner();
|
|
136
141
|
|
|
137
142
|
start("Registry를 가져오고 있어요...");
|
|
138
143
|
const publicRegistries = await (async () => {
|
|
139
144
|
try {
|
|
140
145
|
const registries = await Promise.all(
|
|
141
|
-
(await fetchAvailableRegistries({ baseUrl: options.baseUrl })).map(
|
|
142
|
-
|
|
146
|
+
(await fetchAvailableRegistries({ baseUrl: options.baseUrl, framework })).map(
|
|
147
|
+
async ({ id }) =>
|
|
148
|
+
fetchRegistry({ baseUrl: options.baseUrl, framework, registryId: id }),
|
|
143
149
|
),
|
|
144
150
|
);
|
|
145
151
|
stop("Registry를 가져왔어요.");
|
|
@@ -206,17 +212,19 @@ export const compatCommand = (cli: CAC) => {
|
|
|
206
212
|
process.exit(0);
|
|
207
213
|
}
|
|
208
214
|
|
|
209
|
-
const projectPackageVersions = getProjectSeedPackageVersionSpecs(options.cwd);
|
|
215
|
+
const projectPackageVersions = getProjectSeedPackageVersionSpecs(options.cwd, framework);
|
|
210
216
|
const compatibilityReport = analyzeRegistryItemCompatibility({
|
|
211
217
|
publicRegistries,
|
|
212
218
|
itemKeys: resolvedTargetItemKeys,
|
|
213
219
|
projectPackageVersions,
|
|
220
|
+
framework,
|
|
214
221
|
});
|
|
215
222
|
|
|
216
223
|
p.log.info(`검사 대상: ${highlight(compatibilityReport.checkedItemKeys.join(", "))}`);
|
|
217
224
|
|
|
218
225
|
if (!compatibilityReport.issues.length) {
|
|
219
|
-
|
|
226
|
+
const compatPkgNames = getCompatPackageNames(framework);
|
|
227
|
+
p.outro(`모든 스니펫이 현재 ${compatPkgNames.join(", ")}와 호환돼요.`);
|
|
220
228
|
|
|
221
229
|
try {
|
|
222
230
|
await analytics.track(options.cwd, {
|
|
@@ -239,10 +247,10 @@ export const compatCommand = (cli: CAC) => {
|
|
|
239
247
|
logCompatibilityReport({
|
|
240
248
|
report: compatibilityReport,
|
|
241
249
|
title: "현재 프로젝트 버전과 호환되지 않는 스니펫을 찾았어요.",
|
|
250
|
+
framework,
|
|
242
251
|
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
);
|
|
252
|
+
const compatPkgList = getCompatPackageNames(framework);
|
|
253
|
+
p.log.info(`필요한 버전으로 ${compatPkgList.join(" 또는 ")}를 맞춘 뒤 다시 실행해보세요.`);
|
|
246
254
|
p.outro("호환성 이슈가 있어요.");
|
|
247
255
|
|
|
248
256
|
try {
|