polylith-cli 1.2.1__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/PKG-INFO +1 -1
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/check/collect.py +3 -3
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/check/report.py +1 -1
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/cli/core.py +18 -8
- polylith_cli-1.3.0/polylith_cli/polylith/commands/__init__.py +2 -0
- polylith_cli-1.3.0/polylith_cli/polylith/commands/deps.py +28 -0
- polylith_cli-1.3.0/polylith_cli/polylith/deps/__init__.py +3 -0
- polylith_cli-1.3.0/polylith_cli/polylith/deps/core.py +10 -0
- polylith_cli-1.3.0/polylith_cli/polylith/deps/report.py +57 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/info/report.py +1 -1
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/reporting/theme.py +2 -0
- polylith_cli-1.3.0/polylith_cli/polylith/sync/collect.py +18 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/sync/report.py +1 -1
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/pyproject.toml +1 -1
- polylith_cli-1.2.1/polylith_cli/polylith/commands/__init__.py +0 -2
- polylith_cli-1.2.1/polylith_cli/polylith/sync/collect.py +0 -27
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/README.md +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/alias/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/alias/core.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/bricks/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/bricks/base.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/bricks/brick.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/bricks/component.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/check/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/check/grouping.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/cli/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/cli/__main__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/cli/create.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/cli/options.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/commands/check.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/commands/create.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/commands/diff.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/commands/info.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/commands/libs.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/commands/sync.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/configuration/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/configuration/core.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/development/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/development/development.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/diff/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/diff/collect.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/diff/report.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/dirs/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/dirs/dirs.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/distributions/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/distributions/collect.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/distributions/core.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/files/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/files/files.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/imports/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/imports/parser.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/info/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/info/collect.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/interface/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/interface/interfaces.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/libs/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/libs/grouping.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/libs/report.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/libs/stdlib.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/project/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/project/create.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/project/get.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/project/parser.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/project/templates.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/readme/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/readme/readme.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/repo/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/repo/get.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/repo/repo.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/reporting/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/sync/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/sync/update.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/test/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/test/tests.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/toml/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/toml/core.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/workspace/__init__.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/workspace/create.py +0 -0
- {polylith_cli-1.2.1 → polylith_cli-1.3.0}/polylith_cli/polylith/workspace/paths.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Set
|
|
3
3
|
from polylith_cli.polylith import check, imports, workspace
|
|
4
4
|
|
|
5
5
|
def extract_bricks(paths: Set[Path], ns: str) -> dict:
|
|
@@ -19,11 +19,11 @@ def with_unknown_components(root: Path, ns: str, brick_imports: dict) -> dict:
|
|
|
19
19
|
collected = {**brick_imports, **extracted}
|
|
20
20
|
return with_unknown_components(root, ns, collected)
|
|
21
21
|
|
|
22
|
-
def diff(known_bricks: Set[str], bases:
|
|
22
|
+
def diff(known_bricks: Set[str], bases: Set[str], components: Set[str]) -> Set[str]:
|
|
23
23
|
bricks = set().union(bases, components)
|
|
24
24
|
return known_bricks.difference(bricks)
|
|
25
25
|
|
|
26
|
-
def imports_diff(brick_imports: dict, bases:
|
|
26
|
+
def imports_diff(brick_imports: dict, bases: Set[str], components: Set[str]) -> Set[str]:
|
|
27
27
|
flattened_bases = set().union(*brick_imports['bases'].values())
|
|
28
28
|
flattened_components = set().union(*brick_imports['components'].values())
|
|
29
29
|
flattened_imports = set().union(flattened_bases, flattened_components)
|
|
@@ -42,6 +42,6 @@ def create_report(project_data: dict, collected_imports: dict, third_party_libs:
|
|
|
42
42
|
components = {c for c in project_data.get('components', [])}
|
|
43
43
|
brick_imports = collected_imports['brick_imports']
|
|
44
44
|
third_party_imports = collected_imports['third_party_imports']
|
|
45
|
-
brick_diff = collect.imports_diff(brick_imports,
|
|
45
|
+
brick_diff = collect.imports_diff(brick_imports, bases, components)
|
|
46
46
|
libs_diff = libs.report.calculate_diff(third_party_imports, third_party_libs, is_strict)
|
|
47
47
|
return {'brick_imports': brick_imports, 'third_party_imports': third_party_imports, 'brick_diff': brick_diff, 'libs_diff': libs_diff}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
+
from typing import List, Union
|
|
2
3
|
from polylith_cli.polylith import commands, configuration, info, repo
|
|
3
4
|
from polylith_cli.polylith.cli import create, options
|
|
4
5
|
from typer import Exit, Option, Typer
|
|
@@ -6,6 +7,10 @@ from typing_extensions import Annotated
|
|
|
6
7
|
app = Typer()
|
|
7
8
|
app.add_typer(create.app, name='create', help='Commands for creating a workspace, bases, components and projects.')
|
|
8
9
|
|
|
10
|
+
def filtered_projects_data(projects_data: List[dict], directory: Union[str, None]) -> List[dict]:
|
|
11
|
+
dir_path = Path(directory).as_posix() if directory else Path.cwd().name
|
|
12
|
+
return [p for p in projects_data if dir_path in p['path'].as_posix()]
|
|
13
|
+
|
|
9
14
|
@app.command('info')
|
|
10
15
|
def info_command(short: Annotated[bool, options.short_workspace]=False):
|
|
11
16
|
"""Info about the Polylith workspace."""
|
|
@@ -19,8 +24,7 @@ def check_command(strict: Annotated[bool, options.strict]=False, verbose: Annota
|
|
|
19
24
|
all_projects_data = info.get_projects_data(root, ns)
|
|
20
25
|
only_projects_data = [p for p in all_projects_data if info.is_project(p)]
|
|
21
26
|
cli_options = {'verbose': verbose, 'quiet': quiet, 'strict': strict, 'alias': str.split(alias, ',') if alias else []}
|
|
22
|
-
|
|
23
|
-
projects_data = [p for p in only_projects_data if dir_path in p['path'].as_posix()]
|
|
27
|
+
projects_data = filtered_projects_data(only_projects_data, directory)
|
|
24
28
|
results = {commands.check.run(root, ns, p, cli_options) for p in projects_data}
|
|
25
29
|
if not all(results):
|
|
26
30
|
raise Exit(code=1)
|
|
@@ -35,10 +39,9 @@ def libs_command(strict: Annotated[bool, options.strict]=False, directory: Annot
|
|
|
35
39
|
"""Show third-party libraries used in the workspace."""
|
|
36
40
|
root = repo.get_workspace_root(Path.cwd())
|
|
37
41
|
ns = configuration.get_namespace_from_config(root)
|
|
38
|
-
|
|
42
|
+
all_projects_data = info.get_projects_data(root, ns)
|
|
39
43
|
cli_options = {'strict': strict, 'alias': str.split(alias, ',') if alias else []}
|
|
40
|
-
|
|
41
|
-
projects_data = [p for p in projects_data if dir_path in p['path'].as_posix()]
|
|
44
|
+
projects_data = filtered_projects_data(all_projects_data, directory)
|
|
42
45
|
results = {commands.libs.run(root, ns, p, cli_options) for p in projects_data}
|
|
43
46
|
if not all(results):
|
|
44
47
|
raise Exit(code=1)
|
|
@@ -48,11 +51,18 @@ def sync_command(strict: Annotated[bool, options.strict]=False, quiet: Annotated
|
|
|
48
51
|
"""Update pyproject.toml with missing bricks."""
|
|
49
52
|
root = repo.get_workspace_root(Path.cwd())
|
|
50
53
|
ns = configuration.get_namespace_from_config(root)
|
|
51
|
-
|
|
54
|
+
all_projects_data = info.get_projects_data(root, ns)
|
|
52
55
|
cli_options = {'strict': strict, 'quiet': quiet, 'verbose': verbose}
|
|
53
|
-
|
|
54
|
-
projects_data = [p for p in projects_data if dir_path in p['path'].as_posix()]
|
|
56
|
+
projects_data = filtered_projects_data(all_projects_data, directory)
|
|
55
57
|
for p in projects_data:
|
|
56
58
|
commands.sync.run(root, ns, p, cli_options)
|
|
59
|
+
|
|
60
|
+
@app.command('deps')
|
|
61
|
+
def deps_command(directory: Annotated[str, options.directory]=''):
|
|
62
|
+
"""Visualize the dependencies between bricks."""
|
|
63
|
+
root = repo.get_workspace_root(Path.cwd())
|
|
64
|
+
ns = configuration.get_namespace_from_config(root)
|
|
65
|
+
dir_path = Path(directory).as_posix() if directory else None
|
|
66
|
+
commands.deps.run(root, ns, dir_path)
|
|
57
67
|
if __name__ == '__main__':
|
|
58
68
|
app()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List, Set, Union
|
|
3
|
+
from polylith_cli.polylith import bricks, deps, info
|
|
4
|
+
|
|
5
|
+
def print_report(root: Path, ns: str, bases: Set[str], components: Set[str]):
|
|
6
|
+
brick_imports = deps.get_brick_imports(root, ns, bases, components)
|
|
7
|
+
flattened = {**brick_imports['bases'], **brick_imports['components']}
|
|
8
|
+
deps.print_deps(bases, components, flattened)
|
|
9
|
+
|
|
10
|
+
def pick_name(data: List[dict]) -> Set[str]:
|
|
11
|
+
return {b['name'] for b in data}
|
|
12
|
+
|
|
13
|
+
def get_bases(root: Path, ns: str, project_data: dict) -> Set[str]:
|
|
14
|
+
if project_data:
|
|
15
|
+
return set(project_data.get('bases', []))
|
|
16
|
+
return pick_name(bricks.get_bases_data(root, ns))
|
|
17
|
+
|
|
18
|
+
def get_components(root: Path, ns: str, project_data: dict) -> Set[str]:
|
|
19
|
+
if project_data:
|
|
20
|
+
return set(project_data.get('components', []))
|
|
21
|
+
return pick_name(bricks.get_components_data(root, ns))
|
|
22
|
+
|
|
23
|
+
def run(root: Path, ns: str, directory: Union[str, None]):
|
|
24
|
+
projects_data = info.get_projects_data(root, ns) if directory else []
|
|
25
|
+
project = next((p for p in projects_data if directory in p['path'].as_posix()), {})
|
|
26
|
+
bases = get_bases(root, ns, project)
|
|
27
|
+
components = get_components(root, ns, project)
|
|
28
|
+
print_report(root, ns, bases, components)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Set
|
|
3
|
+
from polylith_cli.polylith import check, workspace
|
|
4
|
+
|
|
5
|
+
def get_brick_imports(root: Path, ns: str, bases: Set[str], components: Set[str]) -> dict:
|
|
6
|
+
bases_paths = workspace.paths.collect_bases_paths(root, ns, bases)
|
|
7
|
+
comp_paths = workspace.paths.collect_components_paths(root, ns, components)
|
|
8
|
+
brick_imports_in_bases = check.collect.extract_bricks(bases_paths, ns)
|
|
9
|
+
brick_imports_in_components = check.collect.extract_bricks(comp_paths, ns)
|
|
10
|
+
return {'bases': check.collect.with_unknown_components(root, ns, brick_imports_in_bases), 'components': check.collect.with_unknown_components(root, ns, brick_imports_in_components)}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from functools import reduce
|
|
2
|
+
from typing import List, Set, Tuple
|
|
3
|
+
from polylith_cli.polylith.reporting import theme
|
|
4
|
+
from rich import box
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from rich.table import Table
|
|
7
|
+
|
|
8
|
+
def calculate_tag(brick: str, project_data: dict) -> str:
|
|
9
|
+
return 'base' if brick in project_data.get('bases', []) else 'comp'
|
|
10
|
+
|
|
11
|
+
def to_col(brick: str, tag: str) -> str:
|
|
12
|
+
name = '\n'.join(brick)
|
|
13
|
+
return f'[{tag}]{name}[/]'
|
|
14
|
+
|
|
15
|
+
def brick_status(bricks: List[str], brick_name: str, imported: str) -> str:
|
|
16
|
+
status = theme.check_emoji if imported in bricks and imported != brick_name else '-'
|
|
17
|
+
return f'[data]{status}[/]'
|
|
18
|
+
|
|
19
|
+
def to_row(name: str, tag: str, brick_imports: dict, imported: List[str]) -> List[str]:
|
|
20
|
+
bricks = brick_imports[name]
|
|
21
|
+
statuses = [brick_status(bricks, name, i) for i in imported]
|
|
22
|
+
return [f'[{tag}]{name}[/]'] + statuses
|
|
23
|
+
|
|
24
|
+
def flatten_import(acc: Set[str], kv: Tuple[str, Set[str]]) -> set:
|
|
25
|
+
key = kv[0]
|
|
26
|
+
values = kv[1]
|
|
27
|
+
return set().union(acc, values.difference({key}))
|
|
28
|
+
|
|
29
|
+
def flatten_imports(brick_imports: dict) -> Set[str]:
|
|
30
|
+
"""Flatten the dict into a set of imports, with the actual brick filtered away when existing as an import"""
|
|
31
|
+
return reduce(flatten_import, brick_imports.items(), set())
|
|
32
|
+
|
|
33
|
+
def create_columns(imported_bases: List[str], imported_components: List[str]) -> List[str]:
|
|
34
|
+
base_cols = [to_col(brick, 'base') for brick in imported_bases]
|
|
35
|
+
comp_cols = [to_col(brick, 'comp') for brick in imported_components]
|
|
36
|
+
return comp_cols + base_cols
|
|
37
|
+
|
|
38
|
+
def create_rows(bases: Set[str], components: Set[str], import_data: dict, imported: List[str]) -> List[List[str]]:
|
|
39
|
+
base_rows = [to_row(b, 'base', import_data, imported) for b in sorted(bases)]
|
|
40
|
+
comp_rows = [to_row(c, 'comp', import_data, imported) for c in sorted(components)]
|
|
41
|
+
return comp_rows + base_rows
|
|
42
|
+
|
|
43
|
+
def print_deps(bases: Set[str], components: Set[str], import_data: dict):
|
|
44
|
+
flattened = flatten_imports(import_data)
|
|
45
|
+
imported_bases = sorted({b for b in flattened if b in bases})
|
|
46
|
+
imported_components = sorted({c for c in flattened if c in components})
|
|
47
|
+
imported_bricks = imported_components + imported_bases
|
|
48
|
+
table = Table(box=box.SIMPLE_HEAD)
|
|
49
|
+
table.add_column('[data]brick[/]')
|
|
50
|
+
cols = create_columns(imported_bases, imported_components)
|
|
51
|
+
rows = create_rows(bases, components, import_data, imported_bricks)
|
|
52
|
+
for col in cols:
|
|
53
|
+
table.add_column(col, justify='center')
|
|
54
|
+
for row in rows:
|
|
55
|
+
table.add_row(*row)
|
|
56
|
+
console = Console(theme=theme.poly_theme)
|
|
57
|
+
console.print(table, overflow='ellipsis')
|
|
@@ -6,7 +6,7 @@ from rich.padding import Padding
|
|
|
6
6
|
from rich.table import Table
|
|
7
7
|
|
|
8
8
|
def brick_status(brick, bricks, command: str) -> str:
|
|
9
|
-
emoji =
|
|
9
|
+
emoji = theme.check_emoji if command == 'info' else ':gear:'
|
|
10
10
|
status = emoji if brick in bricks else '-'
|
|
11
11
|
return f'[data]{status}[/]'
|
|
12
12
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from polylith_cli.polylith import check, deps, info
|
|
3
|
+
|
|
4
|
+
def calculate_diff(root: Path, namespace: str, project_data: dict, workspace_data: dict) -> dict:
|
|
5
|
+
bases = set(project_data['bases'])
|
|
6
|
+
components = set(project_data['components'])
|
|
7
|
+
all_bases = workspace_data['bases']
|
|
8
|
+
all_components = workspace_data['components']
|
|
9
|
+
brick_imports = deps.get_brick_imports(root, namespace, bases, components)
|
|
10
|
+
is_project = info.is_project(project_data)
|
|
11
|
+
if is_project:
|
|
12
|
+
brick_diff = check.collect.imports_diff(brick_imports, bases, components)
|
|
13
|
+
else:
|
|
14
|
+
all_bricks = set().union(all_bases, all_components)
|
|
15
|
+
brick_diff = check.collect.diff(all_bricks, bases, components)
|
|
16
|
+
bases_diff = {b for b in brick_diff if b in all_bases}
|
|
17
|
+
components_diff = {b for b in brick_diff if b in all_components}
|
|
18
|
+
return {'name': project_data['name'], 'path': project_data['path'], 'is_project': is_project, 'bases': bases_diff, 'components': components_diff, 'brick_imports': brick_imports}
|
|
@@ -13,7 +13,7 @@ def print_summary(diff: dict) -> None:
|
|
|
13
13
|
bases = diff['bases']
|
|
14
14
|
components = diff['components']
|
|
15
15
|
anything_to_sync = bases or components
|
|
16
|
-
emoji = ':point_right:' if anything_to_sync else
|
|
16
|
+
emoji = ':point_right:' if anything_to_sync else theme.check_emoji
|
|
17
17
|
printable_name = f'[proj]{name}[/]' if is_project else f'[data]{name}[/]'
|
|
18
18
|
console.print(f'{emoji} {printable_name}')
|
|
19
19
|
for b in bases:
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from polylith_cli.polylith import check, info, workspace
|
|
3
|
-
|
|
4
|
-
def get_brick_imports(root: Path, ns: str, project_data: dict) -> dict:
|
|
5
|
-
bases = {b for b in project_data.get('bases', [])}
|
|
6
|
-
components = {c for c in project_data.get('components', [])}
|
|
7
|
-
bases_paths = workspace.paths.collect_bases_paths(root, ns, bases)
|
|
8
|
-
components_paths = workspace.paths.collect_components_paths(root, ns, components)
|
|
9
|
-
brick_imports_in_bases = check.collect.extract_bricks(bases_paths, ns)
|
|
10
|
-
brick_imports_in_components = check.collect.extract_bricks(components_paths, ns)
|
|
11
|
-
return {'bases': check.collect.with_unknown_components(root, ns, brick_imports_in_bases), 'components': check.collect.with_unknown_components(root, ns, brick_imports_in_components)}
|
|
12
|
-
|
|
13
|
-
def calculate_diff(root: Path, namespace: str, project_data: dict, workspace_data: dict) -> dict:
|
|
14
|
-
brick_imports = get_brick_imports(root, namespace, project_data)
|
|
15
|
-
all_bases = workspace_data['bases']
|
|
16
|
-
all_components = workspace_data['components']
|
|
17
|
-
bases = project_data['bases']
|
|
18
|
-
components = project_data['components']
|
|
19
|
-
is_project = info.is_project(project_data)
|
|
20
|
-
if is_project:
|
|
21
|
-
brick_diff = check.collect.imports_diff(brick_imports, bases, components)
|
|
22
|
-
else:
|
|
23
|
-
all_bricks = set().union(all_bases, all_components)
|
|
24
|
-
brick_diff = check.collect.diff(all_bricks, bases, components)
|
|
25
|
-
bases_diff = {b for b in brick_diff if b in all_bases}
|
|
26
|
-
components_diff = {b for b in brick_diff if b in all_components}
|
|
27
|
-
return {'name': project_data['name'], 'path': project_data['path'], 'is_project': is_project, 'bases': bases_diff, 'components': components_diff, 'brick_imports': brick_imports}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|