Skip to content

Commit 7a10007

Browse files
authored
feat(poly sync): non-interactive mode when running in quite mode (#390)
* feat(poly sync): non-interactive when running in quite mode * bump Poetry plugin to 1.43.0 * bump CLI to 1.36.0
1 parent 6be1473 commit 7a10007

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

components/polylith/commands/sync.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ def choose_base(root: Path, ns: str, project_data: dict) -> Union[str, None]:
2222
)
2323

2424

25-
def calculate_brick_diff(root: Path, ns: str, project_data: dict) -> dict:
26-
if info.is_project(project_data) and is_project_without_bricks(project_data):
25+
def can_run_interactive_mode(project_data: dict, options: dict) -> bool:
26+
is_quiet = options["quiet"]
27+
28+
if is_quiet:
29+
return False
30+
31+
return info.is_project(project_data) and is_project_without_bricks(project_data)
32+
33+
34+
def calculate_brick_diff(
35+
root: Path, ns: str, project_data: dict, options: dict
36+
) -> dict:
37+
if can_run_interactive_mode(project_data, options):
2738
base = choose_base(root, ns, project_data)
2839

2940
if base:
@@ -36,7 +47,7 @@ def run(root: Path, ns: str, project_data: dict, options: dict):
3647
is_quiet = options["quiet"]
3748
is_verbose = options["verbose"]
3849

39-
diff = calculate_brick_diff(root, ns, project_data)
50+
diff = calculate_brick_diff(root, ns, project_data, options)
4051

4152
sync.update_project(root, ns, diff)
4253

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.42.3"
3+
version = "1.43.0"
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.35.2"
3+
version = "1.36.0"
44
description = "Python tooling support for the Polylith Architecture"
55
authors = ['David Vujic']
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from polylith.commands import sync
2+
3+
4+
def test_can_run_interactive_mode_depending_on_the_quite_mode() -> None:
5+
project_data = {"type": "project", "bases": [], "components": []}
6+
with_bricks = {"type": "project", "bases": [], "components": ["one", "two"]}
7+
8+
assert sync.can_run_interactive_mode(project_data, {"quiet": False}) is True
9+
10+
assert sync.can_run_interactive_mode(project_data, {"quiet": True}) is False
11+
assert sync.can_run_interactive_mode(with_bricks, {"quiet": True}) is False
12+
13+
14+
def test_can_run_interactive_mode_returns_false_for_project_with_bricks() -> None:
15+
options = {"quiet": False}
16+
with_bases = {"type": "project", "bases": ["my_base"], "components": []}
17+
with_components = {"type": "project", "bases": [], "components": ["one", "two"]}
18+
19+
assert sync.can_run_interactive_mode(with_bases, options) is False
20+
assert sync.can_run_interactive_mode(with_components, options) is False

0 commit comments

Comments
 (0)