py-wlcli 0.8.0__py3-none-any.whl
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.
- py_wlcli-0.8.0.dist-info/METADATA +139 -0
- py_wlcli-0.8.0.dist-info/RECORD +320 -0
- py_wlcli-0.8.0.dist-info/WHEEL +4 -0
- py_wlcli-0.8.0.dist-info/entry_points.txt +2 -0
- py_wlcli-0.8.0.dist-info/licenses/LICENSE +21 -0
- wl_cli/__init__.py +27 -0
- wl_cli/__main__.py +130 -0
- wl_cli/capabilities.py +79 -0
- wl_cli/cc/__init__.py +5 -0
- wl_cli/cc/checks.py +1019 -0
- wl_cli/cc/cli.py +370 -0
- wl_cli/cc/mutate.py +1350 -0
- wl_cli/cli_click.py +156 -0
- wl_cli/commands/__init__.py +84 -0
- wl_cli/commands/base.py +80 -0
- wl_cli/commands/buildcommands/__init__.py +1 -0
- wl_cli/commands/buildcommands/build.py +71 -0
- wl_cli/commands/buildcommands/build_utils.py +47 -0
- wl_cli/commands/buildcommands/builders/__init__.py +18 -0
- wl_cli/commands/buildcommands/builders/cleanup.py +35 -0
- wl_cli/commands/buildcommands/builders/coordinator.py +122 -0
- wl_cli/commands/buildcommands/builders/environment.py +81 -0
- wl_cli/commands/buildcommands/builders/rust_builder.py +39 -0
- wl_cli/commands/buildcommands/builders/stubs.py +58 -0
- wl_cli/commands/buildcommands/dist.py +326 -0
- wl_cli/commands/buildcommands/test.py +89 -0
- wl_cli/commands/clean/__init__.py +1 -0
- wl_cli/commands/clean/build.py +151 -0
- wl_cli/commands/clean/clean.py +294 -0
- wl_cli/commands/clean/clean_utils.py +77 -0
- wl_cli/commands/clean/core.py +236 -0
- wl_cli/commands/clean/dead_code/__init__.py +0 -0
- wl_cli/commands/clean/dead_code/dead_code_command.py +70 -0
- wl_cli/commands/clean/dead_code/detector.py +161 -0
- wl_cli/commands/clean/dead_code/fixer.py +176 -0
- wl_cli/commands/clean/dead_code/reporter.py +295 -0
- wl_cli/commands/clean/dead_code/utils.py +0 -0
- wl_cli/commands/clean/lfs.py +215 -0
- wl_cli/commands/clean/python.py +81 -0
- wl_cli/commands/clean/rust.py +91 -0
- wl_cli/commands/clean/utils/__init__.py +34 -0
- wl_cli/commands/clean/venv.py +91 -0
- wl_cli/commands/cleanup.py +73 -0
- wl_cli/commands/click_base.py +79 -0
- wl_cli/commands/config/__init__.py +1 -0
- wl_cli/commands/config/config.py +291 -0
- wl_cli/commands/debug/__init__.py +6 -0
- wl_cli/commands/debug/debug.py +309 -0
- wl_cli/commands/debug/debug_cache.py +86 -0
- wl_cli/commands/debug/debug_subagent.py +156 -0
- wl_cli/commands/debug/output_formatter.py +165 -0
- wl_cli/commands/debug/source_hasher.py +92 -0
- wl_cli/commands/format/__init__.py +13 -0
- wl_cli/commands/format/format_cache_adapter.py +125 -0
- wl_cli/commands/format/format_command.py +197 -0
- wl_cli/commands/format/format_coordinator.py +191 -0
- wl_cli/commands/format/format_executor.py +470 -0
- wl_cli/commands/format/format_outcome.py +44 -0
- wl_cli/commands/format/format_path_handler.py +1016 -0
- wl_cli/commands/format/format_progress.py +62 -0
- wl_cli/commands/format/format_reporter.py +31 -0
- wl_cli/commands/format/python_formatter.py +506 -0
- wl_cli/commands/format/rust_formatter.py +106 -0
- wl_cli/commands/gate/__init__.py +1 -0
- wl_cli/commands/gate/gate_command.py +862 -0
- wl_cli/commands/gate/preflight.py +445 -0
- wl_cli/commands/git/__init__.py +1 -0
- wl_cli/commands/git/config.py +169 -0
- wl_cli/commands/git/git_facts.py +60 -0
- wl_cli/commands/git/git_flow.py +86 -0
- wl_cli/commands/git/hook.py +112 -0
- wl_cli/commands/git/policy.py +216 -0
- wl_cli/commands/git/push_update.py +82 -0
- wl_cli/commands/initenv/__init__.py +1 -0
- wl_cli/commands/initenv/common/__init__.py +23 -0
- wl_cli/commands/initenv/common/check_git_bash.py +78 -0
- wl_cli/commands/initenv/common/error_handler.py +68 -0
- wl_cli/commands/initenv/common/exceptions.py +52 -0
- wl_cli/commands/initenv/components/__init__.py +4 -0
- wl_cli/commands/initenv/components/cargo_sync.py +240 -0
- wl_cli/commands/initenv/components/config_manager.py +106 -0
- wl_cli/commands/initenv/components/directory_utils.py +71 -0
- wl_cli/commands/initenv/components/git/__init__.py +9 -0
- wl_cli/commands/initenv/components/git/branch_creator.py +143 -0
- wl_cli/commands/initenv/components/git/git_flow_interface.py +24 -0
- wl_cli/commands/initenv/components/git/git_flow_manager.py +159 -0
- wl_cli/commands/initenv/components/git/git_lfs_manager.py +272 -0
- wl_cli/commands/initenv/components/git/git_utility.py +254 -0
- wl_cli/commands/initenv/components/git/gitignore_manager.py +53 -0
- wl_cli/commands/initenv/components/git_initializer.py +212 -0
- wl_cli/commands/initenv/components/i18n_manager.py +104 -0
- wl_cli/commands/initenv/components/log_manager.py +241 -0
- wl_cli/commands/initenv/components/project_structure/__init__.py +23 -0
- wl_cli/commands/initenv/components/project_structure/config_generator.py +360 -0
- wl_cli/commands/initenv/components/project_structure/directory_creator.py +184 -0
- wl_cli/commands/initenv/components/project_structure/hook_source.py +110 -0
- wl_cli/commands/initenv/components/project_structure/hooks_manager.py +995 -0
- wl_cli/commands/initenv/components/project_structure/readme_handler.py +56 -0
- wl_cli/commands/initenv/components/project_structure/rust_files_handler.py +30 -0
- wl_cli/commands/initenv/components/project_structure/setup_handler.py +103 -0
- wl_cli/commands/initenv/components/project_structure/sop_generator.py +73 -0
- wl_cli/commands/initenv/components/project_structure/template_copier.py +104 -0
- wl_cli/commands/initenv/components/project_structure/template_manager.py +195 -0
- wl_cli/commands/initenv/components/pyproject_generator.py +194 -0
- wl_cli/commands/initenv/components/rust_initializer.py +145 -0
- wl_cli/commands/initenv/components/symlink_cleaner.py +99 -0
- wl_cli/commands/initenv/components/symlink_manager.py +52 -0
- wl_cli/commands/initenv/components/venv_manager.py +118 -0
- wl_cli/commands/initenv/initenv.py +169 -0
- wl_cli/commands/initenv/services/__init__.py +11 -0
- wl_cli/commands/initenv/services/environment_initializer.py +288 -0
- wl_cli/commands/initenv/services/git_lfs_initializer.py +26 -0
- wl_cli/commands/initenv/services/project_structure_initializer.py +52 -0
- wl_cli/commands/lfs/README.md +221 -0
- wl_cli/commands/lfs/__init__.py +5 -0
- wl_cli/commands/lfs/cli.py +106 -0
- wl_cli/commands/lfs/config.py +164 -0
- wl_cli/commands/lfs/hook.py +61 -0
- wl_cli/commands/lfs/initializer.py +531 -0
- wl_cli/commands/lfs/manager.py +95 -0
- wl_cli/commands/lfs/policy.py +165 -0
- wl_cli/commands/lfs/watcher.py +294 -0
- wl_cli/commands/lint/__init__.py +1 -0
- wl_cli/commands/lint/lint_command.py +297 -0
- wl_cli/commands/lint/lint_executor.py +409 -0
- wl_cli/commands/lint/lint_reporter.py +579 -0
- wl_cli/commands/lint/lint_run.py +258 -0
- wl_cli/commands/lint/mypy_config.py +90 -0
- wl_cli/commands/registry.py +103 -0
- wl_cli/commands/self/__init__.py +7 -0
- wl_cli/commands/self/common/__init__.py +8 -0
- wl_cli/commands/self/common/capabilities.py +30 -0
- wl_cli/commands/self/common/config.py +27 -0
- wl_cli/commands/self/common/version_cache.py +85 -0
- wl_cli/commands/self/handlers/__init__.py +19 -0
- wl_cli/commands/self/handlers/base_handler.py +28 -0
- wl_cli/commands/self/handlers/install_handler.py +85 -0
- wl_cli/commands/self/handlers/status_handler.py +66 -0
- wl_cli/commands/self/handlers/uninstall_handler.py +58 -0
- wl_cli/commands/self/handlers/update_handler.py +102 -0
- wl_cli/commands/self/handlers/version_handler.py +16 -0
- wl_cli/commands/self/self_command.py +237 -0
- wl_cli/commands/self/services/__init__.py +15 -0
- wl_cli/commands/self/services/installation_manager.py +187 -0
- wl_cli/commands/self/services/local_installer.py +165 -0
- wl_cli/commands/self/services/pypi_updater.py +278 -0
- wl_cli/commands/self/services/windows_update.py +174 -0
- wl_cli/commands/testcommands/__init__.py +8 -0
- wl_cli/commands/testcommands/base_dependency_analyzer.py +198 -0
- wl_cli/commands/testcommands/batch_processor.py +278 -0
- wl_cli/commands/testcommands/cache_manager.py +1156 -0
- wl_cli/commands/testcommands/coverage_analyzer.py +955 -0
- wl_cli/commands/testcommands/coverage_cache_manager.py +183 -0
- wl_cli/commands/testcommands/progress_manager.py +79 -0
- wl_cli/commands/testcommands/python_env_detector.py +207 -0
- wl_cli/commands/testcommands/report_generator.py +101 -0
- wl_cli/commands/testcommands/single_test_executor.py +250 -0
- wl_cli/commands/testcommands/speed_checker.py +118 -0
- wl_cli/commands/testcommands/test_command_builder.py +165 -0
- wl_cli/commands/testcommands/test_commands.py +786 -0
- wl_cli/commands/testcommands/test_reporter.py +181 -0
- wl_cli/commands/testcommands/test_result_handler.py +96 -0
- wl_cli/commands/testcommands/test_runner.py +1343 -0
- wl_cli/commands/testcommands/test_utils.py +197 -0
- wl_cli/commands/testcommands/utils/__init__.py +17 -0
- wl_cli/commands/testcommands/utils/coverage_parser.py +98 -0
- wl_cli/commands/testcommands/utils/env_info.py +36 -0
- wl_cli/commands/testcommands/utils/junit_parser.py +75 -0
- wl_cli/commands/testcommands/utils/markdown_utils.py +20 -0
- wl_cli/commands/testcommands/utils/project_root.py +61 -0
- wl_cli/commands/update/__init__.py +9 -0
- wl_cli/commands/update/services/__init__.py +21 -0
- wl_cli/commands/update/services/backup_manager.py +207 -0
- wl_cli/commands/update/services/component_manager.py +83 -0
- wl_cli/commands/update/services/conflict_resolver.py +189 -0
- wl_cli/commands/update/services/vendors_updater.py +85 -0
- wl_cli/commands/update/services/version_tracker.py +127 -0
- wl_cli/commands/update/update_command.py +270 -0
- wl_cli/commands/update/utils/__init__.py +3 -0
- wl_cli/commands/version/__init__.py +9 -0
- wl_cli/commands/version/version_command.py +155 -0
- wl_cli/commands/workflow.py +477 -0
- wl_cli/env/__init__.py +5 -0
- wl_cli/env/cli.py +167 -0
- wl_cli/env_status.py +157 -0
- wl_cli/envelope.py +91 -0
- wl_cli/exceptions.py +85 -0
- wl_cli/lib/__init__.py +3 -0
- wl_cli/lib/rust_utils.py +35 -0
- wl_cli/mcp/__init__.py +6 -0
- wl_cli/mcp/capabilities.py +19 -0
- wl_cli/mcp/cli.py +22 -0
- wl_cli/mcp/gitlab.py +553 -0
- wl_cli/mcp/k8s.py +344 -0
- wl_cli/mcp/protocol.py +159 -0
- wl_cli/platform.py +139 -0
- wl_cli/quality/__init__.py +18 -0
- wl_cli/utils/__init__.py +7 -0
- wl_cli/utils/cache.py +491 -0
- wl_cli/utils/cache_ledger.py +355 -0
- wl_cli/utils/cache_store.py +546 -0
- wl_cli/utils/config/__init__.py +27 -0
- wl_cli/utils/config/config_loader.py +163 -0
- wl_cli/utils/config/core.py +862 -0
- wl_cli/utils/config/defaults.py +142 -0
- wl_cli/utils/config/env_exporter.py +86 -0
- wl_cli/utils/config/env_parser.py +108 -0
- wl_cli/utils/config/validation.py +280 -0
- wl_cli/utils/error_handler.py +165 -0
- wl_cli/utils/file_copier.py +56 -0
- wl_cli/utils/file_operations.py +506 -0
- wl_cli/utils/language_utils.py +122 -0
- wl_cli/utils/lazy_import.py +240 -0
- wl_cli/utils/log_levels.py +35 -0
- wl_cli/utils/log_rotators.py +74 -0
- wl_cli/utils/logging.py +458 -0
- wl_cli/utils/output_context.py +142 -0
- wl_cli/utils/performance/__init__.py +1 -0
- wl_cli/utils/performance/decorators.py +111 -0
- wl_cli/utils/performance/exporter.py +38 -0
- wl_cli/utils/performance/models.py +16 -0
- wl_cli/utils/performance/monitor.py +161 -0
- wl_cli/utils/performance_monitor.py +32 -0
- wl_cli/utils/platform_adapter.py +131 -0
- wl_cli/utils/pre_commit.py +266 -0
- wl_cli/utils/pre_commit_config.py +72 -0
- wl_cli/utils/root.py +521 -0
- wl_cli/utils/root_fallback.py +256 -0
- wl_cli/utils/run_evidence.py +236 -0
- wl_cli/utils/structured_logger.py +18 -0
- wl_cli/utils/structured_logging/__init__.py +19 -0
- wl_cli/utils/structured_logging/config.py +337 -0
- wl_cli/utils/structured_logging/core.py +177 -0
- wl_cli/utils/structured_logging/env.py +56 -0
- wl_cli/utils/structured_logging/filtering.py +75 -0
- wl_cli/utils/structured_logging/filters.py +55 -0
- wl_cli/utils/structured_logging/formatters.py +251 -0
- wl_cli/utils/structured_logging/handlers.py +308 -0
- wl_cli/utils/structured_logging/logger.py +354 -0
- wl_cli/utils/subprocess.py +71 -0
- wl_cli/utils/subprocess_utils.py +260 -0
- wl_cli/utils/test_utils/__init__.py +5 -0
- wl_cli/utils/test_utils/test_filter.py +36 -0
- wl_cli/utils/uv_run.py +79 -0
- wl_cli/utils/uv_tool.py +117 -0
- wl_cli/utils/uv_tree.py +71 -0
- wl_cli/utils/uv_workspace.py +174 -0
- wl_cli/utils/version/__init__.py +15 -0
- wl_cli/utils/version/pypi_version_checker.py +95 -0
- wl_cli/utils/version/version_comparator.py +133 -0
- wl_cli/utils/version/version_detectors.py +312 -0
- wl_cli/utils/version/version_service.py +131 -0
- wl_cli/utils/version/version_updater.py +198 -0
- wl_cli/utils/wl_dir_updater.py +1440 -0
- wl_cli/utils/workspace_detector/__init__.py +28 -0
- wl_cli/utils/workspace_detector/core.py +161 -0
- wl_cli/utils/workspace_detector/detection_strategies.py +107 -0
- wl_cli/utils/workspace_detector/exceptions.py +5 -0
- wl_cli/utils/workspace_detector/types.py +17 -0
- wl_cli/utils/workspace_detector/venv_resolver.py +84 -0
- wl_cli/vendors/config/.codespellrc +2 -0
- wl_cli/vendors/config/dependencies.toml +10 -0
- wl_cli/vendors/config/mypy.ini +62 -0
- wl_cli/vendors/config/pyproject_defaults.toml +28 -0
- wl_cli/vendors/config/template_config.toml +24 -0
- wl_cli/vendors/config/tool_configs.toml +76 -0
- wl_cli/vendors/git/.gitignore +122 -0
- wl_cli/vendors/git/.pre-commit-config.yaml +37 -0
- wl_cli/vendors/hooks/applypatch-msg.sample +15 -0
- wl_cli/vendors/hooks/commit-msg.sample +24 -0
- wl_cli/vendors/hooks/fsmonitor-watchman.sample +174 -0
- wl_cli/vendors/hooks/post-update.sample +8 -0
- wl_cli/vendors/hooks/pre-applypatch.sample +14 -0
- wl_cli/vendors/hooks/pre-commit +45 -0
- wl_cli/vendors/hooks/pre-commit.legacy +31 -0
- wl_cli/vendors/hooks/pre-commit.sample +49 -0
- wl_cli/vendors/hooks/pre-merge-commit.sample +13 -0
- wl_cli/vendors/hooks/pre-push.sample +60 -0
- wl_cli/vendors/hooks/pre-rebase.sample +169 -0
- wl_cli/vendors/hooks/pre-receive.sample +24 -0
- wl_cli/vendors/hooks/prepare-commit-msg.sample +42 -0
- wl_cli/vendors/hooks/push-to-checkout.sample +78 -0
- wl_cli/vendors/hooks/sendemail-validate.sample +77 -0
- wl_cli/vendors/hooks/unix/applypatch-msg.sample +15 -0
- wl_cli/vendors/hooks/unix/check_lockfile.py +58 -0
- wl_cli/vendors/hooks/unix/check_lockfile.sh +36 -0
- wl_cli/vendors/hooks/unix/commit-msg.sample +24 -0
- wl_cli/vendors/hooks/unix/fsmonitor-watchman.sample +174 -0
- wl_cli/vendors/hooks/unix/post-update.sample +8 -0
- wl_cli/vendors/hooks/unix/pre-applypatch.sample +14 -0
- wl_cli/vendors/hooks/unix/pre-commit +190 -0
- wl_cli/vendors/hooks/unix/pre-commit.legacy +31 -0
- wl_cli/vendors/hooks/unix/pre-commit.py +81 -0
- wl_cli/vendors/hooks/unix/pre-commit.sample +49 -0
- wl_cli/vendors/hooks/unix/pre-merge-commit.sample +13 -0
- wl_cli/vendors/hooks/unix/pre-push +417 -0
- wl_cli/vendors/hooks/unix/pre-push.sample +53 -0
- wl_cli/vendors/hooks/unix/pre-rebase.sample +169 -0
- wl_cli/vendors/hooks/unix/pre-receive.sample +24 -0
- wl_cli/vendors/hooks/unix/prepare-commit-msg.sample +42 -0
- wl_cli/vendors/hooks/update.sample +128 -0
- wl_cli/vendors/hooks/win/work.bat +63 -0
- wl_cli/vendors/project/.gitignore +90 -0
- wl_cli/vendors/project/.python-version +1 -0
- wl_cli/vendors/project/LICENSE +21 -0
- wl_cli/vendors/project/README.md +0 -0
- wl_cli/vendors/project/pyproject.toml +27 -0
- wl_cli/vendors/project/pyproject_no_workspace.toml +16 -0
- wl_cli/vendors/project/pyproject_workspace.toml +14 -0
- wl_cli/vendors/readme/README.md +120 -0
- wl_cli/vendors/rust/Cargo.toml +14 -0
- wl_cli/vendors/rust/lib/__init__.py +3 -0
- wl_cli/vendors/rust/lib/rust_utils.py +31 -0
- wl_cli/vendors/rust/src/lib.rs +13 -0
- wl_cli/vendors/rust/src/main.rs +3 -0
- wl_cli/vendors/rust/tests/test_rust_fallback.py +40 -0
- wl_cli/vendors/sop_doc/git-dev-sop.md +220 -0
- wl_cli/vendors/sop_doc/industrial-standard-sop.md +145 -0
- wl_cli/vendors/sop_doc/python-sop.md +342 -0
- wl_cli/vendors/sop_doc/rust-readme.md +219 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Build Artifacts Cleaner
|
|
3
|
+
构建产物清理器
|
|
4
|
+
|
|
5
|
+
This module handles cleaning of build artifacts, cache directories, logs, and virtual environments.
|
|
6
|
+
此模块处理构建产物、缓存目录、日志和虚拟环境的清理。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from wl_cli.commands.clean.core import remove_directories, remove_files
|
|
10
|
+
from wl_cli.commands.clean.python import (
|
|
11
|
+
remove_egg_info_dirs,
|
|
12
|
+
remove_log_files,
|
|
13
|
+
remove_pycache_dirs,
|
|
14
|
+
)
|
|
15
|
+
from wl_cli.commands.clean.rust import remove_rust_analyzer_dirs
|
|
16
|
+
from wl_cli.commands.clean.venv import (
|
|
17
|
+
remove_auto_activation_scripts,
|
|
18
|
+
remove_virtual_environments,
|
|
19
|
+
)
|
|
20
|
+
from wl_cli.utils.logging import log_info_pair
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def clean_build_artifacts(dry_run: bool = False, config: str | None = None) -> None:
|
|
24
|
+
"""Clean build artifacts and temporary files
|
|
25
|
+
清理构建产物和临时文件
|
|
26
|
+
"""
|
|
27
|
+
log_info_pair(
|
|
28
|
+
"Cleaning build artifacts and temporary files...",
|
|
29
|
+
"正在清理构建产物和临时文件...",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Remove build directories
|
|
33
|
+
build_dirs = [
|
|
34
|
+
# Build outputs
|
|
35
|
+
"build",
|
|
36
|
+
"dist",
|
|
37
|
+
"results",
|
|
38
|
+
# Cache directories
|
|
39
|
+
".mypy_cache",
|
|
40
|
+
".pytest_cache",
|
|
41
|
+
".ruff_cache",
|
|
42
|
+
".cache",
|
|
43
|
+
# IDE and editor directories
|
|
44
|
+
".vscode",
|
|
45
|
+
".idea",
|
|
46
|
+
".vs",
|
|
47
|
+
# Log and temporary directories
|
|
48
|
+
"logs",
|
|
49
|
+
"todos",
|
|
50
|
+
"tmp",
|
|
51
|
+
"temp",
|
|
52
|
+
]
|
|
53
|
+
remove_directories(build_dirs, dry_run=dry_run)
|
|
54
|
+
|
|
55
|
+
# Remove specific files
|
|
56
|
+
files_to_remove = [
|
|
57
|
+
# Coverage files — pytest-cov 的 `Central` 控制器总以 data_suffix 写
|
|
58
|
+
# `.coverage.<host>.<pid>.<rand>`,精确匹配 ".coverage" 删不掉这些残片,
|
|
59
|
+
# 需要一并按通配清掉。
|
|
60
|
+
".coverage",
|
|
61
|
+
".coverage.*",
|
|
62
|
+
"coverage.xml",
|
|
63
|
+
# IDE and editor files
|
|
64
|
+
".DS_Store",
|
|
65
|
+
"Thumbs.db",
|
|
66
|
+
# Python specific
|
|
67
|
+
"*.pyc",
|
|
68
|
+
"*.pyo",
|
|
69
|
+
"*.pyd",
|
|
70
|
+
# Build files
|
|
71
|
+
"MANIFEST",
|
|
72
|
+
"*.egg-info",
|
|
73
|
+
# Lock files
|
|
74
|
+
"Pipfile.lock",
|
|
75
|
+
"poetry.lock",
|
|
76
|
+
"requirements.txt.lock",
|
|
77
|
+
]
|
|
78
|
+
remove_files(files_to_remove, dry_run=dry_run)
|
|
79
|
+
|
|
80
|
+
# Remove log files
|
|
81
|
+
remove_log_files(dry_run=dry_run)
|
|
82
|
+
|
|
83
|
+
# Remove pycache directories only in project directory
|
|
84
|
+
remove_pycache_dirs(dry_run=dry_run)
|
|
85
|
+
|
|
86
|
+
# Remove egg-info directories
|
|
87
|
+
remove_egg_info_dirs(dry_run=dry_run)
|
|
88
|
+
|
|
89
|
+
# Remove rust-analyzer directories
|
|
90
|
+
remove_rust_analyzer_dirs(dry_run=dry_run)
|
|
91
|
+
|
|
92
|
+
log_info_pair(
|
|
93
|
+
"Build artifacts and temporary files cleaning completed.",
|
|
94
|
+
"构建产物和临时文件清理完成。",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def clean_venv_artifacts(dry_run: bool = False, config: str | None = None) -> None:
|
|
99
|
+
"""
|
|
100
|
+
Clean virtual environment artifacts
|
|
101
|
+
清理虚拟环境产物
|
|
102
|
+
"""
|
|
103
|
+
log_info_pair("Cleaning virtual environment...", "正在清理虚拟环境...")
|
|
104
|
+
|
|
105
|
+
# Remove virtual environments
|
|
106
|
+
remove_virtual_environments(dry_run=dry_run)
|
|
107
|
+
|
|
108
|
+
# Remove auto-activation scripts
|
|
109
|
+
remove_auto_activation_scripts(dry_run=dry_run)
|
|
110
|
+
|
|
111
|
+
log_info_pair("Virtual environment cleaning completed.", "虚拟环境清理完成。")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def clean_cache_artifacts(dry_run: bool = False, config: str | None = None) -> None:
|
|
115
|
+
"""
|
|
116
|
+
Clean cache directories
|
|
117
|
+
清理缓存目录
|
|
118
|
+
"""
|
|
119
|
+
log_info_pair("Cleaning cache directories...", "正在清理缓存目录...")
|
|
120
|
+
|
|
121
|
+
# Remove cache directories
|
|
122
|
+
cache_dirs = [
|
|
123
|
+
".mypy_cache",
|
|
124
|
+
".pytest_cache",
|
|
125
|
+
".ruff_cache",
|
|
126
|
+
]
|
|
127
|
+
remove_directories(cache_dirs, dry_run=dry_run)
|
|
128
|
+
|
|
129
|
+
# Remove pycache directories
|
|
130
|
+
remove_pycache_dirs(dry_run=dry_run)
|
|
131
|
+
|
|
132
|
+
log_info_pair("Cache directories cleaning completed.", "缓存目录清理完成。")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def clean_logs_artifacts(dry_run: bool = False, config: str | None = None) -> None:
|
|
136
|
+
"""
|
|
137
|
+
Clean log files and directories
|
|
138
|
+
清理日志文件和目录
|
|
139
|
+
"""
|
|
140
|
+
log_info_pair("Cleaning log files and directories...", "正在清理日志文件和目录...")
|
|
141
|
+
|
|
142
|
+
# Remove log directories
|
|
143
|
+
log_dirs = ["logs"]
|
|
144
|
+
remove_directories(log_dirs, dry_run=dry_run)
|
|
145
|
+
|
|
146
|
+
# Remove log files
|
|
147
|
+
remove_log_files(dry_run=dry_run)
|
|
148
|
+
|
|
149
|
+
log_info_pair(
|
|
150
|
+
"Log files and directories cleaning completed.", "日志文件和目录清理完成。"
|
|
151
|
+
)
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command to clean project build artifacts and dead code.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
from wl_cli.commands import Command, validate_command_args
|
|
10
|
+
from wl_cli.utils.logging import log_info_pair
|
|
11
|
+
|
|
12
|
+
from .clean_utils import (
|
|
13
|
+
clean_all_artifacts,
|
|
14
|
+
clean_build_artifacts,
|
|
15
|
+
clean_cache_artifacts,
|
|
16
|
+
clean_lfs_artifacts,
|
|
17
|
+
clean_logs_artifacts,
|
|
18
|
+
clean_rust_artifacts,
|
|
19
|
+
clean_venv_artifacts,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CleanCommand(Command):
|
|
24
|
+
"""Command to clean project build artifacts and dead code"""
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def name(self) -> str:
|
|
28
|
+
return "clean"
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def help(self) -> str:
|
|
32
|
+
return "Clean project artifacts and dead code"
|
|
33
|
+
|
|
34
|
+
def _get_cleaning_function(self, target: str):
|
|
35
|
+
"""Get the appropriate cleaning function based on target."""
|
|
36
|
+
cleaning_functions = {
|
|
37
|
+
"all": clean_all_artifacts,
|
|
38
|
+
"rust": clean_rust_artifacts,
|
|
39
|
+
"lfs": clean_lfs_artifacts,
|
|
40
|
+
"venv": clean_venv_artifacts,
|
|
41
|
+
"cache": clean_cache_artifacts,
|
|
42
|
+
"logs": clean_logs_artifacts,
|
|
43
|
+
"build": clean_build_artifacts,
|
|
44
|
+
}
|
|
45
|
+
return cleaning_functions.get(target, clean_build_artifacts)
|
|
46
|
+
|
|
47
|
+
def _get_messages(self, target: str, message_type: str):
|
|
48
|
+
"""Get messages for different targets based on message type."""
|
|
49
|
+
# Define all message types as a dictionary
|
|
50
|
+
all_messages = {
|
|
51
|
+
"start": {
|
|
52
|
+
"all": (
|
|
53
|
+
"Cleaning all project artifacts including virtual environment...",
|
|
54
|
+
"正在清理所有项目产物,包括虚拟环境...",
|
|
55
|
+
),
|
|
56
|
+
"rust": ("Cleaning Rust build artifacts...", "正在清理Rust构建产物..."),
|
|
57
|
+
"lfs": ("Cleaning Git LFS deployment...", "正在清理Git LFS部署..."),
|
|
58
|
+
"venv": ("Cleaning virtual environment...", "正在清理虚拟环境..."),
|
|
59
|
+
"cache": ("Cleaning cache directories...", "正在清理缓存目录..."),
|
|
60
|
+
"logs": ("Cleaning log files...", "正在清理日志文件..."),
|
|
61
|
+
"build": (
|
|
62
|
+
"Cleaning project build artifacts...",
|
|
63
|
+
"正在清理项目构建产物...",
|
|
64
|
+
),
|
|
65
|
+
},
|
|
66
|
+
"success": {
|
|
67
|
+
"all": (
|
|
68
|
+
"Complete project cleaning completed successfully!",
|
|
69
|
+
"完整项目清理成功完成!",
|
|
70
|
+
),
|
|
71
|
+
"rust": ("Rust cleaning completed successfully!", "Rust清理成功完成!"),
|
|
72
|
+
"lfs": (
|
|
73
|
+
"Git LFS cleaning completed successfully!",
|
|
74
|
+
"Git LFS清理成功完成!",
|
|
75
|
+
),
|
|
76
|
+
"venv": (
|
|
77
|
+
"Virtual environment cleaning completed successfully!",
|
|
78
|
+
"虚拟环境清理成功完成!",
|
|
79
|
+
),
|
|
80
|
+
"cache": (
|
|
81
|
+
"Cache directories cleaning completed successfully!",
|
|
82
|
+
"缓存目录清理成功完成!",
|
|
83
|
+
),
|
|
84
|
+
"logs": (
|
|
85
|
+
"Log files cleaning completed successfully!",
|
|
86
|
+
"日志文件清理成功完成!",
|
|
87
|
+
),
|
|
88
|
+
"build": (
|
|
89
|
+
"Project cleaning completed successfully!",
|
|
90
|
+
"项目清理成功完成!",
|
|
91
|
+
),
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Get specified message type dictionary
|
|
96
|
+
message_dict = all_messages.get(message_type, {})
|
|
97
|
+
|
|
98
|
+
# Get default message
|
|
99
|
+
default_message = message_dict.get("build", ("", ""))
|
|
100
|
+
|
|
101
|
+
# Return target's message, or default if not found
|
|
102
|
+
return message_dict.get(target, default_message)
|
|
103
|
+
|
|
104
|
+
def _execute_clean_target(
|
|
105
|
+
self,
|
|
106
|
+
target: str,
|
|
107
|
+
dry_run: bool = False,
|
|
108
|
+
config: str | None = None,
|
|
109
|
+
parallel: bool = False,
|
|
110
|
+
):
|
|
111
|
+
"""Execute cleaning for a specific target."""
|
|
112
|
+
# Use simple logging instead of structured logging for user-facing messages
|
|
113
|
+
start_msg_en, start_msg_zh = self._get_messages(target, "start")
|
|
114
|
+
log_info_pair(start_msg_en, start_msg_zh)
|
|
115
|
+
|
|
116
|
+
# Log dry run mode
|
|
117
|
+
if dry_run:
|
|
118
|
+
log_info_pair(
|
|
119
|
+
"Dry run mode: No files will be deleted.",
|
|
120
|
+
"Dry run模式:不会删除任何文件。",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Get and execute the appropriate cleaning function
|
|
124
|
+
cleaning_function = self._get_cleaning_function(target)
|
|
125
|
+
if target == "all":
|
|
126
|
+
cleaning_function(dry_run=dry_run, config=config, parallel=parallel)
|
|
127
|
+
else:
|
|
128
|
+
cleaning_function(dry_run=dry_run, config=config)
|
|
129
|
+
|
|
130
|
+
# Log success message
|
|
131
|
+
success_msg_en, success_msg_zh = self._get_messages(target, "success")
|
|
132
|
+
log_info_pair(success_msg_en, success_msg_zh)
|
|
133
|
+
|
|
134
|
+
def _execute_dead_code(
|
|
135
|
+
self,
|
|
136
|
+
dry_run: bool = False,
|
|
137
|
+
scan_only: bool = False,
|
|
138
|
+
json_output: bool = False,
|
|
139
|
+
) -> int:
|
|
140
|
+
"""Execute dead code detection and cleaning."""
|
|
141
|
+
from .dead_code.dead_code_command import DeadCodeCommand
|
|
142
|
+
|
|
143
|
+
command = DeadCodeCommand()
|
|
144
|
+
return command.run(
|
|
145
|
+
dry_run=dry_run or scan_only,
|
|
146
|
+
json=json_output,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
@validate_command_args()
|
|
150
|
+
def execute(
|
|
151
|
+
self,
|
|
152
|
+
clean_action: str | None = None,
|
|
153
|
+
target: str | None = None,
|
|
154
|
+
dry_run: bool = False,
|
|
155
|
+
config: str | None = None,
|
|
156
|
+
parallel: bool = False,
|
|
157
|
+
scan_only: bool = False,
|
|
158
|
+
json: bool = False,
|
|
159
|
+
**kwargs,
|
|
160
|
+
) -> int:
|
|
161
|
+
"""
|
|
162
|
+
Clean project artifacts and dead code.
|
|
163
|
+
清理项目产物和死代码。
|
|
164
|
+
|
|
165
|
+
Returns the exit code; only the Click wrapper turns it into a
|
|
166
|
+
``SystemExit`` (#166). ``dead-code`` passes the dead-code command's own
|
|
167
|
+
0/1 through; every other target reports 0 on success.
|
|
168
|
+
"""
|
|
169
|
+
try:
|
|
170
|
+
if clean_action == "dead-code":
|
|
171
|
+
# Execute dead code command
|
|
172
|
+
return self._execute_dead_code(
|
|
173
|
+
dry_run=dry_run,
|
|
174
|
+
scan_only=scan_only,
|
|
175
|
+
json_output=json,
|
|
176
|
+
)
|
|
177
|
+
elif clean_action in [
|
|
178
|
+
"build",
|
|
179
|
+
"all",
|
|
180
|
+
"rust",
|
|
181
|
+
"lfs",
|
|
182
|
+
"venv",
|
|
183
|
+
"cache",
|
|
184
|
+
"logs",
|
|
185
|
+
]:
|
|
186
|
+
# Execute specific clean action
|
|
187
|
+
self._execute_clean_target(
|
|
188
|
+
target=clean_action,
|
|
189
|
+
dry_run=dry_run,
|
|
190
|
+
config=config,
|
|
191
|
+
parallel=parallel,
|
|
192
|
+
)
|
|
193
|
+
elif target is not None:
|
|
194
|
+
# Backward compatibility: use old positional argument
|
|
195
|
+
self._execute_clean_target(
|
|
196
|
+
target=target,
|
|
197
|
+
dry_run=dry_run,
|
|
198
|
+
config=config,
|
|
199
|
+
parallel=parallel,
|
|
200
|
+
)
|
|
201
|
+
else:
|
|
202
|
+
# Default to build
|
|
203
|
+
self._execute_clean_target(
|
|
204
|
+
target="build",
|
|
205
|
+
dry_run=dry_run,
|
|
206
|
+
config=config,
|
|
207
|
+
parallel=parallel,
|
|
208
|
+
)
|
|
209
|
+
# Artifact targets (and the legacy target branch) report success;
|
|
210
|
+
# they do not forward a deeper command's status (#166 patch 4).
|
|
211
|
+
return 0
|
|
212
|
+
except Exception as e:
|
|
213
|
+
log_info_pair(f"Error cleaning project: {e}", f"错误:清理项目失败: {e}")
|
|
214
|
+
return 1
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@click.command(name="clean")
|
|
218
|
+
@click.argument(
|
|
219
|
+
"target_or_subcommand",
|
|
220
|
+
default=None,
|
|
221
|
+
required=False,
|
|
222
|
+
)
|
|
223
|
+
@click.option(
|
|
224
|
+
"--dry-run",
|
|
225
|
+
is_flag=True,
|
|
226
|
+
help="Preview files to be deleted without actually deleting them / Only scan without fixing",
|
|
227
|
+
)
|
|
228
|
+
@click.option(
|
|
229
|
+
"--scan-only",
|
|
230
|
+
is_flag=True,
|
|
231
|
+
help="Same as --dry-run (for dead-code)",
|
|
232
|
+
)
|
|
233
|
+
@click.option(
|
|
234
|
+
"--json",
|
|
235
|
+
is_flag=True,
|
|
236
|
+
help="Output JSON format (for dead-code)",
|
|
237
|
+
)
|
|
238
|
+
@click.option(
|
|
239
|
+
"--config",
|
|
240
|
+
type=str,
|
|
241
|
+
help="Path to custom cleaning configuration file",
|
|
242
|
+
default=None,
|
|
243
|
+
)
|
|
244
|
+
@click.option(
|
|
245
|
+
"--parallel",
|
|
246
|
+
is_flag=True,
|
|
247
|
+
help="Enable parallel execution for clean all (experimental)",
|
|
248
|
+
)
|
|
249
|
+
def clean_command(
|
|
250
|
+
target_or_subcommand: str | None,
|
|
251
|
+
dry_run: bool,
|
|
252
|
+
scan_only: bool,
|
|
253
|
+
json: bool,
|
|
254
|
+
config: str | None,
|
|
255
|
+
parallel: bool,
|
|
256
|
+
) -> None:
|
|
257
|
+
"""Clean project artifacts and dead code.
|
|
258
|
+
|
|
259
|
+
Targets: build, all, rust, lfs, venv, cache, logs, dead-code
|
|
260
|
+
"""
|
|
261
|
+
cmd = CleanCommand()
|
|
262
|
+
|
|
263
|
+
# Check if it's a subcommand
|
|
264
|
+
if target_or_subcommand in [
|
|
265
|
+
"build",
|
|
266
|
+
"all",
|
|
267
|
+
"rust",
|
|
268
|
+
"lfs",
|
|
269
|
+
"venv",
|
|
270
|
+
"cache",
|
|
271
|
+
"logs",
|
|
272
|
+
"dead-code",
|
|
273
|
+
]:
|
|
274
|
+
# Use as clean_action
|
|
275
|
+
exit_code = cmd.execute(
|
|
276
|
+
clean_action=target_or_subcommand,
|
|
277
|
+
dry_run=dry_run,
|
|
278
|
+
scan_only=scan_only,
|
|
279
|
+
json=json,
|
|
280
|
+
config=config,
|
|
281
|
+
parallel=parallel,
|
|
282
|
+
)
|
|
283
|
+
else:
|
|
284
|
+
# Use as target (legacy behavior)
|
|
285
|
+
exit_code = cmd.execute(
|
|
286
|
+
target=target_or_subcommand,
|
|
287
|
+
dry_run=dry_run,
|
|
288
|
+
config=config,
|
|
289
|
+
parallel=parallel,
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
# The implementation returns a code; only this wrapper exits (#166).
|
|
293
|
+
if exit_code:
|
|
294
|
+
sys.exit(exit_code)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Clean Utils Module
|
|
3
|
+
清理工具模块
|
|
4
|
+
|
|
5
|
+
This module now serves as an entry point for the modularized cleaning functionality.
|
|
6
|
+
Main functions are delegated to specialized modules for better organization.
|
|
7
|
+
此模块现在作为模块化清理功能的入口点。
|
|
8
|
+
主要功能委托给专门的模块以获得更好的组织结构。
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
# Import all functions from the modularized components
|
|
12
|
+
# Re-export functions for clean.py - these are used by other modules
|
|
13
|
+
|
|
14
|
+
from wl_cli.commands.clean.build import (
|
|
15
|
+
clean_build_artifacts,
|
|
16
|
+
clean_cache_artifacts,
|
|
17
|
+
clean_logs_artifacts,
|
|
18
|
+
clean_venv_artifacts,
|
|
19
|
+
)
|
|
20
|
+
from wl_cli.commands.clean.core import remove_directories, remove_files
|
|
21
|
+
from wl_cli.commands.clean.lfs import clean_lfs_artifacts
|
|
22
|
+
from wl_cli.commands.clean.python import (
|
|
23
|
+
remove_egg_info_dirs,
|
|
24
|
+
remove_log_files,
|
|
25
|
+
remove_pycache_dirs,
|
|
26
|
+
)
|
|
27
|
+
from wl_cli.commands.clean.rust import (
|
|
28
|
+
clean_rust_artifacts as _clean_rust_artifacts,
|
|
29
|
+
)
|
|
30
|
+
from wl_cli.commands.clean.venv import (
|
|
31
|
+
remove_auto_activation_scripts,
|
|
32
|
+
remove_uv_lock,
|
|
33
|
+
remove_virtual_environments,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Keep backward compatibility with tests that import private functions
|
|
37
|
+
# 保持与导入私有函数的测试的向后兼容性
|
|
38
|
+
_remove_directories = remove_directories
|
|
39
|
+
_remove_files = remove_files
|
|
40
|
+
_remove_log_files = remove_log_files
|
|
41
|
+
_remove_pycache_dirs = remove_pycache_dirs
|
|
42
|
+
_remove_egg_info_dirs = remove_egg_info_dirs
|
|
43
|
+
_remove_virtual_environments = remove_virtual_environments
|
|
44
|
+
_remove_auto_activation_scripts = remove_auto_activation_scripts
|
|
45
|
+
_remove_uv_lock = remove_uv_lock
|
|
46
|
+
|
|
47
|
+
#: Public re-export surface consumed by ``clean/clean.py`` (ruff: F401).
|
|
48
|
+
__all__ = [
|
|
49
|
+
"clean_all_artifacts",
|
|
50
|
+
"clean_build_artifacts",
|
|
51
|
+
"clean_cache_artifacts",
|
|
52
|
+
"clean_lfs_artifacts",
|
|
53
|
+
"clean_logs_artifacts",
|
|
54
|
+
"clean_rust_artifacts",
|
|
55
|
+
"clean_venv_artifacts",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def clean_all_artifacts(
|
|
60
|
+
dry_run: bool = False, config: str | None = None, parallel: bool = False
|
|
61
|
+
) -> None:
|
|
62
|
+
"""
|
|
63
|
+
Clean all artifacts including virtual environments
|
|
64
|
+
清理所有产物,包括虚拟环境
|
|
65
|
+
"""
|
|
66
|
+
clean_build_artifacts(dry_run=dry_run, config=config)
|
|
67
|
+
clean_venv_artifacts(dry_run=dry_run, config=config)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def clean_rust_artifacts(dry_run: bool = False, config: str | None = None) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Clean Rust build artifacts
|
|
73
|
+
清理Rust构建产物
|
|
74
|
+
"""
|
|
75
|
+
# Pass dry_run parameter to the actual implementation
|
|
76
|
+
# Note: config is reserved for future use
|
|
77
|
+
_clean_rust_artifacts(dry_run=dry_run)
|