Skip to content

Commit 8a50c6e

Browse files
authored
feat(poly sync): exclude empty folders for the dev project (#412)
* feat(poly sync): exclude empty folders for the dev project (that will add all bricks by default) * bump Poetry plugin to 1.47.1 * bump CLI to 1.41.1
1 parent a867b34 commit 8a50c6e

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

components/polylith/sync/collect.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1+
from functools import partial
12
from pathlib import Path
23
from typing import Set
34

4-
from polylith import check, deps, info
5+
from polylith import check, configuration, deps, info
6+
7+
8+
def _is_empty(brick: str, bricks_path: Path) -> bool:
9+
path = bricks_path / brick
10+
11+
return not any(path.iterdir())
12+
13+
14+
def _without_empty(
15+
root: Path, namespace: str, bricks: Set[str], brick_type: str
16+
) -> Set[str]:
17+
theme = configuration.get_theme_from_config(root)
18+
19+
if theme == "loose":
20+
bricks_path = root / f"{brick_type}/{namespace}"
21+
else:
22+
bricks_path = root / f"{brick_type}"
23+
24+
return {brick for brick in bricks if not _is_empty(brick, bricks_path)}
525

626

727
def _calculate(root: Path, namespace: str, project_data: dict, bases: Set[str]) -> dict:
@@ -20,14 +40,16 @@ def _calculate(root: Path, namespace: str, project_data: dict, bases: Set[str])
2040
brick_diff = check.collect.diff(all_bricks, bases, components)
2141

2242
bases_diff = {b for b in brick_diff if b in all_bases}
23-
components_diff = {b for b in brick_diff if b in all_components}
43+
comp_diff = {b for b in brick_diff if b in all_components}
44+
45+
fn = partial(_without_empty, root, namespace)
2446

2547
return {
2648
"name": project_data["name"],
2749
"path": project_data["path"],
2850
"is_project": is_project,
29-
"bases": bases_diff,
30-
"components": components_diff,
51+
"bases": bases_diff if is_project else fn(bases_diff, "bases"),
52+
"components": comp_diff if is_project else fn(comp_diff, "components"),
3153
"brick_imports": brick_imports,
3254
}
3355

projects/poetry_polylith_plugin/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "poetry-polylith-plugin"
3-
version = "1.47.0"
3+
version = "1.47.1"
44
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
55
authors = ["David Vujic"]
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

projects/polylith_cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "polylith-cli"
3-
version = "1.41.0"
3+
version = "1.41.1"
44
description = "Python tooling support for the Polylith Architecture"
55
authors = ['David Vujic']
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

0 commit comments

Comments
 (0)