polylith-cli 1.43.0__tar.gz → 1.44.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.43.0 → polylith_cli-1.44.0}/PKG-INFO +1 -1
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/core.py +2 -2
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/options.py +2 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/check.py +1 -1
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/info.py +3 -1
- polylith_cli-1.44.0/polylith_cli/polylith/configuration/__init__.py +2 -0
- polylith_cli-1.44.0/polylith_cli/polylith/configuration/core.py +92 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/diff/report.py +1 -1
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/imports/grouping.py +2 -2
- polylith_cli-1.44.0/polylith_cli/polylith/info/__init__.py +3 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/info/report.py +6 -2
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/libs/report.py +9 -6
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/project/get.py +10 -2
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/sync/collect.py +1 -1
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/sync/report.py +1 -1
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/pyproject.toml +1 -1
- polylith_cli-1.43.0/polylith_cli/polylith/configuration/__init__.py +0 -2
- polylith_cli-1.43.0/polylith_cli/polylith/configuration/core.py +0 -67
- polylith_cli-1.43.0/polylith_cli/polylith/info/__init__.py +0 -3
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/README.md +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/alias/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/alias/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/bricks/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/bricks/base.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/bricks/brick.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/bricks/component.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/building/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/building/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/building/paths.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/check/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/check/collect.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/check/report.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/__main__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/build.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/create.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/env.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/cli/test.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/create.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/deps.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/diff.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/libs.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/sync.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/commands/test.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/deps/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/deps/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/deps/report.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/development/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/development/development.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/diff/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/diff/collect.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/dirs/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/dirs/dirs.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/distributions/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/distributions/caching.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/distributions/collect.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/distributions/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/environment/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/environment/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/files/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/files/files.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/imports/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/imports/parser.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/imports/usages.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/info/collect.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interactive/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interactive/project.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interface/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interface/collect.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interface/interfaces.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interface/parser.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interface/report.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/interface/usage.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/libs/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/libs/grouping.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/libs/lock_files.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/libs/stdlib.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/output/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/output/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/parsing/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/parsing/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/parsing/rewrite.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/project/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/project/create.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/project/parser.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/project/templates.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/readme/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/readme/readme.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/repo/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/repo/get.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/repo/repo.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/reporting/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/reporting/theme.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/sync/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/sync/update.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/test/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/test/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/test/report.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/test/tests.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/toml/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/toml/core.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/workspace/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/workspace/create.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/workspace/paths.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/yaml/__init__.py +0 -0
- {polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/yaml/core.py +0 -0
|
@@ -27,11 +27,11 @@ def enriched_with_lock_files_data(root: Path, projects_data: List[dict], is_verb
|
|
|
27
27
|
return [enriched_with_lock_file_data(root, p, is_verbose) for p in projects_data]
|
|
28
28
|
|
|
29
29
|
@app.command('info')
|
|
30
|
-
def info_command(short: Annotated[bool, options.short_workspace]=False, save: Annotated[bool, options.save]=False):
|
|
30
|
+
def info_command(short: Annotated[bool, options.short_workspace]=False, save: Annotated[bool, options.save]=False, group: Annotated[str, options.group]=''):
|
|
31
31
|
"""Info about the Polylith workspace."""
|
|
32
32
|
root = repo.get_workspace_root(Path.cwd())
|
|
33
33
|
output = configuration.get_output_dir(root, 'info') if save else None
|
|
34
|
-
cli_options = {'short': short, 'save': save, 'output': output}
|
|
34
|
+
cli_options = {'short': short, 'save': save, 'output': output, 'groups': set(str.split(group, ',')) if group else set()}
|
|
35
35
|
commands.info.run(root, cli_options)
|
|
36
36
|
|
|
37
37
|
@app.command('check')
|
|
@@ -20,3 +20,5 @@ quiet = Option(help="Do not output any messages.")
|
|
|
20
20
|
brick = Option(help="Shows dependencies for selected brick.")
|
|
21
21
|
save = Option(help="Store the contents of this command to file.")
|
|
22
22
|
interface = Option(help="Show the brick interface.")
|
|
23
|
+
|
|
24
|
+
group = Option(help="Show contents based on configured project group.")
|
|
@@ -47,7 +47,7 @@ def run_each(root: Path, ns: str, project_data: dict, options: dict) -> Tuple[bo
|
|
|
47
47
|
is_quiet = options['quiet']
|
|
48
48
|
is_strict = options['strict']
|
|
49
49
|
is_verbose = options['verbose']
|
|
50
|
-
name = project_data['name']
|
|
50
|
+
name = project_data.get('alias') or project_data['name']
|
|
51
51
|
deps = project_data['deps']
|
|
52
52
|
alias = options['alias']
|
|
53
53
|
from_lock_file = libs.is_from_lock_file(deps)
|
|
@@ -6,7 +6,9 @@ def run(root: Path, options: dict):
|
|
|
6
6
|
bases = info.get_bases(root, ns)
|
|
7
7
|
components = info.get_components(root, ns)
|
|
8
8
|
projects_data = info.get_bricks_in_projects(root, components, bases, ns)
|
|
9
|
+
groups = options.get('groups')
|
|
10
|
+
filtered = [p for p in projects_data if p['groups'].intersection(groups)] if groups else projects_data
|
|
9
11
|
info.print_workspace_summary(projects_data, bases, components, options)
|
|
10
12
|
if not components and (not bases):
|
|
11
13
|
return
|
|
12
|
-
info.print_bricks_in_projects(projects_data, bases, components, options)
|
|
14
|
+
info.print_bricks_in_projects(filtered or projects_data, bases, components, options)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
from polylith_cli.polylith.configuration.core import get_brick_structure_from_config, get_namespace_from_config, get_output_dir, get_project_alias_from_config, get_project_groups_from_config, get_resources_structure_from_config, get_tag_pattern_from_config, get_tag_sort_options_from_config, get_tests_structure_from_config, get_theme_from_config, is_readme_generation_enabled, is_test_generation_enabled
|
|
2
|
+
__all__ = ['get_brick_structure_from_config', 'get_namespace_from_config', 'get_output_dir', 'get_project_alias_from_config', 'get_project_groups_from_config', 'get_resources_structure_from_config', 'get_tag_pattern_from_config', 'get_tag_sort_options_from_config', 'get_tests_structure_from_config', 'get_theme_from_config', 'is_readme_generation_enabled', 'is_test_generation_enabled']
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List, Set, Union
|
|
3
|
+
from polylith_cli.polylith import repo
|
|
4
|
+
|
|
5
|
+
def get_polylith_config(path: Path) -> dict:
|
|
6
|
+
toml: dict = repo.load_workspace_config(path)
|
|
7
|
+
conf = toml.get('tool', {}).get('polylith')
|
|
8
|
+
if not conf:
|
|
9
|
+
message = 'Cannot find a [tool.polylith] configuration.'
|
|
10
|
+
raise ValueError(message)
|
|
11
|
+
return conf
|
|
12
|
+
|
|
13
|
+
def get_namespace_from_config(path: Path) -> str:
|
|
14
|
+
conf = get_polylith_config(path)
|
|
15
|
+
ns = conf.get('namespace')
|
|
16
|
+
if not ns:
|
|
17
|
+
message = 'Cannot find a [tool.polylith.namespace] section.'
|
|
18
|
+
raise ValueError(message)
|
|
19
|
+
return ns
|
|
20
|
+
|
|
21
|
+
def get_tag_pattern_from_config(path: Path, key: Union[str, None]) -> Union[str, None]:
|
|
22
|
+
conf = get_polylith_config(path)
|
|
23
|
+
patterns = conf.get('tag', {}).get('patterns')
|
|
24
|
+
fallback = conf.get('git_tag_pattern')
|
|
25
|
+
if not key:
|
|
26
|
+
stable = patterns.get('stable') if patterns else None
|
|
27
|
+
return stable or fallback
|
|
28
|
+
return patterns.get(key) if patterns else None
|
|
29
|
+
|
|
30
|
+
def get_tag_sort_options_from_config(path: Path) -> List[str]:
|
|
31
|
+
conf = get_polylith_config(path)
|
|
32
|
+
options = conf.get('tag', {}).get('sorting')
|
|
33
|
+
if options is None:
|
|
34
|
+
return ['-committerdate']
|
|
35
|
+
return options
|
|
36
|
+
|
|
37
|
+
def is_test_generation_enabled(path: Path) -> bool:
|
|
38
|
+
conf = get_polylith_config(path)
|
|
39
|
+
enabled = conf.get('test', {}).get('enabled')
|
|
40
|
+
return bool(enabled)
|
|
41
|
+
|
|
42
|
+
def is_readme_generation_enabled(path: Path) -> bool:
|
|
43
|
+
conf = get_polylith_config(path)
|
|
44
|
+
enabled = conf.get('resources', {}).get('brick_docs_enabled')
|
|
45
|
+
return bool(enabled)
|
|
46
|
+
|
|
47
|
+
def get_theme_from_config(path: Path) -> str:
|
|
48
|
+
conf = get_polylith_config(path)
|
|
49
|
+
return conf.get('structure', {}).get('theme') or 'tdd'
|
|
50
|
+
|
|
51
|
+
def get_brick_structure_from_config(path: Path) -> str:
|
|
52
|
+
theme = get_theme_from_config(path)
|
|
53
|
+
if theme == 'loose':
|
|
54
|
+
return '{brick}/{namespace}/{package}'
|
|
55
|
+
return '{brick}/{package}/src/{namespace}/{package}'
|
|
56
|
+
|
|
57
|
+
def get_tests_structure_from_config(path: Path) -> str:
|
|
58
|
+
theme = get_theme_from_config(path)
|
|
59
|
+
if theme == 'loose':
|
|
60
|
+
return 'test/{brick}/{namespace}/{package}'
|
|
61
|
+
return '{brick}/{package}/test/{namespace}/{package}'
|
|
62
|
+
|
|
63
|
+
def get_resources_structure_from_config(path: Path) -> str:
|
|
64
|
+
theme = get_theme_from_config(path)
|
|
65
|
+
if theme == 'loose':
|
|
66
|
+
return '{brick}/{namespace}/{package}'
|
|
67
|
+
return '{brick}/{package}'
|
|
68
|
+
|
|
69
|
+
def get_output_dir(path: Path, command_name: str) -> str:
|
|
70
|
+
conf = get_polylith_config(path)
|
|
71
|
+
key = 'output'
|
|
72
|
+
commands = conf.get('commands') or {}
|
|
73
|
+
command = commands.get(command_name) or {}
|
|
74
|
+
output = command.get(key) or commands.get(key)
|
|
75
|
+
fallback = f'{repo.development_dir}/poly'
|
|
76
|
+
return output or fallback
|
|
77
|
+
|
|
78
|
+
def get_projects_config(path: Path) -> dict:
|
|
79
|
+
conf = get_polylith_config(path)
|
|
80
|
+
return conf.get('projects', {})
|
|
81
|
+
|
|
82
|
+
def get_project_alias_from_config(path: Path, project_name: str) -> Union[str, None]:
|
|
83
|
+
projects_conf = get_projects_config(path)
|
|
84
|
+
alias = projects_conf.get('alias', {})
|
|
85
|
+
return alias.get(project_name)
|
|
86
|
+
|
|
87
|
+
def get_project_groups_from_config(path: Path, project_name: str) -> Set[str]:
|
|
88
|
+
projects_conf = get_projects_config(path)
|
|
89
|
+
groups = projects_conf.get('groups') or {}
|
|
90
|
+
if not groups:
|
|
91
|
+
return set()
|
|
92
|
+
return {k for k, v in groups.items() if project_name in v}
|
|
@@ -9,7 +9,7 @@ def print_diff_details(projects_data: List[dict], bases: List[str], components:
|
|
|
9
9
|
return
|
|
10
10
|
console = Console(theme=theme.poly_theme)
|
|
11
11
|
options = {'command': 'diff'}
|
|
12
|
-
table = info.
|
|
12
|
+
table = info.build_bricks_in_projects_table(projects_data, bases, components, options)
|
|
13
13
|
console.print(table, overflow='ellipsis')
|
|
14
14
|
|
|
15
15
|
def print_detected_changes(changes: List[str], markup: str, short: bool) -> None:
|
|
@@ -2,7 +2,7 @@ from typing import Set, Union
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def only_brick_imports(imports: Set[str], top_ns: str) -> Set[str]:
|
|
5
|
-
return {i for i in imports if i.startswith(top_ns)}
|
|
5
|
+
return {i for i in imports if i == top_ns or i.startswith(f"{top_ns}.")}
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def only_bricks(import_data: dict, top_ns: str) -> dict:
|
|
@@ -29,7 +29,7 @@ def exclude_empty(import_data: dict) -> dict:
|
|
|
29
29
|
return {k: v for k, v in import_data.items() if v}
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def extract_brick_imports(all_imports: dict, top_ns) -> dict:
|
|
32
|
+
def extract_brick_imports(all_imports: dict, top_ns: str) -> dict:
|
|
33
33
|
with_only_bricks = only_bricks(all_imports, top_ns)
|
|
34
34
|
with_only_brick_names = only_brick_names(with_only_bricks)
|
|
35
35
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
from polylith_cli.polylith.info.collect import find_unused_bases, get_bases, get_bricks_in_projects, get_components, get_projects_data
|
|
2
|
+
from polylith_cli.polylith.info.report import build_bricks_in_projects_table, is_project, print_bricks_in_projects, print_workspace_summary
|
|
3
|
+
__all__ = ['find_unused_bases', 'get_bases', 'get_bricks_in_projects', 'get_components', 'get_projects_data', 'build_bricks_in_projects_table', 'is_project', 'print_bricks_in_projects', 'print_workspace_summary']
|
|
@@ -15,12 +15,13 @@ def is_project(project: dict) -> bool:
|
|
|
15
15
|
return project['type'] == 'project'
|
|
16
16
|
|
|
17
17
|
def printable_name(project: dict, short: bool) -> str:
|
|
18
|
+
alias = project.get('alias')
|
|
18
19
|
if is_project(project):
|
|
19
20
|
template = '[proj]{name}[/]'
|
|
20
|
-
name = project['name']
|
|
21
|
+
name = alias or project['name']
|
|
21
22
|
else:
|
|
22
23
|
template = '[data]{name}[/]'
|
|
23
|
-
name = 'development'
|
|
24
|
+
name = alias or 'development'
|
|
24
25
|
if short:
|
|
25
26
|
return template.format(name='\n'.join(name))
|
|
26
27
|
return template.format(name=name)
|
|
@@ -53,6 +54,7 @@ def print_bricks_in_projects(projects_data: List[dict], bases: List[str], compon
|
|
|
53
54
|
|
|
54
55
|
def print_workspace_summary(projects_data: List[dict], bases: List[str], components: List[str], options: dict) -> None:
|
|
55
56
|
save = options.get('save', False)
|
|
57
|
+
groups = ', '.join(options.get('groups') or set())
|
|
56
58
|
console = Console(theme=theme.poly_theme, record=save)
|
|
57
59
|
console.print(Padding('[data]Workspace summary[/]', (1, 0, 1, 0)))
|
|
58
60
|
number_of_projects = len([p for p in projects_data if is_project(p)])
|
|
@@ -63,5 +65,7 @@ def print_workspace_summary(projects_data: List[dict], bases: List[str], compone
|
|
|
63
65
|
console.print(f'[comp]components[/]: [data]{number_of_components}[/]')
|
|
64
66
|
console.print(f'[base]bases[/]: [data]{number_of_bases}[/]')
|
|
65
67
|
console.print(f'[data]development[/]: [data]{number_of_dev}[/]')
|
|
68
|
+
if groups:
|
|
69
|
+
console.print(Padding(f'[data]group[/]: [proj]{groups}[/]', (1, 0, 0, 0)))
|
|
66
70
|
if save:
|
|
67
71
|
output.save_recorded(console, options, 'workspace_summary')
|
|
@@ -83,13 +83,16 @@ def printable_version(version: Union[str, None], is_same_version: bool) -> str:
|
|
|
83
83
|
def get_version(lib: str, project_data: dict) -> str:
|
|
84
84
|
return project_data['deps']['items'].get(lib)
|
|
85
85
|
|
|
86
|
-
def find_version(lib: str,
|
|
87
|
-
project_data = next((p for p in projects_data if p['name'] == project_name))
|
|
86
|
+
def find_version(lib: str, project_data: dict) -> Union[str, None]:
|
|
88
87
|
return get_version(lib, project_data)
|
|
89
88
|
|
|
90
89
|
def printable_header(header: str, short: bool) -> str:
|
|
91
90
|
return '\n'.join(header) if short else header
|
|
92
91
|
|
|
92
|
+
def printable_project_header(project_data: dict, short: bool) -> str:
|
|
93
|
+
name = project_data.get('alias') or project_data['name']
|
|
94
|
+
return printable_header(name, short)
|
|
95
|
+
|
|
93
96
|
def is_same_version(versions: list) -> bool:
|
|
94
97
|
unique = {v for v in versions if v}
|
|
95
98
|
return len(unique) == 1 if unique else True
|
|
@@ -97,14 +100,14 @@ def is_same_version(versions: list) -> bool:
|
|
|
97
100
|
def libs_in_projects_table(development_data: dict, projects_data: List[dict], libraries: set, options: dict) -> Table:
|
|
98
101
|
table = Table(box=box.SIMPLE_HEAD)
|
|
99
102
|
short = options['short']
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
projects = sorted(projects_data, key=lambda p: p['name'])
|
|
104
|
+
proj_headers = [f'[proj]{printable_project_header(p, short)}[/]' for p in projects]
|
|
102
105
|
dev_header = printable_header('development', short)
|
|
103
|
-
headers = ['[data]library[/]'] +
|
|
106
|
+
headers = ['[data]library[/]'] + proj_headers + [f'[data]{dev_header}[/]']
|
|
104
107
|
for header in headers:
|
|
105
108
|
table.add_column(header)
|
|
106
109
|
for lib in sorted(libraries):
|
|
107
|
-
proj_versions = [find_version(lib,
|
|
110
|
+
proj_versions = [find_version(lib, p) for p in projects]
|
|
108
111
|
dev_version = get_version(lib, development_data)
|
|
109
112
|
is_same = is_same_version(proj_versions + [dev_version])
|
|
110
113
|
printable_proj_versions = [printable_version(v, is_same) for v in proj_versions]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from functools import lru_cache
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from typing import List
|
|
3
|
+
from typing import List, Set, Union
|
|
4
4
|
import tomlkit
|
|
5
5
|
from polylith_cli.polylith import configuration, repo, toml
|
|
6
6
|
from polylith_cli.polylith.project import templates
|
|
@@ -17,6 +17,14 @@ def get_project_name_from_toml(data: dict) -> str:
|
|
|
17
17
|
path = data['path']
|
|
18
18
|
raise KeyError(f'Error in {path}') from e
|
|
19
19
|
|
|
20
|
+
def get_project_alias(path: Path, data: dict) -> Union[str, None]:
|
|
21
|
+
project_name = get_project_name_from_toml(data)
|
|
22
|
+
return configuration.get_project_alias_from_config(path, project_name)
|
|
23
|
+
|
|
24
|
+
def get_project_groups(path: Path, data: dict) -> Set[str]:
|
|
25
|
+
project_name = get_project_name_from_toml(data)
|
|
26
|
+
return configuration.get_project_groups_from_config(path, project_name)
|
|
27
|
+
|
|
20
28
|
@lru_cache
|
|
21
29
|
def get_toml(path: Path) -> tomlkit.TOMLDocument:
|
|
22
30
|
return toml.read_toml_document(path)
|
|
@@ -40,7 +48,7 @@ def get_toml_files(root: Path) -> List[dict]:
|
|
|
40
48
|
def get_packages_for_projects(root: Path) -> List[dict]:
|
|
41
49
|
toml_files = get_toml_files(root)
|
|
42
50
|
namespace = configuration.get_namespace_from_config(root)
|
|
43
|
-
return [{'name': get_project_name_from_toml(d), 'packages': toml.get_project_package_includes(namespace, d['toml']), 'path': d['path'], 'type': d['type'], 'deps': toml.get_project_dependencies(d['toml']), 'exclude': toml.collect_configured_exclude_patterns(d['toml'])} for d in toml_files]
|
|
51
|
+
return [{'name': get_project_name_from_toml(d), 'alias': get_project_alias(root, d), 'groups': get_project_groups(root, d), 'packages': toml.get_project_package_includes(namespace, d['toml']), 'path': d['path'], 'type': d['type'], 'deps': toml.get_project_dependencies(d['toml']), 'exclude': toml.collect_configured_exclude_patterns(d['toml'])} for d in toml_files]
|
|
44
52
|
|
|
45
53
|
def _get_poetry_template(pyproject: dict) -> str:
|
|
46
54
|
if repo.is_pep_621_ready(pyproject):
|
|
@@ -29,7 +29,7 @@ def _calculate(root: Path, namespace: str, project_data: dict, bases: Set[str])
|
|
|
29
29
|
bases_diff = {b for b in brick_diff if b in all_bases}
|
|
30
30
|
comp_diff = {b for b in brick_diff if b in all_components}
|
|
31
31
|
fn = partial(_without_empty, root, namespace)
|
|
32
|
-
return {'name': project_data['name'], 'path': project_data['path'], 'is_project': is_project, 'bases': bases_diff if is_project else fn(bases_diff, 'bases'), 'components': comp_diff if is_project else fn(comp_diff, 'components'), 'brick_imports': brick_imports}
|
|
32
|
+
return {'name': project_data['name'], 'alias': project_data['alias'], 'path': project_data['path'], 'is_project': is_project, 'bases': bases_diff if is_project else fn(bases_diff, 'bases'), 'components': comp_diff if is_project else fn(comp_diff, 'components'), 'brick_imports': brick_imports}
|
|
33
33
|
|
|
34
34
|
def calculate_diff(root: Path, namespace: str, project_data: dict) -> dict:
|
|
35
35
|
bases = set(project_data['bases'])
|
|
@@ -9,7 +9,7 @@ def print_brick_imports(diff: dict) -> None:
|
|
|
9
9
|
def print_summary(diff: dict) -> None:
|
|
10
10
|
console = Console(theme=theme.poly_theme)
|
|
11
11
|
is_project = diff['is_project']
|
|
12
|
-
name = diff['name'] if is_project else 'development'
|
|
12
|
+
name = diff['alias'] or diff['name'] if is_project else 'development'
|
|
13
13
|
bases = diff['bases']
|
|
14
14
|
components = diff['components']
|
|
15
15
|
anything_to_sync = bases or components
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
from polylith_cli.polylith.configuration.core import get_brick_structure_from_config, get_namespace_from_config, get_output_dir, get_resources_structure_from_config, get_tag_pattern_from_config, get_tag_sort_options_from_config, get_tests_structure_from_config, get_theme_from_config, is_readme_generation_enabled, is_test_generation_enabled
|
|
2
|
-
__all__ = ['get_brick_structure_from_config', 'get_namespace_from_config', 'get_output_dir', 'get_resources_structure_from_config', 'get_tag_pattern_from_config', 'get_tag_sort_options_from_config', 'get_tests_structure_from_config', 'get_theme_from_config', 'is_readme_generation_enabled', 'is_test_generation_enabled']
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import List, Union
|
|
3
|
-
from polylith_cli.polylith import repo
|
|
4
|
-
|
|
5
|
-
def get_namespace_from_config(path: Path) -> str:
|
|
6
|
-
toml: dict = repo.load_workspace_config(path)
|
|
7
|
-
return toml['tool']['polylith']['namespace']
|
|
8
|
-
|
|
9
|
-
def get_git_tag_pattern(toml: dict) -> str:
|
|
10
|
-
"""Fallback git tag pattern configuration"""
|
|
11
|
-
return toml['tool']['polylith']['git_tag_pattern']
|
|
12
|
-
|
|
13
|
-
def get_tag_pattern_from_config(path: Path, key: Union[str, None]) -> Union[str, None]:
|
|
14
|
-
toml: dict = repo.load_workspace_config(path)
|
|
15
|
-
patterns = toml['tool']['polylith'].get('tag', {}).get('patterns')
|
|
16
|
-
if not key:
|
|
17
|
-
return patterns['stable'] if patterns else get_git_tag_pattern(toml)
|
|
18
|
-
return patterns.get(key)
|
|
19
|
-
|
|
20
|
-
def get_tag_sort_options_from_config(path: Path) -> List[str]:
|
|
21
|
-
toml: dict = repo.load_workspace_config(path)
|
|
22
|
-
options = toml['tool']['polylith'].get('tag', {}).get('sorting')
|
|
23
|
-
if options is None:
|
|
24
|
-
return ['-committerdate']
|
|
25
|
-
return options
|
|
26
|
-
|
|
27
|
-
def is_test_generation_enabled(path: Path) -> bool:
|
|
28
|
-
toml: dict = repo.load_workspace_config(path)
|
|
29
|
-
enabled = toml['tool']['polylith']['test']['enabled']
|
|
30
|
-
return bool(enabled)
|
|
31
|
-
|
|
32
|
-
def is_readme_generation_enabled(path: Path) -> bool:
|
|
33
|
-
toml: dict = repo.load_workspace_config(path)
|
|
34
|
-
enabled = toml['tool']['polylith'].get('resources', {}).get('brick_docs_enabled')
|
|
35
|
-
return bool(enabled)
|
|
36
|
-
|
|
37
|
-
def get_theme_from_config(path: Path) -> str:
|
|
38
|
-
toml: dict = repo.load_workspace_config(path)
|
|
39
|
-
return toml['tool']['polylith']['structure'].get('theme') or 'tdd'
|
|
40
|
-
|
|
41
|
-
def get_brick_structure_from_config(path: Path) -> str:
|
|
42
|
-
theme = get_theme_from_config(path)
|
|
43
|
-
if theme == 'loose':
|
|
44
|
-
return '{brick}/{namespace}/{package}'
|
|
45
|
-
return '{brick}/{package}/src/{namespace}/{package}'
|
|
46
|
-
|
|
47
|
-
def get_tests_structure_from_config(path: Path) -> str:
|
|
48
|
-
theme = get_theme_from_config(path)
|
|
49
|
-
if theme == 'loose':
|
|
50
|
-
return 'test/{brick}/{namespace}/{package}'
|
|
51
|
-
return '{brick}/{package}/test/{namespace}/{package}'
|
|
52
|
-
|
|
53
|
-
def get_resources_structure_from_config(path: Path) -> str:
|
|
54
|
-
theme = get_theme_from_config(path)
|
|
55
|
-
if theme == 'loose':
|
|
56
|
-
return '{brick}/{namespace}/{package}'
|
|
57
|
-
return '{brick}/{package}'
|
|
58
|
-
|
|
59
|
-
def get_output_dir(path: Path, command_name: str) -> str:
|
|
60
|
-
toml: dict = repo.load_workspace_config(path)
|
|
61
|
-
key = 'output'
|
|
62
|
-
tool = toml['tool']['polylith']
|
|
63
|
-
commands = tool.get('commands', {})
|
|
64
|
-
command = commands.get(command_name, {})
|
|
65
|
-
output = command.get(key) or commands.get(key)
|
|
66
|
-
fallback = f'{repo.development_dir}/poly'
|
|
67
|
-
return output or fallback
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
from polylith_cli.polylith.info.collect import find_unused_bases, get_bases, get_bricks_in_projects, get_components, get_projects_data
|
|
2
|
-
from polylith_cli.polylith.info.report import is_project, print_bricks_in_projects, print_workspace_summary
|
|
3
|
-
__all__ = ['find_unused_bases', 'get_bases', 'get_bricks_in_projects', 'get_components', 'get_projects_data', 'is_project', 'print_bricks_in_projects', 'print_workspace_summary']
|
|
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
|
{polylith_cli-1.43.0 → polylith_cli-1.44.0}/polylith_cli/polylith/development/development.py
RENAMED
|
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
|