@seed-design/cli 1.5.0 → 1.6.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/LICENSE +201 -0
- package/NOTICE +20 -0
- package/bin/index.mjs +21 -21
- package/package.json +5 -3
- package/src/commands/add-all.ts +4 -2
- package/src/commands/add.ts +4 -2
- package/src/tests/registry-source.test.ts +48 -0
- package/src/utils/registry-source.ts +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 Danggeun Market Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
SEED Design
|
|
2
|
+
Copyright 2025 주식회사 당근마켓
|
|
3
|
+
|
|
4
|
+
이 소프트웨어는 Apache License 2.0에 따라 배포되며, 상업적 목적을 포함하여 자유롭게 사용, 수정, 재배포할 수 있습니다.
|
|
5
|
+
재배포할 때에는 Apache License 2.0 제4조에 따라 라이선스 사본을 제공하고 이 파일에 담긴 귀속 고지를 전달해야 합니다.
|
|
6
|
+
|
|
7
|
+
아래 "브랜드 리소스"에 관한 내용은 상표에 관한 안내이며, Apache License 2.0이 정하는 조건을 변경하지 않습니다.
|
|
8
|
+
|
|
9
|
+
이 저장소에서 제공하는 "브랜드 리소스"는 주식회사 당근마켓(이하 "당근마켓")의 자산으로 대한민국 상표법의 보호를 받습니다.
|
|
10
|
+
브랜드 리소스란 로고, 상호명, 캐릭터 등 당근마켓이나 당근마켓의 제품으로 식별될 수 있는 모든 요소를 의미합니다.
|
|
11
|
+
|
|
12
|
+
당근마켓과 사전 협의가 없는 경우 비상업적 목적으로만 사용이 허가되며 [당근마켓 브랜드 리소스 가이드라인]을 준수해야 합니다.
|
|
13
|
+
상표 사용 허가는 당근마켓의 요청에 따라 언제든지 철회될 수 있습니다.
|
|
14
|
+
|
|
15
|
+
또한 브랜드 리소스를 다음과 같은 방식으로 사용할 수 없습니다.
|
|
16
|
+
|
|
17
|
+
- 당근마켓을 사칭하거나, 당근마켓이 제공하는 제품 또는 서비스인 것처럼 오인하게 하는 사용
|
|
18
|
+
- 당근마켓의 제품 또는 서비스와 제휴, 후원, 보증, 그 밖의 관련이 있는 것처럼 오인하게 하는 사용
|
|
19
|
+
|
|
20
|
+
[당근마켓 브랜드 리소스 가이드라인]: https://app.notion.com/p/daangn/6fdd92981e4a42d8b29c89cbbba7a8b7
|
package/bin/index.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import*as me from"@clack/prompts";import{cosmiconfig as
|
|
3
|
-
[verbose] stack trace`)),te.log.message(
|
|
4
|
-
`,"utf-8"),{relativePath:
|
|
5
|
-
${
|
|
6
|
-
`)}`});continue}throw new
|
|
7
|
-
${
|
|
8
|
-
`)}`})}async function ze({baseUrl:e,framework:
|
|
9
|
-
${
|
|
10
|
-
`)}`),
|
|
11
|
-
${
|
|
12
|
-
`),J.log.message(l),J.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:`${k} \uB36E\uC5B4\uC4F0\uAE30`},{value:"backup",label:`\uAE30\uC874 \uD30C\uC77C \uB0B4\uC6A9\uC744 ${V}\uC73C\uB85C \uC62E\uAE30\uACE0 ${k} \uBC1B\uAE30`},{value:"skip",label:"\uC0C8 \uD30C\uC77C \uBC1B\uC9C0 \uC54A\uACE0 \uADF8\uB300\uB85C \uB450\uAE30"}]})})();if(J.isCancel(U)||U==="skip"){J.log.info(`${m(u)}: \uD30C\uC77C\uC744 \uBC1B\uC9C0 \uC54A\uACE0 \uAC74\uB108\uB6F0\uC5C8\uC5B4\uC694.`);continue}if(U==="backup"){let S=Z.dirname(C),l=Z.join(S,V);await ge.rename(C,l),J.log.info(`${m(u)}: \uAE30\uC874 \uD30C\uC77C\uC744 ${m(Z.relative(r,l))}\uB85C \uC62E\uACBC\uC5B4\uC694.`)}}await ge.writeFile(C,h),v.push(E)}if(v.length>0){let E=v.map(({name:C,relativePath:h})=>({name:C,path:h}));a.push(...E),J.log.success(`${m(`${c}:${g}`)} \uAD00\uB828 \uC2A4\uB2C8\uD3AB \uB2E4\uC6B4\uB85C\uB4DC \uC644\uB8CC: ${m(E.map(C=>C.path).join(", "))}`)}}}}import*as j from"@clack/prompts";import dr from"path";import{z as re}from"zod";var K="https://seed-design.io";var He={"1.0":"https://v1-0.seed-design.io","1.1":"https://v1-1.seed-design.io","1.2":"https://v1-2.seed-design.io"};function Pe(e){let t=e.seedReactVersion?.trim();if(!t)return null;let r=He[t];if(!r)throw new $({message:`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 SEED React \uBC84\uC804\uC774\uC5D0\uC694: "${e.seedReactVersion}"`,hint:`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBC84\uC804: ${Object.keys(He).join(", ")}`});return{framework:"react",baseUrl:r}}import*as We from"@clack/prompts";import{execa as Gt}from"execa";import{detect as qt}from"@antfu/ni";async function Je(e){let t=await qt({programmatic:!0,cwd:e});return t==="yarn@berry"?"yarn":t==="pnpm@6"?"pnpm":t==="bun"?"bun":t==="deno"?"deno":t??"npm"}async function Se({cwd:e,deps:t,dev:r=!1}){let{start:n,stop:o}=We.spinner(),i=await Je(e),a={...ie(e).dependencies},c=new Set(t.filter(I=>!a[I])),p=new Set(t.filter(I=>a[I]));if(!c.size)return{installed:new Set,filtered:c};n("\uC758\uC874\uC131 \uC124\uCE58\uC911...");let g=[i==="npm"?"install":"add",r?"-D":null,...c].filter(I=>!!I),x=`${i} ${g.join(" ")}`;try{await Gt(i,g,{cwd:e})}catch(I){throw o("\uC758\uC874\uC131 \uC124\uCE58\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."),new $({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: ${x}`],cause:I})}return o("\uC758\uC874\uC131 \uC124\uCE58\uAC00 \uC644\uB8CC\uB410\uC5B4\uC694."),{installed:c,filtered:p}}import{randomUUID as Ht}from"node:crypto";import*as Qe from"@clack/prompts";var Jt="seed_cli";async function Wt(e){if(process.env.DISABLE_TELEMETRY==="true"||process.env.SEED_DISABLE_TELEMETRY==="true")return!1;try{if((await ne(e))?.telemetry===!1)return!1}catch{}return!0}function Yt(){return Ht()}var Qt=Yt(),Ye=!1;function Xe(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Xt(e){return e instanceof Error&&e.name?e.name:typeof e=="object"&&e!==null?e.constructor?.name??"Object":typeof e}async function Ze(e,{event:t,properties:r={}}){if(!await Wt(e))return;let o=`${Jt}.${t}`;Ye||(Qe.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)"),Ye=!0);try{let i="https://us.i.posthog.com/capture",s={"Content-Type":"application/json"},a={api_key:"phc_seod8HhifElOP1R92KmvsQybrtUmkOTgZBsq0mfCelR",event:o,distinct_id:Qt,properties:{...r,$process_person_profile:!1},timestamp:new Date().toISOString()},c=new AbortController,p=setTimeout(()=>c.abort(),5e3);try{await fetch(i,{method:"POST",headers:s,body:JSON.stringify(a),signal:c.signal})}finally{clearTimeout(p)}}catch{}}async function et(e,{command:t,status:r,result:n,properties:o={}}){await Ze(e,{event:t,properties:Xe({status:r,result:n,...o})})}async function Zt(e,{command:t,error:r,result:n,properties:o={}}){await et(e,{command:t,status:"failed",result:n,properties:Xe({error_type:Xt(r),...o})})}var R={track:Ze,trackCommandFailure:Zt,trackCommandOutcome:et};import*as pe from"@clack/prompts";import er from"fs-extra";import tr from"path";import{intersects as rr,satisfies as sr,valid as rt,validRange as st}from"semver";var or=["@seed-design/react","@seed-design/css"],ir=["@seed-design/lynx-react","@seed-design/lynx-css"];function ae(e){return e==="lynx"?ir:or}var tt="workspace:",nr="npm:";function ue(e,t="react"){try{let r=ie(e),n={...r.dependencies,...r.devDependencies,...r.peerDependencies,...r.optionalDependencies},o={},i=ae(t);for(let s of i){let a=n[s];typeof a=="string"&&(o[s]=a)}return o}catch{return{}}}function ye({publicRegistries:e,itemKeys:t,projectPackageVersions:r,framework:n="react"}){let o=Array.from(new Set(t)),i=new Map(e.flatMap(c=>c.items.map(p=>[`${c.id}:${p.id}`,p]))),s=[],a=ae(n);for(let c of o){let p=i.get(c);if(!p)continue;let y=ar(p,n);for(let w of a){let g=Array.from(y[w]??[]);if(!g.length)continue;let x=r[w];if(!x){s.push({itemKey:c,packageName:w,requiredRanges:g,type:"missing-package"});continue}let I=cr(x);if(!I){s.push({itemKey:c,packageName:w,requiredRanges:g,installedVersionSpec:x,type:"invalid-version-spec"});continue}g.every(E=>lr({currentVersionSpec:I,requiredRange:E}))||s.push({itemKey:c,packageName:w,requiredRanges:g,installedVersionSpec:x,type:"incompatible-version"})}}return{checkedItemKeys:o,projectPackageVersions:r,issues:s}}function he({report:e,title:t,framework:r="react"}){if(!e.issues.length)return;let n=ae(r);pe.log.warn(t),pe.log.info(`\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804: ${n.map(i=>`${i}@${m(e.projectPackageVersions[i]??"\uBBF8\uC124\uCE58")}`).join(", ")}`);let o=new Map;for(let i of e.issues){let s=o.get(i.itemKey)??[];s.push(i),o.set(i.itemKey,s)}for(let[i,s]of o.entries()){pe.log.warn(m(i));for(let a of s){let c=a.requiredRanges.join(" | ");if(a.type==="missing-package"){pe.log.info(` - ${a.packageName}: \uD328\uD0A4\uC9C0\uAC00 \uC124\uCE58\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC544\uC694. \uD544\uC694 \uBC94\uC704: ${c}`);continue}if(a.type==="invalid-version-spec"){pe.log.info(` - ${a.packageName}: \uD604\uC7AC \uBC84\uC804 \uD615\uC2DD\uC744 \uD574\uC11D\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694 (${a.installedVersionSpec}). \uD544\uC694 \uBC94\uC704: ${c}`);continue}pe.log.info(` - ${a.packageName}: \uD604\uC7AC ${a.installedVersionSpec}, \uD544\uC694 \uBC94\uC704 ${c}`)}}}function ot({publicRegistries:e,rootPath:t}){let r=[];for(let n of e)for(let o of n.items)o.snippets.some(s=>mr(s.path).some(a=>er.existsSync(tr.join(t,n.id,a))))&&r.push(`${n.id}:${o.id}`);return r}function ar(e,t="react"){let r=ae(t),n=Object.fromEntries(r.map(o=>[o,new Set]));for(let o of e.snippets)for(let[i,s]of Object.entries(o.dependencies??{}))pr(i,t)&&n[i].add(s);return n}function cr(e){let t=e.trim();if(t.startsWith(tt)&&(t=t.slice(tt.length).trim()),t.startsWith(nr)){let r=t.split("@").at(-1);if(!r)return null;t=r}return!t||t==="*"?null:rt(t)||st(t)?t:null}function lr({currentVersionSpec:e,requiredRange:t}){let r=st(t);return r?rt(e)?sr(e,r,{includePrerelease:!0}):rr(e,r,{includePrerelease:!0}):!1}function mr(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 pr(e,t="react"){return ae(t).includes(e)}var fr=re.object({itemIds:re.array(re.string()).optional(),all:re.boolean(),cwd:re.string(),baseUrl:re.string().default(K),seedReactVersion:re.string().optional(),framework:re.enum(["react","lynx"]).optional(),onDiff:re.enum(["overwrite","backup"]).optional()}),it=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:K}).option("--seed-react-version <version>","\uC9C0\uC815\uD55C SEED React \uBC84\uC804\uC758 \uB808\uC9C0\uC2A4\uD2B8\uB9AC \uC0AC\uC6A9 (\uC608: 1.2)").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=Y(r),i=typeof r?.cwd=="string"?r.cwd:process.cwd();j.intro("seed-design add");try{let s=fr.safeParse({itemIds:t,...r});if(!s.success)throw s.error;let{data:{all:a,...c}}=s;if(a)throw new $({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 p=c.cwd,y=Pe(c),w=y?.baseUrl??c.baseUrl,g=await $e(p),x=y?.framework??c.framework??g.framework,I=dr.resolve(p,g.path),{start:v,stop:E}=j.spinner();v("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let C=await(async()=>{try{let l=await Promise.all((await de({baseUrl:w,framework:x})).map(async({id:f})=>fe({baseUrl:w,framework:x,registryId:f})));return E("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),l}catch(l){throw E("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),l}})(),h=await(async()=>{if(c.itemIds?.length)return c.itemIds;let l=await j.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:C.filter(({hideFromCLICatalog:f})=>!f).flatMap(({id:f,items:T})=>T.filter(({hideFromCLICatalog:_})=>!_).sort((_,L)=>_.id.localeCompare(L.id)).map(({id:_,description:L,deprecated:M})=>({label:`${M?"(deprecated) ":""}${m(f)}:${_}`,value:`${f}:${_}`,hint:L,deprecated:M,registryItemCount:T.length}))).sort((f,T)=>f.deprecated!==T.deprecated?f.deprecated?1:-1:T.registryItemCount-f.registryItemCount)});if(j.isCancel(l))throw new D;return l})();if(!h?.length)throw new D("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC5B4\uC694.");j.log.message(`\uC120\uD0DD\uB41C \uD56D\uBAA9: ${m(h.join(", "))}`);let u=[];for(let l of h){let[f,...T]=l.split(":"),_=T.join(":");if(!f||!_)throw new $({message:`${m(l)}: \uD56D\uBAA9 \uC774\uB984\uC774 \uC798\uBABB\uB418\uC5C8\uC5B4\uC694.`,hint:`${m("ui:action-button")}\uACFC \uAC19\uC740 \uD615\uC2DD\uC73C\uB85C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});let L=C.find(M=>M.id===f)?.items.find(M=>M.id===_);if(!L)throw new $({message:`${m(l)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});if(L.deprecated){let M=await j.confirm({message:`${m(L.id)}: deprecated \uB418\uC5C8\uC5B4\uC694. \uCD94\uAC00\uD560\uAE4C\uC694?`,initialValue:!1});if(j.isCancel(M))throw new D;if(M===!1){j.log.info(`${m(L.id)}: \uCD94\uAC00\uD558\uC9C0 \uC54A\uC744\uAC8C\uC694.`);continue}}u.push(l)}let{registryItemsToAdd:b,npmDependenciesToAdd:k}=xe({selectedItemKeys:u,publicRegistries:C}),z=ye({publicRegistries:C,itemKeys:b.flatMap(({registryId:l,items:f})=>f.map(T=>`${l}:${T.id}`)),projectPackageVersions:ue(c.cwd,x),framework:x});he({report:z,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:x}),j.log.info(`\uCD94\uAC00\uD560 \uD56D\uBAA9: ${m(b.map(l=>l.items.map(f=>`${l.registryId}:${f.id}`).join(", ")).join(", ")||"\uC5C6\uC74C")}
|
|
2
|
+
import*as me from"@clack/prompts";import{cosmiconfig as kt}from"cosmiconfig";import{z as le}from"zod";import*as te from"@clack/prompts";import{ZodError as yt}from"zod";import ut from"picocolors";var l=e=>ut.cyan(e);var k=class extends Error{hint;details;constructor({message:r,hint:t,details:i=[],cause:s}){super(r,{cause:s}),this.name="CliError",this.hint=t,this.details=i}},D=class extends Error{constructor(r="\uC791\uC5C5\uC774 \uCDE8\uC18C\uB410\uC5B4\uC694."){super(r),this.name="CliCancelError"}};function q(e){return e instanceof D}function J(e){return!e||typeof e!="object"||!("verbose"in e)?!1:e.verbose===!0}function ht(e,r){if(e instanceof k)return{reason:e.message,hint:e.hint??r,details:e.details,stack:wt(e.cause??e)};if(e instanceof yt){let t=e.issues.map(i=>`${i.path.join(".")||"(root)"}: ${i.message}`);return{reason:"\uC785\uB825\uAC12 \uB610\uB294 \uC124\uC815 \uD30C\uC77C \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC544\uC694.",hint:r,details:t,stack:e.stack}}if(e instanceof Error){let t=e,i=[];return(t.escapedCommand||t.command)&&i.push(`\uC2E4\uD589 \uBA85\uB839\uC5B4: ${t.escapedCommand??t.command}`),typeof t.exitCode=="number"&&i.push(`\uC885\uB8CC \uCF54\uB4DC: ${t.exitCode}`),t.stderr?.trim()?i.push(`stderr: ${t.stderr.trim()}`):t.stdout?.trim()&&i.push(`stdout: ${t.stdout.trim()}`),{reason:t.shortMessage??e.message,hint:r,details:i,stack:e.stack}}return typeof e=="string"?{reason:e,hint:r,details:[]}:{reason:"\uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC5B4\uC694.",hint:r,details:[]}}function wt(e){if(e instanceof Error)return e.stack}function Y(e,{defaultMessage:r,defaultHint:t,verbose:i=!1}){let s=ht(e,t);te.log.error(r),te.log.error(`\uC6D0\uC778: ${s.reason}`);for(let n of s.details)te.log.info(n);s.hint&&te.log.info(`\uD574\uACB0 \uD78C\uD2B8: ${s.hint}`),i&&s.stack&&(te.log.message(l(`
|
|
3
|
+
[verbose] stack trace`)),te.log.message(s.stack)),te.outro(l("\uC791\uC5C5\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."))}import*as Q from"@clack/prompts";import It from"fs-extra";import De from"path";import bt from"findup-sync";import Ct from"fs-extra";var $t="package.json";function xt(e=process.cwd()){let r=bt($t,{cwd:e});if(!r)throw new Error("No package.json file found in the project.");return r}function ne(e=process.cwd()){let r=xt(e);return Ct.readJSONSync(r)}var G={rsc:!1,tsx:!0,framework:"react",path:"./seed-design",telemetry:!0};function ve(e){try{let r=ne(e),t={...r.dependencies,...r.devDependencies,...r.peerDependencies};if("@lynx-js/react"in t||"@seed-design/lynx-react"in t)return"lynx"}catch{}return"react"}async function Oe(e){let r=ve(e);return await Q.group({tsx:()=>Q.confirm({message:`${l("TypeScript")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:G.tsx}),rsc:()=>Q.confirm({message:`${l("React Server Components")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:G.rsc}),framework:()=>Q.select({message:`\uC5B4\uB5A4 ${l("\uD504\uB808\uC784\uC6CC\uD06C")}\uB97C \uC0AC\uC6A9\uD558\uC2DC\uB098\uC694?`,initialValue:r,options:[{value:"react",label:"React"},{value:"lynx",label:"Lynx"}]}),path:()=>Q.text({message:`${l("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:G.path,defaultValue:G.path,placeholder:G.path}),telemetry:()=>Q.confirm({message:`\uAC1C\uC120\uC744 \uC704\uD574 ${l("\uC775\uBA85 \uC0AC\uC6A9 \uB370\uC774\uD130")}\uB97C \uC218\uC9D1\uD560\uAE4C\uC694?`,initialValue:G.telemetry})},{onCancel:()=>{throw new D}})}async function Ce({cwd:e,config:r}){let t=De.resolve(e,"seed-design.json");return await It.writeFile(t,`${JSON.stringify(r,null,2)}
|
|
4
|
+
`,"utf-8"),{relativePath:De.relative(process.cwd(),t),targetPath:t}}var Le="seed-design",Pt=kt(Le,{searchPlaces:[`${Le}.json`]}),Me=le.object({$schema:le.string().optional(),rsc:le.coerce.boolean().default(!1),tsx:le.coerce.boolean().default(!0),framework:le.enum(["react","lynx"]).default("react"),path:le.string(),telemetry:le.coerce.boolean().optional().default(!0)}).strict();async function $e(e){let r=await ie(e);if(r)return r;me.log.error("\uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8 \uACBD\uB85C\uC5D0 `seed-design.json` \uD30C\uC77C\uC774 \uC5C6\uC5B4\uC694.");let t=await me.confirm({message:"seed-design.json \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uC2DC\uACA0\uC5B4\uC694?"});if(me.isCancel(t)||!t)throw new D;try{return await Ce({cwd:e,config:G}),me.log.message("seed-design.json \uD30C\uC77C\uC774 \uC0DD\uC131\uB410\uC5B4\uC694."),Me.parse(G)}catch(i){throw new k({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:i})}}async function ie(e){let r=await Pt.search(e);if(!r||r.isEmpty)return null;try{return Me.parse(r.config)}catch(t){throw new k({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:t})}}function xe({selectedItemKeys:e,publicRegistries:r}){let t=[],i=new Set;function s(n,o){let a=t.find(c=>c.registryId===n);if(!a?.items.some(c=>c.id===o.id)){if(a?a.items.push(o):t.push({registryId:n,items:[o]}),o.dependencies?.length)for(let c of o.dependencies)i.add(c);if(o.innerDependencies?.length)for(let c of o.innerDependencies)for(let m of c.itemIds){let g=r.find(C=>C.id===c.registryId)?.items.find(C=>C.id===m);if(!g)throw new Error(`Cannot find dependency item: ${c.registryId}:${m}`);s(c.registryId,g)}}}for(let n of e){let[o,...a]=n.split(":"),c=a.join(":");if(!o||!c)throw new Error(`Invalid snippet format: "${n}"`);let m=r.find(g=>g.id===o)?.items.find(g=>g.id===c);if(!m)throw new Error(`Cannot find snippet: "${n}"`);s(o,m)}return{registryItemsToAdd:t,npmDependenciesToAdd:i}}import*as je from"@clack/prompts";import{z as d}from"zod";var Te=d.object({id:d.string(),description:d.string().optional(),deprecated:d.boolean().optional(),hideFromCLICatalog:d.boolean().optional(),dependencies:d.array(d.string()).optional(),innerDependencies:d.array(d.object({registryId:d.string(),itemIds:d.array(d.string())})).optional(),snippets:d.array(d.object({path:d.string(),dependencies:d.record(d.string(),d.string()).optional(),content:d.string()}))}),_e=d.object({id:d.string(),hideFromCLICatalog:d.boolean().optional(),items:d.array(Te.omit({snippets:!0}).extend({snippets:d.array(d.object({path:d.string(),dependencies:d.record(d.string(),d.string()).optional()}))}))}),Ue=d.array(d.object({id:d.string()})),St=d.object({label:d.string(),path:d.string()}),Rt=d.object({id:d.string(),title:d.string(),description:d.string().optional(),docUrl:d.string(),deprecated:d.boolean().optional(),snippetKey:d.string().optional(),snippets:d.array(St).optional()}),Et=d.object({id:d.string(),label:d.string(),items:d.array(Rt)}),vt=d.object({id:d.string(),label:d.string(),sections:d.array(Et)}),Fe=d.object({categories:d.array(vt)});var Tt=1e4;async function Ke(e,r=Tt){let t=new AbortController,i=setTimeout(()=>t.abort(),r);try{return await fetch(e,{signal:t.signal})}catch(s){throw s instanceof Error&&s.name==="AbortError"?new k({message:`\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC5B4\uC694 (${r}ms): ${e}`,hint:"\uB124\uD2B8\uC6CC\uD06C \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uACE0 \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694."}):s}finally{clearTimeout(i)}}async function Ae({baseUrl:e}){let r=await fetch(`${e}/__docs__/index.json`);if(!r.ok)throw new k({message:`\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694: ${r.status} ${r.statusText}`});let t=await r.json(),{success:i,data:s,error:n}=Fe.safeParse(t);if(!i)throw new k({message:`\uBB38\uC11C \uBAA9\uB85D \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694: ${n?.message}`});return s}async function de({baseUrl:e,framework:r}){let t=await fetch(`${e}/__registry__/${r}/index.json`);if(!t.ok)throw new Error(`Failed to fetch registries: ${t.status} ${t.statusText}`);let i=await t.json(),{success:s,data:n,error:o}=Ue.safeParse(i);if(!s)throw new Error(`Failed to parse registries: ${o?.message}`);return n}async function fe({baseUrl:e,framework:r,registryId:t}){let i=await fetch(`${e}/__registry__/${r}/${t}/index.json`);if(!i.ok)throw new Error(`Failed to fetch ${t} registry: ${i.status} ${i.statusText}`);let s=await i.json(),{success:n,data:o,error:a}=_e.safeParse(s);if(!n)throw new Error(`Failed to parse ${t} registry: ${a?.message}`);return o}async function _t({baseUrl:e,framework:r,registryId:t,registryItemId:i}){let s=await fetch(`${e}/__registry__/${r}/${t}/${i}.json`);if(!s.ok)throw new Error(`Failed to fetch ${i}: ${s.status} ${s.statusText}`);let n=await s.json(),{success:o,data:a,error:c}=Te.safeParse(n);if(!o)throw new Error(`Failed to parse ${i}: ${c?.message}`);return a}async function Ne({url:e}){let r=await Ke(e);if(!r.ok)throw new k({message:`llms.txt\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694: ${r.status} ${r.statusText}`,hint:`${e} \uC5D0 \uC811\uADFC\uD560 \uC218 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694.`});return r.text()}async function Ve({baseUrl:e,query:r}){let t=r.startsWith("/")?r.slice(1):r,i=[`${e}/llms/${t}.txt`,`${e}/llms/${t}/llms.txt`],s;for(let n of i){let o;try{o=await Ke(n)}catch(a){s=a;continue}if(o.ok)return o.text();if(o.status===404){s=new k({message:`llms.txt\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694: ${t}`,hint:`\uB2E4\uC74C \uACBD\uB85C\uB97C \uC2DC\uB3C4\uD588\uC5B4\uC694:
|
|
5
|
+
${i.map(a=>` - ${a}`).join(`
|
|
6
|
+
`)}`});continue}throw new k({message:`llms.txt \uC694\uCCAD\uC774 \uC2E4\uD328\uD588\uC5B4\uC694: ${o.status} ${o.statusText}`,hint:`URL: ${n}`})}throw s??new k({message:`llms.txt\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694: ${t}`,hint:`\uB2E4\uC74C \uACBD\uB85C\uB97C \uC2DC\uB3C4\uD588\uC5B4\uC694:
|
|
7
|
+
${i.map(n=>` - ${n}`).join(`
|
|
8
|
+
`)}`})}async function ze({baseUrl:e,framework:r,registryId:t,registryItemIds:i}){return await Promise.all(i.map(async s=>{try{return await _t({baseUrl:e,framework:r,registryId:t,registryItemId:s})}catch(n){let o=await fetch(`${e}/__registry__/${r}/${t}/index.json`);if(!o.ok)throw new Error(`${t} \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694: ${o.status} ${o.statusText}`);let a=await o.json(),{success:c,data:m}=_e.safeParse(a);throw c?(je.log.error(`${s} \uC2A4\uB2C8\uD3AB\uC774 ${t} \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC5C6\uC5B4\uC694.`),je.log.info(`${t} \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC874\uC7AC\uD558\uB294 \uC2A4\uB2C8\uD3AB:
|
|
9
|
+
${m.items.map(g=>g.id).join(`
|
|
10
|
+
`)}`),n):new Error(`Failed to parse registry index for ${t}`)}}))}import{promises as Mt}from"fs";import{tmpdir as Ut}from"os";import Ge from"path";import{transformFromAstSync as jt}from"@babel/core";import At from"@babel/plugin-transform-typescript";import*as Ie from"recast";import{parse as Dt}from"@babel/parser";var Ot={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"]},Be=async({sourceFile:e,config:r})=>{let t=e.getFullText();if(r.tsx)return t;let i=Ie.parse(t,{parser:{parse:n=>Dt(n,Ot)}}),s=jt(i,t,{cloneInputAst:!1,code:!1,ast:!0,plugins:[At],configFile:!1});if(!s||!s.ast)throw new Error("Failed to transform JSX");return Ie.print(s.ast).code};import{SyntaxKind as Lt}from"ts-morph";var qe=async({sourceFile:e,config:r})=>{if(r.rsc)return e;let t=e.getFirstChildByKind(Lt.ExpressionStatement);if(!t)return e;let i=t.getExpression();if(!i)return e;let s=i.getText().trim();if(s!=='"use client"'&&s!=="'use client'")return e;let n=t.getText(),o=t.getFullText();if(n.trim()===o.trim())return e;let c=o.replace(n,"").replace(/^\s*\n/,"").replace(/\n\s*$/,"");return t.replaceWithText(c),e};import{Project as Ft,ScriptKind as Kt}from"ts-morph";var Nt=[qe],Vt=new Ft({compilerOptions:{}});async function zt(e){let r=await Mt.mkdtemp(Ge.join(Ut(),"seed-design-"));return Ge.join(r,e)}async function He(e){let r=await zt(e.filename),t=Vt.createSourceFile(r,e.raw,{scriptKind:Kt.TSX});for(let i of Nt)i({sourceFile:t,...e});return await Be({sourceFile:t,...e})}import*as H from"@clack/prompts";import ge from"fs-extra";import X from"path";import{createPatch as Bt}from"diff";import qt from"@npmcli/disparity-colors";async function ke({registryItemsToAdd:e,rootPath:r,cwd:t,baseUrl:i,framework:s,config:n,onDiff:o}){let a=[];for(let{registryId:c,items:m}of e){let g=X.join(r,c);ge.ensureDirSync(g);let C=await ze({baseUrl:i,framework:s,registryId:c,registryItemIds:m.map(u=>u.id)});for(let{id:u,snippets:$}of C){let I=await Promise.all($.map(async T=>{let x=await He({filename:T.path,config:n,raw:T.content}),y=X.join(g,T.path);return n.tsx||(y=y.replace(/\.tsx$/,".jsx"),y=y.replace(/\.ts$/,".js")),{filePath:y,content:x,relativePath:X.relative(t,y),name:`${c}:${u}`}})),A=[];for(let T of I){let{filePath:x,content:y,relativePath:h}=T;if(await ge.ensureDir(X.dirname(x)),ge.existsSync(x)){let w=await ge.readFile(x,"utf-8");if(w===y){H.log.info(`${l(h)}: \uC774\uBBF8 \uCD5C\uC2E0 \uC0C1\uD0DC\uC608\uC694.`);continue}let P=X.basename(x),F=X.extname(x),ee=X.basename(x,F),S=Date.now(),K=`legacy-${ee}-${S}${F}`,U=await(async()=>{if(o)return o;let W=Bt(h,w,y),b=qt(W);return H.log.message(`
|
|
11
|
+
${l(h)}: \uD604\uC7AC \uD30C\uC77C\uACFC \uBC1B\uC73C\uB824\uB294 \uD30C\uC77C\uC758 \uB0B4\uC6A9\uC774 \uB2EC\uB77C\uC694.
|
|
12
|
+
`),H.log.message(b),H.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:`${P} \uB36E\uC5B4\uC4F0\uAE30`},{value:"backup",label:`\uAE30\uC874 \uD30C\uC77C \uB0B4\uC6A9\uC744 ${K}\uC73C\uB85C \uC62E\uAE30\uACE0 ${P} \uBC1B\uAE30`},{value:"skip",label:"\uC0C8 \uD30C\uC77C \uBC1B\uC9C0 \uC54A\uACE0 \uADF8\uB300\uB85C \uB450\uAE30"}]})})();if(H.isCancel(U)||U==="skip"){H.log.info(`${l(h)}: \uD30C\uC77C\uC744 \uBC1B\uC9C0 \uC54A\uACE0 \uAC74\uB108\uB6F0\uC5C8\uC5B4\uC694.`);continue}if(U==="backup"){let W=X.dirname(x),b=X.join(W,K);await ge.rename(x,b),H.log.info(`${l(h)}: \uAE30\uC874 \uD30C\uC77C\uC744 ${l(X.relative(t,b))}\uB85C \uC62E\uACBC\uC5B4\uC694.`)}}await ge.writeFile(x,y),A.push(T)}if(A.length>0){let T=A.map(({name:x,relativePath:y})=>({name:x,path:y}));a.push(...T),H.log.success(`${l(`${c}:${u}`)} \uAD00\uB828 \uC2A4\uB2C8\uD3AB \uB2E4\uC6B4\uB85C\uB4DC \uC644\uB8CC: ${l(T.map(x=>x.path).join(", "))}`)}}}}import*as _ from"@clack/prompts";import fr from"path";import{z as re}from"zod";var N="https://seed-design.io";var We={"1.0":"https://v1-0.seed-design.io","1.1":"https://v1-1.seed-design.io","1.2":"https://v1-2.seed-design.io"};function Pe(e){let r=e.seedReactVersion?.trim();if(!r)return null;let t=We[r];if(!t)throw new k({message:`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 SEED React \uBC84\uC804\uC774\uC5D0\uC694: "${e.seedReactVersion}"`,hint:`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBC84\uC804: ${Object.keys(We).join(", ")}`});return{framework:"react",baseUrl:t}}function Se(e,r){for(let t=0;t<e.length;t++){let i=e[t];if(i===r)return e[t+1];if(i.startsWith(`${r}=`))return i.slice(r.length+1)}}import*as Ye from"@clack/prompts";import{execa as Ht}from"execa";import{detect as Gt}from"@antfu/ni";async function Je(e){let r=await Gt({programmatic:!0,cwd:e});return r==="yarn@berry"?"yarn":r==="pnpm@6"?"pnpm":r==="bun"?"bun":r==="deno"?"deno":r??"npm"}async function Re({cwd:e,deps:r,dev:t=!1}){let{start:i,stop:s}=Ye.spinner(),n=await Je(e),a={...ne(e).dependencies},c=new Set(r.filter(I=>!a[I])),m=new Set(r.filter(I=>a[I]));if(!c.size)return{installed:new Set,filtered:c};i("\uC758\uC874\uC131 \uC124\uCE58\uC911...");let u=[n==="npm"?"install":"add",t?"-D":null,...c].filter(I=>!!I),$=`${n} ${u.join(" ")}`;try{await Ht(n,u,{cwd:e})}catch(I){throw s("\uC758\uC874\uC131 \uC124\uCE58\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."),new k({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: ${$}`],cause:I})}return s("\uC758\uC874\uC131 \uC124\uCE58\uAC00 \uC644\uB8CC\uB410\uC5B4\uC694."),{installed:c,filtered:m}}import{randomUUID as Wt}from"node:crypto";import*as Xe from"@clack/prompts";var Jt="seed_cli";async function Yt(e){if(process.env.DISABLE_TELEMETRY==="true"||process.env.SEED_DISABLE_TELEMETRY==="true")return!1;try{if((await ie(e))?.telemetry===!1)return!1}catch{}return!0}function Qt(){return Wt()}var Xt=Qt(),Qe=!1;function Ze(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}function Zt(e){return e instanceof Error&&e.name?e.name:typeof e=="object"&&e!==null?e.constructor?.name??"Object":typeof e}async function et(e,{event:r,properties:t={}}){if(!await Yt(e))return;let s=`${Jt}.${r}`;Qe||(Xe.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)"),Qe=!0);try{let n="https://us.i.posthog.com/capture",o={"Content-Type":"application/json"},a={api_key:"phc_seod8HhifElOP1R92KmvsQybrtUmkOTgZBsq0mfCelR",event:s,distinct_id:Xt,properties:{...t,$process_person_profile:!1},timestamp:new Date().toISOString()},c=new AbortController,m=setTimeout(()=>c.abort(),5e3);try{await fetch(n,{method:"POST",headers:o,body:JSON.stringify(a),signal:c.signal})}finally{clearTimeout(m)}}catch{}}async function tt(e,{command:r,status:t,result:i,properties:s={}}){await et(e,{event:r,properties:Ze({status:t,result:i,...s})})}async function er(e,{command:r,error:t,result:i,properties:s={}}){await tt(e,{command:r,status:"failed",result:i,properties:Ze({error_type:Zt(t),...s})})}var v={track:et,trackCommandFailure:er,trackCommandOutcome:tt};import*as pe from"@clack/prompts";import tr from"fs-extra";import rr from"path";import{intersects as sr,satisfies as or,valid as st,validRange as ot}from"semver";var nr=["@seed-design/react","@seed-design/css"],ir=["@seed-design/lynx-react","@seed-design/lynx-css"];function ae(e){return e==="lynx"?ir:nr}var rt="workspace:",ar="npm:";function ue(e,r="react"){try{let t=ne(e),i={...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies},s={},n=ae(r);for(let o of n){let a=i[o];typeof a=="string"&&(s[o]=a)}return s}catch{return{}}}function ye({publicRegistries:e,itemKeys:r,projectPackageVersions:t,framework:i="react"}){let s=Array.from(new Set(r)),n=new Map(e.flatMap(c=>c.items.map(m=>[`${c.id}:${m.id}`,m]))),o=[],a=ae(i);for(let c of s){let m=n.get(c);if(!m)continue;let g=cr(m,i);for(let C of a){let u=Array.from(g[C]??[]);if(!u.length)continue;let $=t[C];if(!$){o.push({itemKey:c,packageName:C,requiredRanges:u,type:"missing-package"});continue}let I=lr($);if(!I){o.push({itemKey:c,packageName:C,requiredRanges:u,installedVersionSpec:$,type:"invalid-version-spec"});continue}u.every(T=>mr({currentVersionSpec:I,requiredRange:T}))||o.push({itemKey:c,packageName:C,requiredRanges:u,installedVersionSpec:$,type:"incompatible-version"})}}return{checkedItemKeys:s,projectPackageVersions:t,issues:o}}function he({report:e,title:r,framework:t="react"}){if(!e.issues.length)return;let i=ae(t);pe.log.warn(r),pe.log.info(`\uD604\uC7AC \uD504\uB85C\uC81D\uD2B8 \uBC84\uC804: ${i.map(n=>`${n}@${l(e.projectPackageVersions[n]??"\uBBF8\uC124\uCE58")}`).join(", ")}`);let s=new Map;for(let n of e.issues){let o=s.get(n.itemKey)??[];o.push(n),s.set(n.itemKey,o)}for(let[n,o]of s.entries()){pe.log.warn(l(n));for(let a of o){let c=a.requiredRanges.join(" | ");if(a.type==="missing-package"){pe.log.info(` - ${a.packageName}: \uD328\uD0A4\uC9C0\uAC00 \uC124\uCE58\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC544\uC694. \uD544\uC694 \uBC94\uC704: ${c}`);continue}if(a.type==="invalid-version-spec"){pe.log.info(` - ${a.packageName}: \uD604\uC7AC \uBC84\uC804 \uD615\uC2DD\uC744 \uD574\uC11D\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694 (${a.installedVersionSpec}). \uD544\uC694 \uBC94\uC704: ${c}`);continue}pe.log.info(` - ${a.packageName}: \uD604\uC7AC ${a.installedVersionSpec}, \uD544\uC694 \uBC94\uC704 ${c}`)}}}function nt({publicRegistries:e,rootPath:r}){let t=[];for(let i of e)for(let s of i.items)s.snippets.some(o=>pr(o.path).some(a=>tr.existsSync(rr.join(r,i.id,a))))&&t.push(`${i.id}:${s.id}`);return t}function cr(e,r="react"){let t=ae(r),i=Object.fromEntries(t.map(s=>[s,new Set]));for(let s of e.snippets)for(let[n,o]of Object.entries(s.dependencies??{}))dr(n,r)&&i[n].add(o);return i}function lr(e){let r=e.trim();if(r.startsWith(rt)&&(r=r.slice(rt.length).trim()),r.startsWith(ar)){let t=r.split("@").at(-1);if(!t)return null;r=t}return!r||r==="*"?null:st(r)||ot(r)?r:null}function mr({currentVersionSpec:e,requiredRange:r}){let t=ot(r);return t?st(e)?or(e,t,{includePrerelease:!0}):sr(e,t,{includePrerelease:!0}):!1}function pr(e){let r=new Set([e]);return e.endsWith(".tsx")&&r.add(`${e.slice(0,-4)}.jsx`),e.endsWith(".ts")&&r.add(`${e.slice(0,-3)}.js`),e.endsWith(".jsx")&&r.add(`${e.slice(0,-4)}.tsx`),e.endsWith(".js")&&r.add(`${e.slice(0,-3)}.ts`),Array.from(r)}function dr(e,r="react"){return ae(r).includes(e)}var gr=re.object({itemIds:re.array(re.string()).optional(),all:re.boolean(),cwd:re.string(),baseUrl:re.string().default(N),seedReactVersion:re.string().optional(),framework:re.enum(["react","lynx"]).optional(),onDiff:re.enum(["overwrite","backup"]).optional()}),it=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:N}).option("--seed-react-version <version>","\uC9C0\uC815\uD55C SEED React \uBC84\uC804\uC758 \uB808\uC9C0\uC2A4\uD2B8\uB9AC \uC0AC\uC6A9 (\uC608: 1.2)").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(r,t)=>{let i=Date.now(),s=J(t),n=typeof t?.cwd=="string"?t.cwd:process.cwd();_.intro("seed-design add");try{let o=Se(e.rawArgs,"--seed-react-version"),a=gr.safeParse({itemIds:r,...t,seedReactVersion:o});if(!a.success)throw a.error;let{data:{all:c,...m}}=a;if(c)throw new k({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 g=m.cwd,C=Pe(m),u=C?.baseUrl??m.baseUrl,$=await $e(g),I=C?.framework??m.framework??$.framework,A=fr.resolve(g,$.path),{start:T,stop:x}=_.spinner();T("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let y=await(async()=>{try{let p=await Promise.all((await de({baseUrl:u,framework:I})).map(async({id:f})=>fe({baseUrl:u,framework:I,registryId:f})));return x("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),p}catch(p){throw x("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),p}})(),h=await(async()=>{if(m.itemIds?.length)return m.itemIds;let p=await _.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:f})=>!f).flatMap(({id:f,items:E})=>E.filter(({hideFromCLICatalog:M})=>!M).sort((M,L)=>M.id.localeCompare(L.id)).map(({id:M,description:L,deprecated:R})=>({label:`${R?"(deprecated) ":""}${l(f)}:${M}`,value:`${f}:${M}`,hint:L,deprecated:R,registryItemCount:E.length}))).sort((f,E)=>f.deprecated!==E.deprecated?f.deprecated?1:-1:E.registryItemCount-f.registryItemCount)});if(_.isCancel(p))throw new D;return p})();if(!h?.length)throw new D("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC120\uD0DD\uB418\uC9C0 \uC54A\uC558\uC5B4\uC694.");_.log.message(`\uC120\uD0DD\uB41C \uD56D\uBAA9: ${l(h.join(", "))}`);let w=[];for(let p of h){let[f,...E]=p.split(":"),M=E.join(":");if(!f||!M)throw new k({message:`${l(p)}: \uD56D\uBAA9 \uC774\uB984\uC774 \uC798\uBABB\uB418\uC5C8\uC5B4\uC694.`,hint:`${l("ui:action-button")}\uACFC \uAC19\uC740 \uD615\uC2DD\uC73C\uB85C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});let L=y.find(R=>R.id===f)?.items.find(R=>R.id===M);if(!L)throw new k({message:`${l(p)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});if(L.deprecated){let R=await _.confirm({message:`${l(L.id)}: deprecated \uB418\uC5C8\uC5B4\uC694. \uCD94\uAC00\uD560\uAE4C\uC694?`,initialValue:!1});if(_.isCancel(R))throw new D;if(R===!1){_.log.info(`${l(L.id)}: \uCD94\uAC00\uD558\uC9C0 \uC54A\uC744\uAC8C\uC694.`);continue}}w.push(p)}let{registryItemsToAdd:P,npmDependenciesToAdd:F}=xe({selectedItemKeys:w,publicRegistries:y}),ee=ye({publicRegistries:y,itemKeys:P.flatMap(({registryId:p,items:f})=>f.map(E=>`${p}:${E.id}`)),projectPackageVersions:ue(m.cwd,I),framework:I});he({report:ee,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:I}),_.log.info(`\uCD94\uAC00\uD560 \uD56D\uBAA9: ${l(P.map(p=>p.items.map(f=>`${p.registryId}:${f.id}`).join(", ")).join(", ")||"\uC5C6\uC74C")}
|
|
13
13
|
|
|
14
|
-
\uC124\uCE58\uD560 \uC758\uC874\uC131: ${m(Array.from(k).join(", ")||"\uC5C6\uC74C")}`),await ke({registryItemsToAdd:b,rootPath:I,cwd:p,baseUrl:w,framework:x,config:g,onDiff:c.onDiff});let{installed:W,filtered:P}=await Se({cwd:p,deps:Array.from(k)});W.size===0&&j.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),W.size&&(j.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${m(Array.from(W).join(", "))}`),P.size&&j.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${m(Array.from(P).join(", "))}`)),j.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let V=Date.now()-n,U=new Set(b.map(l=>l.registryId)),S=h.some(l=>{let[f,...T]=l.split(":"),_=T.join(":");return C.find(L=>L.id===f)?.items.find(L=>L.id===_)?.deprecated});try{await R.trackCommandOutcome(c.cwd,{command:"add",status:"completed",properties:{items_count:u.length,registries:Array.from(U),has_deprecated:S,dependencies_count:k.size,duration_ms:V}})}catch(l){o&&console.error("[Telemetry] add \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",l)}}catch(s){if(G(s)){try{await R.trackCommandOutcome(i,{command:"add",status:"cancelled",properties:{duration_ms:Date.now()-n}})}catch(a){o&&console.error("[Telemetry] add \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}j.outro(m(s.message)),process.exit(0)}try{await R.trackCommandFailure(i,{command:"add",error:s,properties:{duration_ms:Date.now()-n}})}catch(a){o&&console.error("[Telemetry] add \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}Q(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 O from"@clack/prompts";import gr from"path";import{z as ee}from"zod";var ur=ee.object({registryIds:ee.array(ee.string()).optional(),all:ee.boolean(),includeDeprecated:ee.boolean().optional(),cwd:ee.string(),baseUrl:ee.string().default(K),seedReactVersion:ee.string().optional(),framework:ee.enum(["react","lynx"]).optional(),onDiff:ee.enum(["overwrite","backup"]).optional()}),nt=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:K}).option("--seed-react-version <version>","\uC9C0\uC815\uD55C SEED React \uBC84\uC804\uC758 \uB808\uC9C0\uC2A4\uD2B8\uB9AC \uC0AC\uC6A9 (\uC608: 1.2)").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=Y(r),i=typeof r?.cwd=="string"?r.cwd:process.cwd();O.intro("seed-design add-all");try{let s=ur.safeParse({registryIds:t,...r});if(!s.success)throw s.error;let{data:a}=s,c=a.cwd,p=Pe(a),y=p?.baseUrl??a.baseUrl,w=await $e(c),g=p?.framework??a.framework??w.framework,x=gr.resolve(c,w.path),{start:I,stop:v}=O.spinner();I("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let E=await(async()=>{try{let S=await Promise.all((await de({baseUrl:y,framework:g})).map(async({id:l})=>fe({baseUrl:y,framework:g,registryId:l})));return v("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),S}catch(S){throw v("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),S}})(),C=await(async()=>{if(a.all){let l=E.map(f=>f.id);return O.log.message(`\uBAA8\uB4E0 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${m(l.join(", "))}`),l}if(a.registryIds?.length){let l=E.map(f=>f.id);for(let f of a.registryIds)if(!l.includes(f))throw new $({message:`\uB808\uC9C0\uC2A4\uD2B8\uB9AC '${f}'\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,details:[`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uB808\uC9C0\uC2A4\uD2B8\uB9AC: ${l.join(", ")}`]});return O.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${m(a.registryIds.join(", "))}`),a.registryIds}let S=await O.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:E.filter(({hideFromCLICatalog:l})=>!l).sort((l,f)=>f.items.length-l.items.length).map(l=>{let f=l.items[0]?.id,T=f?`${l.items.length}\uAC1C \uD56D\uBAA9 (${f} \uB4F1)`:`${l.items.length}\uAC1C \uD56D\uBAA9 (\uD56D\uBAA9 \uC5C6\uC74C)`;return{label:l.id,value:l.id,hint:T}})});if(O.isCancel(S))throw new D;return O.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${m(S.join(", "))}`),S})(),h=E.filter(S=>C.includes(S.id)),u=h.flatMap(S=>S.items.filter(l=>l.deprecated?a.includeDeprecated:!0).map(l=>`${S.id}:${l.id}`)),b=h.reduce((S,l)=>S+l.items.filter(f=>f.deprecated).length,0);if(!a.includeDeprecated&&b>0&&O.log.info(`${b}\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.`),!u.length)throw new D("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694.");O.log.message(`\uCD1D ${m(u.length.toString())}\uAC1C\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4.`);let{registryItemsToAdd:k,npmDependenciesToAdd:z}=xe({selectedItemKeys:u,publicRegistries:E}),W=ye({publicRegistries:E,itemKeys:k.flatMap(({registryId:S,items:l})=>l.map(f=>`${S}:${f.id}`)),projectPackageVersions:ue(a.cwd,g),framework:g});he({report:W,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:g}),await ke({registryItemsToAdd:k,rootPath:x,cwd:c,baseUrl:y,framework:g,config:w,onDiff:a.onDiff});let{installed:P,filtered:V}=await Se({cwd:c,deps:Array.from(z)});P.size===0&&O.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),P.size&&(O.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${m(Array.from(P).join(", "))}`),V.size&&O.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${m(Array.from(V).join(", "))}`)),O.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let U=Date.now()-n;try{await R.trackCommandOutcome(a.cwd,{command:"add-all",status:"completed",properties:{registries:C,items_count:u.length,include_deprecated:a.includeDeprecated||!1,dependencies_count:z.size,duration_ms:U}})}catch(S){o&&console.error("[Telemetry] add-all \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",S)}}catch(s){if(G(s)){try{await R.trackCommandOutcome(i,{command:"add-all",status:"cancelled",properties:{duration_ms:Date.now()-n}})}catch(a){o&&console.error("[Telemetry] add-all \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}O.outro(m(s.message)),process.exit(0)}try{await R.trackCommandFailure(i,{command:"add-all",error:s,properties:{duration_ms:Date.now()-n}})}catch(a){o&&console.error("[Telemetry] add-all \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}Q(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 N from"@clack/prompts";import at from"path";import{z as B}from"zod";var yr=B.object({itemIds:B.array(B.string()).optional(),component:B.union([B.string(),B.array(B.string())]).optional(),all:B.boolean(),registry:B.string().optional(),cwd:B.string(),baseUrl:B.string().default(K),framework:B.enum(["react","lynx"]).optional()});function hr({itemIds:e,component:t}){let r=i=>i.trim().replace(/\s+/g,"-"),n=(e??[]).map(r).filter(Boolean),o=(Array.isArray(t)?t:[t]).filter(i=>!!i).flatMap(i=>i.split(",")).map(r).filter(Boolean);return Array.from(new Set([...n,...o]))}function wr({publicRegistries:e,targetInputs:t,defaultRegistry:r}){let n=e.filter(i=>typeof i.id=="string"&&Array.isArray(i.items)).flatMap(i=>i.items.filter(s=>typeof s.id=="string").map(s=>`${i.id}:${s.id}`)),o=new Set;for(let i of t){let s=i.includes(":")?i:r?`${r}:${i}`:(()=>{let a=n.filter(c=>c.endsWith(`:${i}`));if(!a.length)throw new $({message:`${m(i)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:`${m("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});if(a.length>1)throw new $({message:`${m(i)}: \uAC19\uC740 \uC774\uB984\uC758 \uD56D\uBAA9\uC774 \uC5EC\uB7EC \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC788\uC5B4\uC694.`,details:a.map(c=>`- ${c}`),hint:`${m("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});return a[0]})();if(!n.includes(s))throw new $({message:`${m(s)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});o.add(s)}return Array.from(o)}var ct=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:K}).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=Y(r),i=typeof r?.cwd=="string"?r.cwd:process.cwd();N.intro("seed-design compat");try{let s=yr.safeParse({itemIds:t,...r});if(!s.success)throw s.error;let{data:a}=s,c=await ne(a.cwd),p=a.framework??c?.framework??"react",{start:y,stop:w}=N.spinner();y("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let g=await(async()=>{try{let u=await Promise.all((await de({baseUrl:a.baseUrl,framework:p})).map(async({id:b})=>fe({baseUrl:a.baseUrl,framework:p,registryId:b})));return w("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),u}catch(u){throw w("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),u}})(),x=hr({itemIds:a.itemIds,component:a.component}),I=a.all?g.flatMap(b=>b.items.map(k=>`${b.id}:${k.id}`)):x.length>0?wr({publicRegistries:g,targetInputs:x,defaultRegistry:a.registry}):ne(a.cwd),v=Array.isArray(I)?I:await(async()=>{let u=await I;if(!u)throw new $({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=at.resolve(a.cwd,u.path),k=ot({publicRegistries:g,rootPath:b});return k.length?k:(N.log.info(`${m(at.relative(a.cwd,b)||u.path)}\uC5D0\uC11C \uC124\uCE58\uB41C \uC2A4\uB2C8\uD3AB\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.`),[])})();if(!v.length){try{await R.trackCommandOutcome(a.cwd,{command:"compat",status:"completed",result:"empty",properties:{duration_ms:Date.now()-n}})}catch(u){o&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",u)}N.outro("\uAC80\uC0AC\uD560 \uC2A4\uB2C8\uD3AB\uC774 \uC5C6\uC5B4\uC694."),process.exit(0)}let E=ue(a.cwd,p),C=ye({publicRegistries:g,itemKeys:v,projectPackageVersions:E,framework:p});if(N.log.info(`\uAC80\uC0AC \uB300\uC0C1: ${m(C.checkedItemKeys.join(", "))}`),!C.issues.length){let u=ae(p);N.outro(`\uBAA8\uB4E0 \uC2A4\uB2C8\uD3AB\uC774 \uD604\uC7AC ${u.join(", ")}\uC640 \uD638\uD658\uB3FC\uC694.`);try{await R.trackCommandOutcome(a.cwd,{command:"compat",status:"completed",result:"compatible",properties:{checked_items_count:C.checkedItemKeys.length,incompatible_items_count:0,duration_ms:Date.now()-n}})}catch(b){o&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",b)}process.exit(0)}he({report:C,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:p});let h=ae(p);N.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.`),N.outro("\uD638\uD658\uC131 \uC774\uC288\uAC00 \uC788\uC5B4\uC694.");try{await R.trackCommandOutcome(a.cwd,{command:"compat",status:"completed",result:"incompatible",properties:{checked_items_count:C.checkedItemKeys.length,incompatible_items_count:new Set(C.issues.map(u=>u.itemKey)).size,issue_count:C.issues.length,duration_ms:Date.now()-n}})}catch(u){o&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",u)}process.exit(1)}catch(s){if(G(s)){try{await R.trackCommandOutcome(i,{command:"compat",status:"cancelled",properties:{duration_ms:Date.now()-n}})}catch(a){o&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}N.outro(m(s.message)),process.exit(0)}try{await R.trackCommandFailure(i,{command:"compat",error:s,properties:{duration_ms:Date.now()-n}})}catch(a){o&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}Q(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 A from"@clack/prompts";import{z as se}from"zod";var br="https://raw.githubusercontent.com/daangn/seed-design/refs/heads/dev/docs/registry",Cr=se.object({query:se.union([se.string(),se.array(se.string())]).optional().transform(e=>{let r=(Array.isArray(e)?e.join(" "):e)?.trim();return r||void 0}),baseUrl:se.string().optional(),cwd:se.string().default(process.cwd()),framework:se.enum(["react","lynx"]).optional(),raw:se.boolean()});function lt(e,t){return`${br}/${e}/${t}`}function $r(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[i]=e.snippetKey.split(":");if(i)if(e.snippets.length===1)o.push(`- snippet: ${lt(i,e.snippets[0].path)}`);else{o.push("- snippet:");for(let s of e.snippets)o.push(` - ${s.label}: ${lt(i,s.path)}`)}}A.log.message(o.join(`
|
|
15
|
-
`))}function
|
|
16
|
-
`)}function
|
|
14
|
+
\uC124\uCE58\uD560 \uC758\uC874\uC131: ${l(Array.from(F).join(", ")||"\uC5C6\uC74C")}`),await ke({registryItemsToAdd:P,rootPath:A,cwd:g,baseUrl:u,framework:I,config:$,onDiff:m.onDiff});let{installed:S,filtered:K}=await Re({cwd:g,deps:Array.from(F)});S.size===0&&_.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),S.size&&(_.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${l(Array.from(S).join(", "))}`),K.size&&_.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${l(Array.from(K).join(", "))}`)),_.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let U=Date.now()-i,W=new Set(P.map(p=>p.registryId)),b=h.some(p=>{let[f,...E]=p.split(":"),M=E.join(":");return y.find(L=>L.id===f)?.items.find(L=>L.id===M)?.deprecated});try{await v.trackCommandOutcome(m.cwd,{command:"add",status:"completed",properties:{items_count:w.length,registries:Array.from(W),has_deprecated:b,dependencies_count:F.size,duration_ms:U}})}catch(p){s&&console.error("[Telemetry] add \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",p)}}catch(o){if(q(o)){try{await v.trackCommandOutcome(n,{command:"add",status:"cancelled",properties:{duration_ms:Date.now()-i}})}catch(a){s&&console.error("[Telemetry] add \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}_.outro(l(o.message)),process.exit(0)}try{await v.trackCommandFailure(n,{command:"add",error:o,properties:{duration_ms:Date.now()-i}})}catch(a){s&&console.error("[Telemetry] add \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}Y(o,{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:s}),process.exit(1)}})};import*as O from"@clack/prompts";import ur from"path";import{z as Z}from"zod";var yr=Z.object({registryIds:Z.array(Z.string()).optional(),all:Z.boolean(),includeDeprecated:Z.boolean().optional(),cwd:Z.string(),baseUrl:Z.string().default(N),seedReactVersion:Z.string().optional(),framework:Z.enum(["react","lynx"]).optional(),onDiff:Z.enum(["overwrite","backup"]).optional()}),at=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:N}).option("--seed-react-version <version>","\uC9C0\uC815\uD55C SEED React \uBC84\uC804\uC758 \uB808\uC9C0\uC2A4\uD2B8\uB9AC \uC0AC\uC6A9 (\uC608: 1.2)").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(r,t)=>{let i=Date.now(),s=J(t),n=typeof t?.cwd=="string"?t.cwd:process.cwd();O.intro("seed-design add-all");try{let o=Se(e.rawArgs,"--seed-react-version"),a=yr.safeParse({registryIds:r,...t,seedReactVersion:o});if(!a.success)throw a.error;let{data:c}=a,m=c.cwd,g=Pe(c),C=g?.baseUrl??c.baseUrl,u=await $e(m),$=g?.framework??c.framework??u.framework,I=ur.resolve(m,u.path),{start:A,stop:T}=O.spinner();A("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let x=await(async()=>{try{let b=await Promise.all((await de({baseUrl:C,framework:$})).map(async({id:p})=>fe({baseUrl:C,framework:$,registryId:p})));return T("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),b}catch(b){throw T("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),b}})(),y=await(async()=>{if(c.all){let p=x.map(f=>f.id);return O.log.message(`\uBAA8\uB4E0 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${l(p.join(", "))}`),p}if(c.registryIds?.length){let p=x.map(f=>f.id);for(let f of c.registryIds)if(!p.includes(f))throw new k({message:`\uB808\uC9C0\uC2A4\uD2B8\uB9AC '${f}'\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,details:[`\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uB808\uC9C0\uC2A4\uD2B8\uB9AC: ${p.join(", ")}`]});return O.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uBAA8\uB4E0 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${l(c.registryIds.join(", "))}`),c.registryIds}let b=await O.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:x.filter(({hideFromCLICatalog:p})=>!p).sort((p,f)=>f.items.length-p.items.length).map(p=>{let f=p.items[0]?.id,E=f?`${p.items.length}\uAC1C \uD56D\uBAA9 (${f} \uB4F1)`:`${p.items.length}\uAC1C \uD56D\uBAA9 (\uD56D\uBAA9 \uC5C6\uC74C)`;return{label:p.id,value:p.id,hint:E}})});if(O.isCancel(b))throw new D;return O.log.message(`\uC120\uD0DD\uB41C \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4: ${l(b.join(", "))}`),b})(),h=x.filter(b=>y.includes(b.id)),w=h.flatMap(b=>b.items.filter(p=>p.deprecated?c.includeDeprecated:!0).map(p=>`${b.id}:${p.id}`)),P=h.reduce((b,p)=>b+p.items.filter(f=>f.deprecated).length,0);if(!c.includeDeprecated&&P>0&&O.log.info(`${P}\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.`),!w.length)throw new D("\uCD94\uAC00\uD560 \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694.");O.log.message(`\uCD1D ${l(w.length.toString())}\uAC1C\uC758 \uD56D\uBAA9\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4.`);let{registryItemsToAdd:F,npmDependenciesToAdd:ee}=xe({selectedItemKeys:w,publicRegistries:x}),S=ye({publicRegistries:x,itemKeys:F.flatMap(({registryId:b,items:p})=>p.map(f=>`${b}:${f.id}`)),projectPackageVersions:ue(c.cwd,$),framework:$});he({report:S,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:$}),await ke({registryItemsToAdd:F,rootPath:I,cwd:m,baseUrl:C,framework:$,config:u,onDiff:c.onDiff});let{installed:K,filtered:U}=await Re({cwd:m,deps:Array.from(ee)});K.size===0&&O.log.message("\uBAA8\uB4E0 \uC758\uC874\uC131\uC774 \uC774\uBBF8 \uC124\uCE58\uB418\uC5B4 \uC788\uC5B4\uC694."),K.size&&(O.log.message(`\uC758\uC874\uC131 \uC124\uCE58 \uC644\uB8CC: ${l(Array.from(K).join(", "))}`),U.size&&O.log.message(`\uC124\uCE58\uD558\uC9C0 \uC54A\uC740 \uC758\uC874\uC131 (\uC774\uBBF8 \uC124\uCE58\uB428): ${l(Array.from(U).join(", "))}`)),O.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let W=Date.now()-i;try{await v.trackCommandOutcome(c.cwd,{command:"add-all",status:"completed",properties:{registries:y,items_count:w.length,include_deprecated:c.includeDeprecated||!1,dependencies_count:ee.size,duration_ms:W}})}catch(b){s&&console.error("[Telemetry] add-all \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",b)}}catch(o){if(q(o)){try{await v.trackCommandOutcome(n,{command:"add-all",status:"cancelled",properties:{duration_ms:Date.now()-i}})}catch(a){s&&console.error("[Telemetry] add-all \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}O.outro(l(o.message)),process.exit(0)}try{await v.trackCommandFailure(n,{command:"add-all",error:o,properties:{duration_ms:Date.now()-i}})}catch(a){s&&console.error("[Telemetry] add-all \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}Y(o,{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:s}),process.exit(1)}})};import*as V from"@clack/prompts";import ct from"path";import{z}from"zod";var hr=z.object({itemIds:z.array(z.string()).optional(),component:z.union([z.string(),z.array(z.string())]).optional(),all:z.boolean(),registry:z.string().optional(),cwd:z.string(),baseUrl:z.string().default(N),framework:z.enum(["react","lynx"]).optional()});function wr({itemIds:e,component:r}){let t=n=>n.trim().replace(/\s+/g,"-"),i=(e??[]).map(t).filter(Boolean),s=(Array.isArray(r)?r:[r]).filter(n=>!!n).flatMap(n=>n.split(",")).map(t).filter(Boolean);return Array.from(new Set([...i,...s]))}function br({publicRegistries:e,targetInputs:r,defaultRegistry:t}){let i=e.filter(n=>typeof n.id=="string"&&Array.isArray(n.items)).flatMap(n=>n.items.filter(o=>typeof o.id=="string").map(o=>`${n.id}:${o.id}`)),s=new Set;for(let n of r){let o=n.includes(":")?n:t?`${t}:${n}`:(()=>{let a=i.filter(c=>c.endsWith(`:${n}`));if(!a.length)throw new k({message:`${l(n)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`,hint:`${l("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});if(a.length>1)throw new k({message:`${l(n)}: \uAC19\uC740 \uC774\uB984\uC758 \uD56D\uBAA9\uC774 \uC5EC\uB7EC \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 \uC788\uC5B4\uC694.`,details:a.map(c=>`- ${c}`),hint:`${l("ui:action-button")}\uCC98\uB7FC registry\uB97C \uD3EC\uD568\uD574\uC11C \uC785\uB825\uD574\uBCF4\uC138\uC694.`});return a[0]})();if(!i.includes(o))throw new k({message:`${l(o)}: \uD56D\uBAA9\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.`});s.add(o)}return Array.from(s)}var lt=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:N}).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(r,t)=>{let i=Date.now(),s=J(t),n=typeof t?.cwd=="string"?t.cwd:process.cwd();V.intro("seed-design compat");try{let o=hr.safeParse({itemIds:r,...t});if(!o.success)throw o.error;let{data:a}=o,c=await ie(a.cwd),m=a.framework??c?.framework??"react",{start:g,stop:C}=V.spinner();g("Registry\uB97C \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");let u=await(async()=>{try{let h=await Promise.all((await de({baseUrl:a.baseUrl,framework:m})).map(async({id:w})=>fe({baseUrl:a.baseUrl,framework:m,registryId:w})));return C("Registry\uB97C \uAC00\uC838\uC654\uC5B4\uC694."),h}catch(h){throw C("Registry\uB97C \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),h}})(),$=wr({itemIds:a.itemIds,component:a.component}),I=a.all?u.flatMap(w=>w.items.map(P=>`${w.id}:${P.id}`)):$.length>0?br({publicRegistries:u,targetInputs:$,defaultRegistry:a.registry}):ie(a.cwd),A=Array.isArray(I)?I:await(async()=>{let h=await I;if(!h)throw new k({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 w=ct.resolve(a.cwd,h.path),P=nt({publicRegistries:u,rootPath:w});return P.length?P:(V.log.info(`${l(ct.relative(a.cwd,w)||h.path)}\uC5D0\uC11C \uC124\uCE58\uB41C \uC2A4\uB2C8\uD3AB\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.`),[])})();if(!A.length){try{await v.trackCommandOutcome(a.cwd,{command:"compat",status:"completed",result:"empty",properties:{duration_ms:Date.now()-i}})}catch(h){s&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",h)}V.outro("\uAC80\uC0AC\uD560 \uC2A4\uB2C8\uD3AB\uC774 \uC5C6\uC5B4\uC694."),process.exit(0)}let T=ue(a.cwd,m),x=ye({publicRegistries:u,itemKeys:A,projectPackageVersions:T,framework:m});if(V.log.info(`\uAC80\uC0AC \uB300\uC0C1: ${l(x.checkedItemKeys.join(", "))}`),!x.issues.length){let h=ae(m);V.outro(`\uBAA8\uB4E0 \uC2A4\uB2C8\uD3AB\uC774 \uD604\uC7AC ${h.join(", ")}\uC640 \uD638\uD658\uB3FC\uC694.`);try{await v.trackCommandOutcome(a.cwd,{command:"compat",status:"completed",result:"compatible",properties:{checked_items_count:x.checkedItemKeys.length,incompatible_items_count:0,duration_ms:Date.now()-i}})}catch(w){s&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",w)}process.exit(0)}he({report:x,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:m});let y=ae(m);V.log.info(`\uD544\uC694\uD55C \uBC84\uC804\uC73C\uB85C ${y.join(" \uB610\uB294 ")}\uB97C \uB9DE\uCD98 \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574\uBCF4\uC138\uC694.`),V.outro("\uD638\uD658\uC131 \uC774\uC288\uAC00 \uC788\uC5B4\uC694.");try{await v.trackCommandOutcome(a.cwd,{command:"compat",status:"completed",result:"incompatible",properties:{checked_items_count:x.checkedItemKeys.length,incompatible_items_count:new Set(x.issues.map(h=>h.itemKey)).size,issue_count:x.issues.length,duration_ms:Date.now()-i}})}catch(h){s&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",h)}process.exit(1)}catch(o){if(q(o)){try{await v.trackCommandOutcome(n,{command:"compat",status:"cancelled",properties:{duration_ms:Date.now()-i}})}catch(a){s&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}V.outro(l(o.message)),process.exit(0)}try{await v.trackCommandFailure(n,{command:"compat",error:o,properties:{duration_ms:Date.now()-i}})}catch(a){s&&console.error("[Telemetry] compat \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",a)}Y(o,{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:s}),process.exit(1)}})};import*as j from"@clack/prompts";import{z as se}from"zod";var Cr="https://raw.githubusercontent.com/daangn/seed-design/refs/heads/dev/docs/registry",$r=se.object({query:se.union([se.string(),se.array(se.string())]).optional().transform(e=>{let t=(Array.isArray(e)?e.join(" "):e)?.trim();return t||void 0}),baseUrl:se.string().optional(),cwd:se.string().default(process.cwd()),framework:se.enum(["react","lynx"]).optional(),raw:se.boolean()});function mt(e,r){return`${Cr}/${e}/${r}`}function xr(e,r){let t=`${r}${e.docUrl}`,i=`${r}/llms${e.docUrl}.txt`,s=[e.id,`- docs: ${t}`,`- llms.txt: ${i}`];if(e.snippetKey&&e.snippets&&e.snippets.length>0){let[n]=e.snippetKey.split(":");if(n)if(e.snippets.length===1)s.push(`- snippet: ${mt(n,e.snippets[0].path)}`);else{s.push("- snippet:");for(let o of e.snippets)s.push(` - ${o.label}: ${mt(n,o.path)}`)}}j.log.message(s.join(`
|
|
15
|
+
`))}function Ir(e,r){let t=e.length,i=r.length,s=Array.from({length:t+1},(n,o)=>Array.from({length:i+1},(a,c)=>o===0?c:c===0?o:0));for(let n=1;n<=t;n++)for(let o=1;o<=i;o++)s[n][o]=Math.min(s[n-1][o]+1,s[n][o-1]+1,s[n-1][o-1]+(e[n-1]!==r[o-1]?1:0));return s[t][i]}function ce(e,r,t=3){let i=e.toLowerCase();return r.map(s=>({value:s,dist:Ir(i,s.toLowerCase())})).filter(({dist:s})=>s>0&&s<=t).sort((s,n)=>s.dist-n.dist).map(({value:s})=>s)}function kr(e,r){if(e.length===0)return;let t=[],i=r.map(o=>o.id),s=ce(e[0],i);if(s.length===0){let o=r.flatMap(m=>m.sections.flatMap(g=>g.items.map(C=>`${m.id}/${g.id}/${C.id}`))),a=e.join("/"),c=ce(a,o,5);c.length>0&&t.push(...c.slice(0,3))}else{let o=r.find(a=>a.id===s[0]);if(o&&e.length>=2){let a=o.sections.map(m=>m.id),c=ce(e[1],a);if(c.length>0){let m=o.sections.find(g=>g.id===c[0]);if(m&&e.length>=3){let g=m.items.map(u=>u.id),C=ce(e[2],g);for(let u of C.slice(0,3))t.push(`${o.id}/${m.id}/${u}`)}else for(let g of c.slice(0,3))t.push(`${o.id}/${g}`)}else{let m=o.sections.flatMap(C=>C.items.map(u=>({path:`${o.id}/${C.id}/${u.id}`,id:u.id}))),g=ce(e[1],m.map(C=>C.id));for(let C of g.slice(0,3)){let u=m.find($=>$.id===C);u&&t.push(u.path)}}}else for(let a of s.slice(0,3))t.push(a)}if(t.length===0)return;let n=["","\u{1F4A1} \uC774\uAC83\uC744 \uC758\uBBF8\uD588\uB098\uC694?"];for(let o of t)n.push(` - ${o}`);return n.join(`
|
|
16
|
+
`)}function dt(e){return e.split(/[\/\s]+/).map(r=>r.trim()).filter(Boolean)}function Pr(e){let[,r]=e.split(":");return r??e}function Sr({query:e,framework:r,categoryIds:t}){if(!e)return;let i=dt(e).map(Pr);if(!i.length)return;let[s]=i;return!t.includes(s)&&r&&t.includes(r)?[r,...i].join("/"):i.join("/")}function Rr(e,r){let t=r.toLowerCase();return e.flatMap(i=>i.sections.flatMap(s=>s.items.filter(n=>n.id.toLowerCase().includes(t)||n.title.toLowerCase().includes(t)).map(n=>({item:n,categoryLabel:i.label,sectionLabel:s.label}))))}async function we(e){let r=await j.select({message:"\uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694",options:e.map(t=>({label:`${t.deprecated?"(deprecated) ":""}${t.title}`,value:t,hint:t.description}))});if(j.isCancel(r))throw new D;return r}async function pt(e){let r=await j.select({message:"\uC139\uC158\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694",options:e.map(t=>({label:t.label,value:t,hint:`${t.items.length}\uAC1C \uD56D\uBAA9`}))});if(j.isCancel(r))throw new D;return r}async function Er(e){let r=await j.select({message:"\uCE74\uD14C\uACE0\uB9AC\uB97C \uC120\uD0DD\uD574\uC8FC\uC138\uC694",options:e.map(t=>({label:t.label,value:t,hint:`${t.sections.reduce((i,s)=>i+s.items.length,0)}\uAC1C \uD56D\uBAA9`}))});if(j.isCancel(r))throw new D;return r}var ft=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: ${N})`,{default:N}).option("--cwd <cwd>","the working directory. defaults to the current directory.",{default:process.cwd()}).option("-f, --framework <framework>","\uD504\uB808\uC784\uC6CC\uD06C (react \uB610\uB294 lynx)").option("--raw","llms.txt \uB0B4\uC6A9\uC744 \uC9C1\uC811 \uAC00\uC838\uC640 \uCD9C\uB825\uD569\uB2C8\uB2E4. LLM \uD30C\uC774\uD504\uC5D0 \uC720\uC6A9\uD569\uB2C8\uB2E4.",{default:!1}).example("seed-design docs").example("seed-design docs action-button").example("seed-design docs react").example("seed-design docs lynx action-button").example("seed-design docs react/components").example("seed-design docs react/components/action-button").example("seed-design docs react/updates/changelog --raw").action(async(r,t)=>{let i=Date.now(),s=J(t),n=t.raw??!1,o=process.cwd();n||j.intro("seed-design docs");try{let a=$r.safeParse({query:r,...t});if(!a.success)throw a.error;let{data:c}=a;o=c.cwd;let m=c.baseUrl??N,g=await ie(c.cwd).catch(()=>null),C=c.framework??g?.framework;if(c.raw&&!c.query)throw new k({message:"--raw \uBAA8\uB4DC\uC5D0\uC11C\uB294 \uCFFC\uB9AC\uAC00 \uD544\uC694\uD574\uC694.",hint:"\uC608: `seed-design docs react/updates/changelog --raw`"});let u=await(async()=>{if(n)return await Ae({baseUrl:m});let{start:y,stop:h}=j.spinner();y("\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC624\uACE0 \uC788\uC5B4\uC694...");try{let w=await Ae({baseUrl:m});return h("\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC654\uC5B4\uC694."),w}catch(w){throw h("\uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC624\uC9C0 \uBABB\uD588\uC5B4\uC694."),w}})(),{categories:$}=u,I=Sr({query:c.query,framework:C,categoryIds:$.map(y=>y.id)}),A,T=async()=>{if(I){let w=dt(I);if(n&&w.length>3)return;let P=$.find(S=>S.id===w[0]);if(P&&w.length>=2){let S=P.sections.find(b=>b.id===w[1]);if(S&&w.length>=3){let b=S.items.find(E=>E.id===w[2]);if(b)return b;let p=w[2].toLowerCase(),f=S.items.filter(E=>E.id.toLowerCase().includes(p)||E.title.toLowerCase().includes(p));if(f.length===0){let E=ce(w[2],S.items.map(L=>L.id)),M=E.length>0?`
|
|
17
17
|
|
|
18
18
|
\u{1F4A1} \uC774\uAC83\uC744 \uC758\uBBF8\uD588\uB098\uC694?
|
|
19
|
-
${
|
|
20
|
-
`)}`:"";throw new
|
|
19
|
+
${E.slice(0,3).map(L=>` - ${P.id}/${S.id}/${L}`).join(`
|
|
20
|
+
`)}`:"";throw new k({message:`${l(I)}: \uBB38\uC11C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.${M}`,hint:`\`seed-design docs ${P.id}/${S.id}\`\uB85C \uBAA9\uB85D\uC744 \uD655\uC778\uD574\uBCF4\uC138\uC694.`})}return f.length===1?f[0]:await we(f)}if(S)return await we(S.items);let K=w[1].toLowerCase(),U=P.sections.flatMap(b=>b.items.filter(p=>p.id.toLowerCase().includes(K)||p.title.toLowerCase().includes(K)).map(p=>({item:p,sectionLabel:b.label})));if(U.length===0){let b=P.sections.map(R=>R.id),p=ce(w[1],b),f=P.sections.flatMap(R=>R.items.map(be=>({path:`${P.id}/${R.id}/${be.id}`,id:be.id}))),E=ce(w[1],f.map(R=>R.id)),M=[...p.slice(0,2).map(R=>`${P.id}/${R}`),...E.slice(0,2).map(R=>f.find(be=>be.id===R)?.path).filter(R=>R!=null)],L=M.length>0?`
|
|
21
21
|
|
|
22
22
|
\u{1F4A1} \uC774\uAC83\uC744 \uC758\uBBF8\uD588\uB098\uC694?
|
|
23
|
-
${
|
|
24
|
-
`)}`:"";throw new
|
|
23
|
+
${M.map(R=>` - ${R}`).join(`
|
|
24
|
+
`)}`:"";throw new k({message:`${l(I)}: \uBB38\uC11C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.${L}`,hint:`\`seed-design docs ${P.id}\`\uB85C \uBAA9\uB85D\uC744 \uD655\uC778\uD574\uBCF4\uC138\uC694.`})}if(U.length===1)return U[0].item;let W=await j.select({message:`${l(w[1])}\uC5D0 \uD574\uB2F9\uD558\uB294 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694`,options:U.map(({item:b,sectionLabel:p})=>({label:`[${p}] ${b.title}`,value:b,hint:b.description}))});if(j.isCancel(W))throw new D;return W}if(P){if(P.sections.length===1)return await we(P.sections[0].items);let S=await pt(P.sections);return await we(S.items)}let F=Rr($,I);if(F.length===0){let S=kr(w,$);throw new k({message:`${l(I)}: \uBB38\uC11C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4\uC694.${S??""}`,hint:"`seed-design docs`\uB85C \uC804\uCCB4 \uBAA9\uB85D\uC744 \uD655\uC778\uD574\uBCF4\uC138\uC694."})}if(F.length===1)return F[0].item;let ee=await j.select({message:`${l(I)}\uC5D0 \uD574\uB2F9\uD558\uB294 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694`,options:F.map(({item:S,categoryLabel:K,sectionLabel:U})=>({label:`[${K} > ${U}] ${S.title}`,value:S,hint:S.description}))});if(j.isCancel(ee))throw new D;return ee}let y=await Er($),h;return y.sections.length===1?h=y.sections[0]:h=await pt(y.sections),await we(h.items)};if(n)try{A=await T()}catch(y){if(q(y))throw y}else A=await T();if(n){let y;if(A){let h=`${m}/llms${A.docUrl}.txt`;y=await Ne({url:h})}else y=await Ve({baseUrl:m,query:I});console.log(y)}else xr(A,m),j.outro("\uC644\uB8CC\uD588\uC5B4\uC694.");let x=Date.now()-i;try{await v.trackCommandOutcome(o,{command:"docs",status:"completed",properties:{query:c.query??null,item_id:A?.id??c.query??null,has_snippet:!!(A?.snippets&&A.snippets.length>0),raw_mode:n,duration_ms:x}})}catch(y){s&&console.error("[Telemetry] docs \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",y)}}catch(a){if(q(a)){try{await v.trackCommandOutcome(o,{command:"docs",status:"cancelled",properties:{raw_mode:n,duration_ms:Date.now()-i}})}catch(c){s&&console.error("[Telemetry] docs \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",c)}n||j.outro(l(a.message)),process.exit(0)}try{await v.trackCommandFailure(o,{command:"docs",error:a,properties:{raw_mode:n,duration_ms:Date.now()-i}})}catch(c){s&&console.error("[Telemetry] docs \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",c)}if(n){let c=a instanceof Error?a.message:String(a);console.error(c),process.exit(1)}Y(a,{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:s}),process.exit(1)}})};import*as B from"@clack/prompts";import{z as Ee}from"zod";import vr from"dedent";var Tr=Ee.object({cwd:Ee.string(),yes:Ee.boolean().optional(),default:Ee.boolean().optional()}),gt=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 r=>{let t=Date.now(),i=J(r),s=typeof r?.cwd=="string"?r.cwd:process.cwd();B.intro("seed-design.json \uD30C\uC77C \uC0DD\uC131");try{let n=Tr.safeParse(r);if(!n.success)throw n.error;let o=n.data,a=o.yes||o.default,c=a?{...G,framework:ve(o.cwd)}:await Oe(o.cwd),{start:m,stop:g}=B.spinner();m("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC911...");let C=await(async()=>{try{return(await Ce({cwd:o.cwd,config:c})).relativePath}catch($){throw g("seed-design.json \uD30C\uC77C \uC0DD\uC131\uC774 \uC911\uB2E8\uB410\uC5B4\uC694."),$}})();g(`seed-design.json \uD30C\uC77C\uC774 ${l(C)}\uC5D0 \uC0DD\uC131\uB410\uC5B4\uC694.`),B.log.info(l("seed-design add {component} \uBA85\uB839\uC5B4\uB85C \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCD94\uAC00\uD574\uBCF4\uC138\uC694!")),B.log.info(l("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.")),B.note(vr(`SEED Design CLI\uB294 \uAC1C\uC120\uC744 \uC704\uD574 \uC775\uBA85 \uC0AC\uC6A9 \uB370\uC774\uD130\uB97C \uC218\uC9D1\uD574\uC694.
|
|
25
25
|
|
|
26
26
|
\uBE44\uD65C\uC131\uD654\uD558\uB824\uBA74:
|
|
27
|
-
\u2022 seed-design.json\uC5D0\uC11C ${
|
|
28
|
-
\u2022 ${
|
|
27
|
+
\u2022 seed-design.json\uC5D0\uC11C ${l('"telemetry": false')}\uB85C \uC124\uC815
|
|
28
|
+
\u2022 ${l("DISABLE_TELEMETRY=true")} \uD658\uACBD \uBCC0\uC218 \uC124\uC815
|
|
29
29
|
|
|
30
|
-
\uC790\uC138\uD55C \uB0B4\uC6A9: https://seed-design.com/react/getting-started/cli/configuration#telemetry`),"Telemetry \uC548\uB0B4"),
|
|
30
|
+
\uC790\uC138\uD55C \uB0B4\uC6A9: https://seed-design.com/react/getting-started/cli/configuration#telemetry`),"Telemetry \uC548\uB0B4"),B.outro("\uC791\uC5C5\uC774 \uC644\uB8CC\uB410\uC5B4\uC694.");let u=Date.now()-t;try{await v.trackCommandOutcome(o.cwd,{command:"init",status:"completed",properties:{tsx:c.tsx,rsc:c.rsc,telemetry:c.telemetry,yes_option:a,duration_ms:u}})}catch($){i&&console.error("[Telemetry] init \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",$)}}catch(n){if(q(n)){try{await v.trackCommandOutcome(s,{command:"init",status:"cancelled",properties:{duration_ms:Date.now()-t}})}catch(o){i&&console.error("[Telemetry] init \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",o)}B.outro(l(n.message)),process.exit(0)}try{await v.trackCommandFailure(s,{command:"init",error:n,properties:{duration_ms:Date.now()-t}})}catch(o){i&&console.error("[Telemetry] init \uC774\uBCA4\uD2B8 \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694:",o)}Y(n,{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:i}),process.exit(1)}})};import{cac as _r}from"cac";var jr="seed-design",oe=_r(jr);async function Ar(){let e=ne();oe.option("--verbose","\uC624\uB958 \uC0C1\uC138 \uC815\uBCF4\uB97C \uCD9C\uB825\uD569\uB2C8\uB2E4."),it(oe),at(oe),lt(oe),ft(oe),gt(oe),oe.version(e.version||"1.0.0","-v, --version"),oe.help(),oe.parse()}Ar();
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
8
8
|
"directory": "packages/cli"
|
|
9
9
|
},
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
11
|
"bin": {
|
|
12
12
|
"seed-design": "./bin/index.mjs"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"bin",
|
|
16
|
-
"src"
|
|
16
|
+
"src",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"NOTICE"
|
|
17
19
|
],
|
|
18
20
|
"engines": {
|
|
19
21
|
"node": ">=20.19.0"
|
package/src/commands/add-all.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { CAC } from "cac";
|
|
|
10
10
|
import { BASE_URL } from "../constants";
|
|
11
11
|
import { analytics } from "../utils/analytics";
|
|
12
12
|
import { highlight } from "../utils/color";
|
|
13
|
-
import { resolveSeedVersion } from "../utils/registry-source";
|
|
13
|
+
import { readRawOptionValue, resolveSeedVersion } from "../utils/registry-source";
|
|
14
14
|
import {
|
|
15
15
|
analyzeRegistryItemCompatibility,
|
|
16
16
|
getProjectSeedPackageVersionSpecs,
|
|
@@ -65,7 +65,9 @@ export const addAllCommand = (cli: CAC) => {
|
|
|
65
65
|
p.intro("seed-design add-all");
|
|
66
66
|
|
|
67
67
|
try {
|
|
68
|
-
|
|
68
|
+
// CAC가 --seed-react-version 값을 숫자로 뭉개므로 rawArgs에서 원본 문자열을 읽어 덮어쓴다.
|
|
69
|
+
const seedReactVersion = readRawOptionValue(cli.rawArgs, "--seed-react-version");
|
|
70
|
+
const parsed = addAllOptionsSchema.safeParse({ registryIds, ...opts, seedReactVersion });
|
|
69
71
|
if (!parsed.success) {
|
|
70
72
|
throw parsed.error;
|
|
71
73
|
}
|
package/src/commands/add.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { z } from "zod";
|
|
|
9
9
|
import type { CAC } from "cac";
|
|
10
10
|
import { BASE_URL } from "../constants";
|
|
11
11
|
import { highlight } from "../utils/color";
|
|
12
|
-
import { resolveSeedVersion } from "../utils/registry-source";
|
|
12
|
+
import { readRawOptionValue, resolveSeedVersion } from "../utils/registry-source";
|
|
13
13
|
import { installDependencies } from "../utils/install";
|
|
14
14
|
import { analytics } from "../utils/analytics";
|
|
15
15
|
import {
|
|
@@ -64,7 +64,9 @@ export const addCommand = (cli: CAC) => {
|
|
|
64
64
|
p.intro("seed-design add");
|
|
65
65
|
|
|
66
66
|
try {
|
|
67
|
-
|
|
67
|
+
// CAC가 --seed-react-version 값을 숫자로 뭉개므로 rawArgs에서 원본 문자열을 읽어 덮어쓴다.
|
|
68
|
+
const seedReactVersion = readRawOptionValue(cli.rawArgs, "--seed-react-version");
|
|
69
|
+
const parsed = addOptionsSchema.safeParse({ itemIds, ...opts, seedReactVersion });
|
|
68
70
|
if (!parsed.success) {
|
|
69
71
|
throw parsed.error;
|
|
70
72
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { readRawOptionValue, resolveSeedVersion } from "../utils/registry-source";
|
|
3
|
+
|
|
4
|
+
describe("readRawOptionValue", () => {
|
|
5
|
+
it("`--flag value` 형식에서 원본 문자열을 읽는다", () => {
|
|
6
|
+
// CAC는 이 값을 숫자 1로 뭉개지만 rawArgs엔 "1.0"이 그대로 남아있다.
|
|
7
|
+
expect(
|
|
8
|
+
readRawOptionValue(
|
|
9
|
+
["node", "cli", "add", "--seed-react-version", "1.0"],
|
|
10
|
+
"--seed-react-version",
|
|
11
|
+
),
|
|
12
|
+
).toBe("1.0");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("`--flag=value` 형식에서 원본 문자열을 읽는다", () => {
|
|
16
|
+
expect(
|
|
17
|
+
readRawOptionValue(
|
|
18
|
+
["node", "cli", "add", "--seed-react-version=1.2"],
|
|
19
|
+
"--seed-react-version",
|
|
20
|
+
),
|
|
21
|
+
).toBe("1.2");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("플래그가 없으면 undefined를 반환한다", () => {
|
|
25
|
+
expect(readRawOptionValue(["node", "cli", "add"], "--seed-react-version")).toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("resolveSeedVersion", () => {
|
|
30
|
+
it("지원하는 버전을 아카이브 baseUrl로 해석한다", () => {
|
|
31
|
+
expect(resolveSeedVersion({ seedReactVersion: "1.0" })).toEqual({
|
|
32
|
+
framework: "react",
|
|
33
|
+
baseUrl: "https://v1-0.seed-design.io",
|
|
34
|
+
});
|
|
35
|
+
expect(resolveSeedVersion({ seedReactVersion: "1.2" })).toEqual({
|
|
36
|
+
framework: "react",
|
|
37
|
+
baseUrl: "https://v1-2.seed-design.io",
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("버전이 없으면 null을 반환한다", () => {
|
|
42
|
+
expect(resolveSeedVersion({})).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("지원하지 않는 버전이면 에러를 던진다", () => {
|
|
46
|
+
expect(() => resolveSeedVersion({ seedReactVersion: "9.9" })).toThrow();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -36,3 +36,19 @@ export function resolveSeedVersion(opts: {
|
|
|
36
36
|
|
|
37
37
|
return { framework: "react", baseUrl };
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* CLI rawArgs에서 옵션의 원본 문자열 값을 직접 읽는다.
|
|
42
|
+
*
|
|
43
|
+
* CAC(내부 mri)는 `--seed-react-version 1.0`의 값을 숫자 1로 강제변환해 trailing zero를
|
|
44
|
+
* 잃는다(→ z.string() 검증도 깨진다). 원본 문자열은 rawArgs에 그대로 남아있으므로 여기서
|
|
45
|
+
* 직접 읽어 coercion을 우회한다. `--flag value`와 `--flag=value` 두 형식을 지원한다.
|
|
46
|
+
*/
|
|
47
|
+
export function readRawOptionValue(rawArgs: string[], flag: string): string | undefined {
|
|
48
|
+
for (let i = 0; i < rawArgs.length; i++) {
|
|
49
|
+
const arg = rawArgs[i];
|
|
50
|
+
if (arg === flag) return rawArgs[i + 1];
|
|
51
|
+
if (arg.startsWith(`${flag}=`)) return arg.slice(flag.length + 1);
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|