({ args })
| 41 | }, |
| 42 | }, |
| 43 | async run({ args }) { |
| 44 | const json = args.json === true; |
| 45 | const interactive = args["human-friendly"] === true; |
| 46 | const dir = resolve(process.cwd()); |
| 47 | const config = loadProjectConfig(dir) ?? DEFAULT_PROJECT_CONFIG; |
| 48 | |
| 49 | let typeFilter: ItemType | undefined; |
| 50 | if (args.type === "block") typeFilter = "hyperframes:block"; |
| 51 | else if (args.type === "component") typeFilter = "hyperframes:component"; |
| 52 | else if (args.type) { |
| 53 | console.error(`Invalid --type: "${args.type}". Use "block" or "component".`); |
| 54 | process.exit(1); |
| 55 | } |
| 56 | |
| 57 | const entries = await listRegistryItems(typeFilter ? { type: typeFilter } : undefined, { |
| 58 | baseUrl: config.registry, |
| 59 | }); |
| 60 | const filtered = entries.filter((e) => e.type !== "hyperframes:example"); |
| 61 | |
| 62 | if (filtered.length === 0) { |
| 63 | if (json) console.log("[]"); |
| 64 | else console.log("No items found in registry."); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | const items = await loadAllItems(filtered, { baseUrl: config.registry }); |
| 69 | |
| 70 | const tagFilter = args.tag?.toLowerCase(); |
| 71 | const matching = tagFilter |
| 72 | ? items.filter((item) => item.tags?.some((t) => t.toLowerCase() === tagFilter)) |
| 73 | : items; |
| 74 | |
| 75 | if (matching.length === 0) { |
| 76 | if (json) console.log("[]"); |
| 77 | else console.log(`No items match tag "${args.tag}".`); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | if (json) { |
| 82 | const output = matching.map((item) => ({ |
| 83 | name: item.name, |
| 84 | type: item.type.replace("hyperframes:", ""), |
| 85 | title: item.title, |
| 86 | description: item.description, |
| 87 | tags: item.tags ?? [], |
| 88 | ...("dimensions" in item && item.dimensions ? { dimensions: item.dimensions } : {}), |
| 89 | ...("duration" in item && item.duration ? { duration: item.duration } : {}), |
| 90 | })); |
| 91 | console.log(JSON.stringify(output, null, 2)); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | if (interactive) { |
| 96 | const options = matching.map((item) => ({ |
| 97 | value: item.name, |
| 98 | label: item.name, |
| 99 | hint: item.description, |
| 100 | })); |
nothing calls this directly
no test coverage detected