This commit introduces a large-scale structural refactor of the pkgmgr
codebase. All functionality has been moved from the previous flat
top-level layout into three clearly separated namespaces:
• pkgmgr.actions – high-level operations invoked by the CLI
• pkgmgr.core – pure logic, helpers, repository utilities,
versioning, git helpers, config IO, and
command resolution
• pkgmgr.cli – parser, dispatch, context, and command
handlers
Key improvements:
- Moved all “branch”, “release”, “changelog”, repo-management
actions, installer pipelines, and proxy execution logic into
pkgmgr.actions.<domain>.
- Reworked installer structure under
pkgmgr.actions.repository.install.installers
including OS-package installers, Nix, Python, and Makefile.
- Consolidated all low-level functionality under pkgmgr.core:
• git helpers → core/git
• config load/save → core/config
• repository helpers → core/repository
• versioning & semver → core/version
• command helpers (alias, resolve, run, ink) → core/command
- Replaced pkgmgr.cli_core with pkgmgr.cli and updated all imports.
- Added minimal __init__.py files for clean package exposure.
- Updated all E2E, integration, and unit tests with new module paths.
- Fixed patch targets so mocks point to the new structure.
- Ensured backward compatibility at the CLI boundary (pkgmgr entry point unchanged).
This refactor produces a cleaner, layered architecture:
- `core` = logic
- `actions` = orchestrated behaviour
- `cli` = user interface
Reference: ChatGPT-assisted refactor discussion
https://chatgpt.com/share/6938221c-e24c-800f-8317-7732cedf39b9
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
import os
|
|
from pkgmgr.core.repository.identifier import get_repo_identifier
|
|
from pkgmgr.core.repository.dir import get_repo_dir
|
|
from pkgmgr.core.command.run import run_command
|
|
import sys
|
|
|
|
def exec_proxy_command(proxy_prefix: str, selected_repos, repositories_base_dir, all_repos, proxy_command: str, extra_args, preview: bool):
|
|
"""Execute a given proxy command with extra arguments for each repository."""
|
|
error_repos = []
|
|
max_exit_code = 0
|
|
|
|
for repo in selected_repos:
|
|
repo_identifier = get_repo_identifier(repo, all_repos)
|
|
repo_dir = get_repo_dir(repositories_base_dir, repo)
|
|
|
|
if not os.path.exists(repo_dir):
|
|
print(f"Repository directory '{repo_dir}' not found for {repo_identifier}.")
|
|
continue
|
|
|
|
full_cmd = f"{proxy_prefix} {proxy_command} {' '.join(extra_args)}"
|
|
|
|
try:
|
|
run_command(full_cmd, cwd=repo_dir, preview=preview)
|
|
except SystemExit as e:
|
|
print(f"[ERROR] Command failed in {repo_identifier} with exit code {e.code}.")
|
|
error_repos.append((repo_identifier, e.code))
|
|
max_exit_code = max(max_exit_code, e.code)
|
|
|
|
if error_repos:
|
|
print("\nSummary of failed commands:")
|
|
for repo_identifier, exit_code in error_repos:
|
|
print(f"- {repo_identifier} failed with exit code {exit_code}")
|
|
sys.exit(max_exit_code) |