From 42e38110add467b1491bb751ad758a3b5fa85357 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 14 May 2026 17:38:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=91=E5=B8=83=E5=89=8D=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20-=20CI=E3=80=81wizard=20=E7=A1=AE=E8=AE=A4=E9=A1=B5?= =?UTF-8?q?=E3=80=81=E6=96=87=E6=A1=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 GitHub Actions CI(Python 3.8/3.12) - CLI wizard 增加配置摘要和确认页 - README 添加 CI badge、Interactive wizard 小节、package name 说明 - 修复 gen_share_card.py 的 Pillow 提示信息 - 删除未使用的 _path_label 函数 --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ README.md | 16 +++++++++++++++ gen_share_card.py | 4 ++-- run.py | 24 ++++++++++++++++++---- 4 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..567fd9f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.8', '3.12' ] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build Pillow>=8.0 + + - name: Compile check + run: | + python -m py_compile run.py + python -m py_compile git_analytics.py + python -m py_compile generate_report.py + python -m py_compile gen_share_card.py + + - name: CLI help + run: python run.py --help + + - name: Run scan + run: python run.py --no-wizard --max-depth 0 --output-dir /tmp/git-analytics-ci --share-card + + - name: Build package + run: python -m build diff --git a/README.md b/README.md index 3f86376..a6772e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Git Analytics +[![CI](https://github.com/mark-618/git-analytics/actions/workflows/ci.yml/badge.svg)](https://github.com/mark-618/git-analytics/actions/workflows/ci.yml) + **扫描本地 Git 仓库,生成你的开发者人格画像和代码习惯体检报告。** 不只统计 commits 和 lines——它告诉你:你是什么类型的开发者,你的代码习惯健康吗。 @@ -10,6 +12,8 @@ pip install git-analytics-cli ``` +> **Package name vs command name**: PyPI package name is `git-analytics-cli`, CLI command is `git-analytics`. + ## 30 秒快速开始 ```bash @@ -22,6 +26,18 @@ git-analytics ~/Projects 向导会引导你选择扫描目录、扫描深度、输出目录等,不需要记任何参数。 +## Interactive Wizard + +运行 `git-analytics` 不带参数时,会启动交互式向导: + +1. 选择扫描目录(当前目录、Desktop、Projects 等) +2. 选择扫描深度(3 或 5) +3. 输入输出目录 +4. 是否自动打开报告 +5. 是否生成分享卡片设计器 + +向导会显示配置摘要,确认后开始扫描。输入 `q` 可随时退出。 + ## CLI 用法 ```bash diff --git a/gen_share_card.py b/gen_share_card.py index baaa1ae..8f97629 100644 --- a/gen_share_card.py +++ b/gen_share_card.py @@ -13,8 +13,8 @@ try: from PIL import Image, ImageDraw, ImageFont except ImportError: - print("需要安装 Pillow 才能生成 PNG 分享卡片。") - print("运行: pip install git-analytics-cli[share-card]") + print("Pillow 是 git-analytics-cli 的必需依赖,请重新安装:") + print("pip install --upgrade git-analytics-cli") sys.exit(1) diff --git a/run.py b/run.py index 1745468..d847cca 100644 --- a/run.py +++ b/run.py @@ -66,10 +66,6 @@ def _confirm(title, default=True): return raw in {"y", "yes", "1", "true"} -def _path_label(path): - return os.path.abspath(os.path.expanduser(path)) - - def _existing_path(path): expanded = os.path.abspath(os.path.expanduser(path)) return expanded if os.path.isdir(expanded) else None @@ -140,6 +136,26 @@ def _run_wizard(args): args.output_dir = output_dir args.open = _confirm("生成后自动打开报告?", default=True) args.share_card = _confirm("同时生成分享卡片设计器?", default=True) + + # 显示配置摘要并确认 + print() + print("=" * 40) + print("📋 配置摘要") + print("=" * 40) + print("扫描目录:") + for item in scan_dirs: + print(f" - {os.path.abspath(os.path.expanduser(item))}") + print(f"扫描深度: {max_depth}") + print(f"输出目录: {os.path.abspath(os.path.expanduser(output_dir))}") + print(f"自动打开报告: {'是' if args.open else '否'}") + print(f"生成分享卡片: {'是' if args.share_card else '否'}") + print("=" * 40) + + confirm = input("[Enter] 开始,输入 q 退出: ").strip().lower() + if confirm in {"q", "quit", "exit"}: + print("已退出。") + sys.exit(0) + print() return args