@seed-design/cli 0.0.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +0,0 @@
1
- import * as p from "@clack/prompts";
2
- import { registryUISchema, type RegistryUIMachineGenerated } from "@/src/schema";
3
-
4
- export async function fetchRegistryItems(
5
- fileNames?: string[],
6
- baseUrl?: string,
7
- type: "ui" | "lib" = "ui",
8
- ): Promise<RegistryUIMachineGenerated> {
9
- const results = await Promise.all(
10
- fileNames.map(async (fileName) => {
11
- try {
12
- const response = await fetch(`${baseUrl}/__registry__/${type}/${fileName}.json`);
13
- return await response.json();
14
- } catch (error) {
15
- const index = await fetch(`${baseUrl}/__registry__/${type}/index.json`).then((res) =>
16
- res.json(),
17
- );
18
- const parsedIndex = registryUISchema.parse(index);
19
- const availableComponents = parsedIndex.map((component) => component.name);
20
-
21
- p.log.error(`${type}:${fileName} 컴포넌트는 레지스트리에 존재하지 않아요.`);
22
- p.log.info(`사용 가능한 컴포넌트: ${availableComponents.join(", ")}`);
23
- p.log.info(
24
- JSON.stringify(
25
- {
26
- baseUrl,
27
- error: error.toString(),
28
- },
29
- null,
30
- 2,
31
- ),
32
- );
33
- process.exit(1);
34
- }
35
- }),
36
- );
37
-
38
- return results;
39
- }
40
-
41
- export async function fetchRegistryItem(
42
- fileName: string,
43
- baseUrl: string,
44
- type: "ui" | "lib" = "ui",
45
- ) {
46
- const [result] = await fetchRegistryItems([fileName], baseUrl, type);
47
- return result;
48
- }
49
-
50
- export async function getRegistryUIIndex(baseUrl?: string) {
51
- try {
52
- const [result] = await fetchRegistryItems(["index"], baseUrl, "ui");
53
-
54
- return registryUISchema.parse(result);
55
- } catch (error) {
56
- p.log.error("레지스트리 인덱스를 가져오는 데 실패했어요.");
57
- p.log.info(
58
- JSON.stringify(
59
- {
60
- baseUrl,
61
- error: error.toString(),
62
- },
63
- null,
64
- 2,
65
- ),
66
- );
67
- process.exit(1);
68
- }
69
- }
70
-
71
- export async function getRegistryLibIndex(baseUrl?: string) {
72
- const [result] = await fetchRegistryItems(["index"], baseUrl, "lib");
73
-
74
- return registryUISchema.parse(result);
75
- }