Skip to content

Commit 0136455

Browse files
author
phernandez
committed
feat: include all components in dependency mapping
Added empty lists for components with no dependencies in component_dependencies.toml. Refactored component_analyzer.py to ensure all components are included in the dependencies mapping. Enhanced error handling in components.py for better user feedback.
1 parent d61c0ad commit 0136455

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

basic_components/cli/components.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
help="Install and update components from basic-components",
1515
add_completion=False,
1616
)
17-
1817
console = Console()
1918

2019
# Default values for REPO_URL and COMPONENTS_DIR
@@ -77,13 +76,7 @@ def add_component(
7776
# Build exclude list - exclude everything except our pattern
7877
excludes = ["*", f"!{pattern}"]
7978

80-
# Debug output
81-
# console.print("[yellow]Debug: Copying with args:[/yellow]")
82-
# console.print(f" src_path: {repo_url}")
83-
# console.print(f" dst_path: {dest_dir}")
84-
# console.print(f" exclude patterns: {excludes}")
85-
# console.print(f" vcs_ref: {branch}")
86-
79+
# Run copier to copy the component
8780
copier.run_copy(
8881
src_path=repo_url,
8982
dst_path=str(dest_dir),
@@ -93,7 +86,11 @@ def add_component(
9386
)
9487

9588
except Exception as e:
96-
console.print(f"[red]Error installing {component}: {str(e)}[/red]")
89+
error_message = str(e)
90+
if "No files or folders to copy" in error_message or "Nothing to do" in error_message:
91+
console.print(f"[red]Error: Component '{component}' not found in the repository.[/red]")
92+
else:
93+
console.print(f"[red]Error installing {component}: {error_message}[/red]")
9794
raise typer.Exit(1)
9895

9996
def display_installation_plan(component: str, dependencies: Set[str], dry_run: bool = False) -> None:
@@ -137,12 +134,16 @@ def add(
137134
# Normalize component name
138135
component = normalize_component_name(component)
139136

137+
# Check if component exists in dependencies
138+
if component not in deps_map:
139+
console.print(f"[red]Error: Component '{component}' not found.[/red]")
140+
raise typer.Exit(1)
141+
140142
# Get all dependencies if requested
141143
components_to_install = {component}
142144
if with_deps:
143145
dependencies = set(deps_map.get(component, []))
144146
if dependencies:
145-
#console.print(f"\n[yellow]Debug: Found dependencies: {dependencies}[/yellow]")
146147
components_to_install.update(dependencies)
147148
else:
148149
dependencies = set()
@@ -157,7 +158,6 @@ def add(
157158
# Install each component separately with its own exclude pattern
158159
installed = []
159160
for comp in sorted(components_to_install):
160-
#console.print(f"\n[yellow]Debug: Installing component: {comp}[/yellow]")
161161
add_component(comp, components_dir, repo_url, branch, dry_run)
162162
installed.append(comp)
163163

basic_components/component_dependencies.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ accordion = [
33
"icons/ChevronDown",
44
"icons/ChevronUp",
55
]
6+
alert = []
7+
alert_dialog = []
8+
badge = []
9+
button = []
10+
card = []
11+
checkbox = []
612
dialog = [
713
"icons/X",
814
]
@@ -11,15 +17,22 @@ dropdown_menu = [
1117
"icons/ChevronRight",
1218
"radio",
1319
]
20+
form = []
21+
icons = []
22+
input = []
1423
"integrations/wtform" = [
1524
"form",
1625
]
26+
label = []
27+
link = []
1728
mode_toggle = [
1829
"button",
1930
"dropdown_menu",
2031
"icons/Moon",
2132
"icons/Sun",
2233
]
34+
popover = []
35+
radio = []
2336
select = [
2437
"icons/Check",
2538
"icons/ChevronDown",
@@ -33,6 +46,8 @@ table = [
3346
"icons/ChevronUp",
3447
"icons/ChevronsUpDown",
3548
]
49+
tabs = []
50+
textarea = []
3651
toast = [
3752
"button",
3853
"icons/X",

tools/component_analyzer.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def analyze_components(
8686
core_components, integration_mapping = get_components(components_dir)
8787
raw_dependencies = defaultdict(set)
8888
warnings = []
89+
all_components = set()
8990

9091
for template_file in components_dir.rglob("*.jinja"):
9192
rel_path = template_file.relative_to(components_dir)
@@ -102,6 +103,8 @@ def analyze_components(
102103
if component_name in {'ui', 'integrations'}:
103104
continue
104105

106+
all_components.add(component_name)
107+
105108
content = template_file.read_text()
106109
refs = find_component_references(content)
107110

@@ -116,11 +119,11 @@ def analyze_components(
116119
if normalized_ref != component_name:
117120
raw_dependencies[component_name].add(normalized_ref)
118121

119-
dependencies = {
120-
k: sorted(list(v))
121-
for k, v in raw_dependencies.items()
122-
if v
123-
}
122+
# Include all components in dependencies, mapping components with no dependencies to empty lists
123+
dependencies = {}
124+
for component in all_components:
125+
deps = sorted(list(raw_dependencies.get(component, set())))
126+
dependencies[component] = deps
124127

125128
return dict(sorted(dependencies.items())), warnings
126129

0 commit comments

Comments
 (0)