From 76e2866bc9cf5b31f717b92dea0b50e17b2025a3 Mon Sep 17 00:00:00 2001 From: p-sw Date: Sat, 15 Jun 2024 03:35:08 +0900 Subject: [PATCH] feat(cli): add getDirComponentURL for directory component handling --- packages/cli/src/helpers/registry.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/helpers/registry.ts b/packages/cli/src/helpers/registry.ts index a048b6b..eaeccef 100644 --- a/packages/cli/src/helpers/registry.ts +++ b/packages/cli/src/helpers/registry.ts @@ -19,6 +19,18 @@ export async function getRegistry( return registryResponse } -export async function getComponentURL(registry: Registry, component: RegistryComponent): Promise { +export async function getComponentURL( + registry: Registry, + component: RegistryComponent & {type: 'file'}, +): Promise { return registry.base + registry.paths.components.replace('{componentName}', component.name) } + +export async function getDirComponentURL( + registry: Registry, + component: RegistryComponent & {type: 'dir'}, +): Promise { + const base = registry.base + registry.paths.components.replace('{componentName}', component.name) + + return component.files.map((filename) => base + '/' + filename) +}