@seed-design/cli 1.5.1 → 1.6.1
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 +11 -11
- package/package.json +5 -3
- package/src/tests/compatibility.test.ts +39 -0
- package/src/utils/compatibility.ts +8 -1
- package/src/utils/get-package-info.ts +20 -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,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import*as me from"@clack/prompts";import{cosmiconfig as
|
|
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
|
|
4
|
-
`,"utf-8"),{relativePath:
|
|
2
|
+
import*as me from"@clack/prompts";import{cosmiconfig as St}from"cosmiconfig";import{z as le}from"zod";import*as te from"@clack/prompts";import{ZodError as Ct}from"zod";import bt from"picocolors";var l=e=>bt.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 W(e){return!e||typeof e!="object"||!("verbose"in e)?!1:e.verbose===!0}function $t(e,r){if(e instanceof k)return{reason:e.message,hint:e.hint??r,details:e.details,stack:xt(e.cause??e)};if(e instanceof Ct){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 xt(e){if(e instanceof Error)return e.stack}function Y(e,{defaultMessage:r,defaultHint:t,verbose:i=!1}){let s=$t(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 Pt from"fs-extra";import Ue from"path";import It from"path";import De from"findup-sync";import Oe from"fs-extra";var Le="package.json";function kt(e=process.cwd()){let r=De(Le,{cwd:e});if(!r)throw new Error("No package.json file found in the project.");return r}function ne(e=process.cwd()){let r=kt(e);return Oe.readJSONSync(r)}function Me(e,r=process.cwd()){try{let t=De(It.join("node_modules",e,Le),{cwd:r});return t?Oe.readJSONSync(t):null}catch{return null}}var J={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 Fe(e){let r=ve(e);return await Q.group({tsx:()=>Q.confirm({message:`${l("TypeScript")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:J.tsx}),rsc:()=>Q.confirm({message:`${l("React Server Components")}\uB97C \uC0AC\uC6A9\uC911\uC774\uC2E0\uAC00\uC694?`,initialValue:J.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:J.path,defaultValue:J.path,placeholder:J.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:J.telemetry})},{onCancel:()=>{throw new D}})}async function Ce({cwd:e,config:r}){let t=Ue.resolve(e,"seed-design.json");return await Pt.writeFile(t,`${JSON.stringify(r,null,2)}
|
|
4
|
+
`,"utf-8"),{relativePath:Ue.relative(process.cwd(),t),targetPath:t}}var Ke="seed-design",Rt=St(Ke,{searchPlaces:[`${Ke}.json`]}),Ne=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:J}),me.log.message("seed-design.json \uD30C\uC77C\uC774 \uC0DD\uC131\uB410\uC5B4\uC694."),Ne.parse(J)}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 Rt.search(e);if(!r||r.isEmpty)return null;try{return Ne.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()}))}))}),Ve=d.array(d.object({id:d.string()})),Et=d.object({label:d.string(),path:d.string()}),vt=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(Et).optional()}),Tt=d.object({id:d.string(),label:d.string(),items:d.array(vt)}),_t=d.object({id:d.string(),label:d.string(),sections:d.array(Tt)}),ze=d.object({categories:d.array(_t)});var jt=1e4;async function Be(e,r=jt){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}=ze.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}=Ve.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 At({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 qe({url:e}){let r=await Be(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 Je({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 Be(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
5
|
${i.map(a=>` - ${a}`).join(`
|
|
6
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
7
|
${i.map(n=>` - ${n}`).join(`
|
|
8
|
-
`)}`})}async function
|
|
8
|
+
`)}`})}async function Ge({baseUrl:e,framework:r,registryId:t,registryItemIds:i}){return await Promise.all(i.map(async s=>{try{return await At({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
9
|
${m.items.map(g=>g.id).join(`
|
|
10
|
-
`)}`),n):new Error(`Failed to parse registry index for ${t}`)}}))}import{promises as
|
|
10
|
+
`)}`),n):new Error(`Failed to parse registry index for ${t}`)}}))}import{promises as Ft}from"fs";import{tmpdir as Kt}from"os";import Ye from"path";import{transformFromAstSync as Dt}from"@babel/core";import Ot from"@babel/plugin-transform-typescript";import*as Ie from"recast";import{parse as Lt}from"@babel/parser";var Mt={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"]},He=async({sourceFile:e,config:r})=>{let t=e.getFullText();if(r.tsx)return t;let i=Ie.parse(t,{parser:{parse:n=>Lt(n,Mt)}}),s=Dt(i,t,{cloneInputAst:!1,code:!1,ast:!0,plugins:[Ot],configFile:!1});if(!s||!s.ast)throw new Error("Failed to transform JSX");return Ie.print(s.ast).code};import{SyntaxKind as Ut}from"ts-morph";var We=async({sourceFile:e,config:r})=>{if(r.rsc)return e;let t=e.getFirstChildByKind(Ut.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 Nt,ScriptKind as Vt}from"ts-morph";var zt=[We],Bt=new Nt({compilerOptions:{}});async function qt(e){let r=await Ft.mkdtemp(Ye.join(Kt(),"seed-design-"));return Ye.join(r,e)}async function Qe(e){let r=await qt(e.filename),t=Bt.createSourceFile(r,e.raw,{scriptKind:Vt.TSX});for(let i of zt)i({sourceFile:t,...e});return await He({sourceFile:t,...e})}import*as G from"@clack/prompts";import ge from"fs-extra";import X from"path";import{createPatch as Jt}from"diff";import Gt 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 Ge({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 Qe({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){G.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 H=Jt(h,w,y),b=Gt(H);return G.log.message(`
|
|
11
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")}
|
|
12
|
+
`),G.log.message(b),G.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(G.isCancel(U)||U==="skip"){G.log.info(`${l(h)}: \uD30C\uC77C\uC744 \uBC1B\uC9C0 \uC54A\uACE0 \uAC74\uB108\uB6F0\uC5C8\uC5B4\uC694.`);continue}if(U==="backup"){let H=X.dirname(x),b=X.join(H,K);await ge.rename(x,b),G.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),G.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 ur from"path";import{z as re}from"zod";var N="https://seed-design.io";var Xe={"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=Xe[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(Xe).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 et from"@clack/prompts";import{execa as Wt}from"execa";import{detect as Ht}from"@antfu/ni";async function Ze(e){let r=await Ht({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}=et.spinner(),n=await Ze(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 Wt(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 Yt}from"node:crypto";import*as rt from"@clack/prompts";var Qt="seed_cli";async function Xt(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 Zt(){return Yt()}var er=Zt(),tt=!1;function st(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}function tr(e){return e instanceof Error&&e.name?e.name:typeof e=="object"&&e!==null?e.constructor?.name??"Object":typeof e}async function ot(e,{event:r,properties:t={}}){if(!await Xt(e))return;let s=`${Qt}.${r}`;tt||(rt.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)"),tt=!0);try{let n="https://us.i.posthog.com/capture",o={"Content-Type":"application/json"},a={api_key:"phc_seod8HhifElOP1R92KmvsQybrtUmkOTgZBsq0mfCelR",event:s,distinct_id:er,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 nt(e,{command:r,status:t,result:i,properties:s={}}){await ot(e,{event:r,properties:st({status:t,result:i,...s})})}async function rr(e,{command:r,error:t,result:i,properties:s={}}){await nt(e,{command:r,status:"failed",result:i,properties:st({error_type:tr(t),...s})})}var v={track:ot,trackCommandFailure:rr,trackCommandOutcome:nt};import*as pe from"@clack/prompts";import sr from"fs-extra";import or from"path";import{intersects as nr,satisfies as ir,valid as at,validRange as ct}from"semver";var ar=["@seed-design/react","@seed-design/css"],cr=["@seed-design/lynx-react","@seed-design/lynx-css"];function ae(e){return e==="lynx"?cr:ar}var it="workspace:",lr="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];if(typeof a=="string"){s[o]=a;continue}let c=Me(o,e)?.version;typeof c=="string"&&(s[o]=c)}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=mr(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=pr($);if(!I){o.push({itemKey:c,packageName:C,requiredRanges:u,installedVersionSpec:$,type:"invalid-version-spec"});continue}u.every(T=>dr({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 lt({publicRegistries:e,rootPath:r}){let t=[];for(let i of e)for(let s of i.items)s.snippets.some(o=>fr(o.path).some(a=>sr.existsSync(or.join(r,i.id,a))))&&t.push(`${i.id}:${s.id}`);return t}function mr(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??{}))gr(n,r)&&i[n].add(o);return i}function pr(e){let r=e.trim();if(r.startsWith(it)&&(r=r.slice(it.length).trim()),r.startsWith(lr)){let t=r.split("@").at(-1);if(!t)return null;r=t}return!r||r==="*"?null:at(r)||ct(r)?r:null}function dr({currentVersionSpec:e,requiredRange:r}){let t=ct(r);return t?at(e)?ir(e,t,{includePrerelease:!0}):nr(e,t,{includePrerelease:!0}):!1}function fr(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 gr(e,r="react"){return ae(r).includes(e)}var yr=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()}),mt=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=W(t),n=typeof t?.cwd=="string"?t.cwd:process.cwd();_.intro("seed-design add");try{let o=Se(e.rawArgs,"--seed-react-version"),a=yr.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=ur.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: ${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
|
|
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,H=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(H),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 hr from"path";import{z as Z}from"zod";var wr=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()}),pt=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=W(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=wr.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=hr.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 H=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:H}})}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 dt from"path";import{z}from"zod";var br=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 Cr({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 $r({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 ft=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=W(t),n=typeof t?.cwd=="string"?t.cwd:process.cwd();V.intro("seed-design compat");try{let o=br.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}})(),$=Cr({itemIds:a.itemIds,component:a.component}),I=a.all?u.flatMap(w=>w.items.map(P=>`${w.id}:${P.id}`)):$.length>0?$r({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=dt.resolve(a.cwd,h.path),P=lt({publicRegistries:u,rootPath:w});return P.length?P:(V.log.info(`${l(dt.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 xr="https://raw.githubusercontent.com/daangn/seed-design/refs/heads/dev/docs/registry",Ir=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 gt(e,r){return`${xr}/${e}/${r}`}function kr(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: ${gt(n,e.snippets[0].path)}`);else{s.push("- snippet:");for(let o of e.snippets)s.push(` - ${o.label}: ${gt(n,o.path)}`)}}j.log.message(s.join(`
|
|
15
|
+
`))}function Pr(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:Pr(i,s.toLowerCase())})).filter(({dist:s})=>s>0&&s<=t).sort((s,n)=>s.dist-n.dist).map(({value:s})=>s)}function Sr(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 yt(e){return e.split(/[\/\s]+/).map(r=>r.trim()).filter(Boolean)}function Rr(e){let[,r]=e.split(":");return r??e}function Er({query:e,framework:r,categoryIds:t}){if(!e)return;let i=yt(e).map(Rr);if(!i.length)return;let[s]=i;return!t.includes(s)&&r&&t.includes(r)?[r,...i].join("/"):i.join("/")}function vr(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 ut(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 Tr(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 ht=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=W(t),n=t.raw??!1,o=process.cwd();n||j.intro("seed-design docs");try{let a=Ir.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=Er({query:c.query,framework:C,categoryIds:$.map(y=>y.id)}),A,T=async()=>{if(I){let w=yt(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
19
|
${E.slice(0,3).map(L=>` - ${P.id}/${S.id}/${L}`).join(`
|
|
@@ -21,10 +21,10 @@ ${E.slice(0,3).map(L=>` - ${P.id}/${S.id}/${L}`).join(`
|
|
|
21
21
|
|
|
22
22
|
\u{1F4A1} \uC774\uAC83\uC744 \uC758\uBBF8\uD588\uB098\uC694?
|
|
23
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
|
|
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 H=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(H))throw new D;return H}if(P){if(P.sections.length===1)return await we(P.sections[0].items);let S=await ut(P.sections);return await we(S.items)}let F=vr($,I);if(F.length===0){let S=Sr(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 Tr($),h;return y.sections.length===1?h=y.sections[0]:h=await ut(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 qe({url:h})}else y=await Je({baseUrl:m,query:I});console.log(y)}else kr(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 _r from"dedent";var jr=Ee.object({cwd:Ee.string(),yes:Ee.boolean().optional(),default:Ee.boolean().optional()}),wt=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=W(r),s=typeof r?.cwd=="string"?r.cwd:process.cwd();B.intro("seed-design.json \uD30C\uC77C \uC0DD\uC131");try{let n=jr.safeParse(r);if(!n.success)throw n.error;let o=n.data,a=o.yes||o.default,c=a?{...J,framework:ve(o.cwd)}:await Fe(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(_r(`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
27
|
\u2022 seed-design.json\uC5D0\uC11C ${l('"telemetry": false')}\uB85C \uC124\uC815
|
|
28
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"),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
|
|
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 Ar}from"cac";var Dr="seed-design",oe=Ar(Dr);async function Or(){let e=ne();oe.option("--verbose","\uC624\uB958 \uC0C1\uC138 \uC815\uBCF4\uB97C \uCD9C\uB825\uD569\uB2C8\uB2E4."),mt(oe),pt(oe),ft(oe),ht(oe),wt(oe),oe.version(e.version||"1.0.0","-v, --version"),oe.help(),oe.parse()}Or();
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
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"
|
|
@@ -6,6 +6,7 @@ import type { PublicRegistry } from "@/src/schema";
|
|
|
6
6
|
import {
|
|
7
7
|
analyzeRegistryItemCompatibility,
|
|
8
8
|
findInstalledSnippetItemKeys,
|
|
9
|
+
getProjectSeedPackageVersionSpecs,
|
|
9
10
|
} from "../utils/compatibility";
|
|
10
11
|
|
|
11
12
|
const registries: PublicRegistry[] = [
|
|
@@ -146,3 +147,41 @@ describe("findInstalledSnippetItemKeys", () => {
|
|
|
146
147
|
expect(installed).toEqual(["ui:action-button"]);
|
|
147
148
|
});
|
|
148
149
|
});
|
|
150
|
+
|
|
151
|
+
describe("getProjectSeedPackageVersionSpecs", () => {
|
|
152
|
+
const tempDirs: string[] = [];
|
|
153
|
+
|
|
154
|
+
afterEach(async () => {
|
|
155
|
+
while (tempDirs.length > 0) {
|
|
156
|
+
const dir = tempDirs.pop();
|
|
157
|
+
if (dir) await fs.remove(dir);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
async function makeProject(packageJson: object) {
|
|
162
|
+
const rootPath = await fs.mkdtemp(path.join(os.tmpdir(), "seed-cli-specs-"));
|
|
163
|
+
tempDirs.push(rootPath);
|
|
164
|
+
await fs.writeJSON(path.join(rootPath, "package.json"), packageJson);
|
|
165
|
+
await fs.ensureDir(path.join(rootPath, "node_modules", "@seed-design", "react"));
|
|
166
|
+
await fs.writeJSON(
|
|
167
|
+
path.join(rootPath, "node_modules", "@seed-design", "react", "package.json"),
|
|
168
|
+
{ name: "@seed-design/react", version: "2.0.4" },
|
|
169
|
+
);
|
|
170
|
+
return rootPath;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
it("package.json 선언이 있으면 선언을 그대로 쓴다", async () => {
|
|
174
|
+
const rootPath = await makeProject({
|
|
175
|
+
name: "app",
|
|
176
|
+
dependencies: { "@seed-design/react": "^2.0.0" },
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
expect(getProjectSeedPackageVersionSpecs(rootPath)["@seed-design/react"]).toBe("^2.0.0");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("선언이 없어도 설치본이 있으면 미설치로 보지 않는다 (모노레포 호이스팅)", async () => {
|
|
183
|
+
const rootPath = await makeProject({ name: "app" });
|
|
184
|
+
|
|
185
|
+
expect(getProjectSeedPackageVersionSpecs(rootPath)["@seed-design/react"]).toBe("2.0.4");
|
|
186
|
+
});
|
|
187
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PublicRegistry } from "@/src/schema";
|
|
2
|
-
import { getPackageInfo } from "@/src/utils/get-package-info";
|
|
2
|
+
import { getInstalledPackageJson, getPackageInfo } from "@/src/utils/get-package-info";
|
|
3
3
|
import * as p from "@clack/prompts";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
5
|
import path from "path";
|
|
@@ -53,6 +53,13 @@ export function getProjectSeedPackageVersionSpecs(
|
|
|
53
53
|
const value = packageDeps[packageName];
|
|
54
54
|
if (typeof value === "string") {
|
|
55
55
|
result[packageName] = value;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// 모노레포처럼 선언이 상위 package.json에 있으면 여기선 안 잡혀요.
|
|
59
|
+
// 실제로 해소된 설치본이 있으면 그걸 쓰지 않으면 "미설치"로 오판해요.
|
|
60
|
+
const installed = getInstalledPackageJson(packageName, cwd)?.version;
|
|
61
|
+
if (typeof installed === "string") {
|
|
62
|
+
result[packageName] = installed;
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
import findup from "findup-sync";
|
|
2
3
|
import fs from "fs-extra";
|
|
3
4
|
import type { PackageJson } from "type-fest";
|
|
@@ -16,3 +17,22 @@ export function getPackageInfo(cwd = process.cwd()) {
|
|
|
16
17
|
const packageJsonPath = getPackagePath(cwd);
|
|
17
18
|
return fs.readJSONSync(packageJsonPath) as PackageJson;
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* node_modules에 실제로 설치된 패키지의 package.json을 읽어요.
|
|
23
|
+
* 선언 범위(`^1.1.0`)가 아니라 실제 해소된 설치본을 보므로 정확한 호환성 진단에 사용해요.
|
|
24
|
+
* 미설치 또는 읽기 실패 시 null.
|
|
25
|
+
*/
|
|
26
|
+
export function getInstalledPackageJson(
|
|
27
|
+
packageName: string,
|
|
28
|
+
cwd = process.cwd(),
|
|
29
|
+
): PackageJson | null {
|
|
30
|
+
try {
|
|
31
|
+
// findup으로 cwd부터 상위로 올라가며 node_modules를 찾아 호이스팅된 설치본도 탐지
|
|
32
|
+
const packageJsonPath = findup(path.join("node_modules", packageName, PACKAGE_JSON), { cwd });
|
|
33
|
+
if (!packageJsonPath) return null;
|
|
34
|
+
return fs.readJSONSync(packageJsonPath) as PackageJson;
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|