From 06248fa6f18e9be230f7563c1a1883fed07e3275 Mon Sep 17 00:00:00 2001 From: Willem Jiang Date: Sat, 14 Feb 2026 16:24:44 +0800 Subject: [PATCH] chore: Polishing the license headers work (#860) * feat(tool): Adding license header check and apply tool * Update docs/LICENSE_HEADERS.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update scripts/license_header.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Polishing the license headers work --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 2 +- docs/LICENSE_HEADERS.md | 21 ++++++++++----------- scripts/license_header.py | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 3780905..50bfb00 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help lint format install-dev serve test coverage langgraph-dev lint-frontend add-license add-license-ts add-license-all check-license check-license-ts check-license-all +.PHONY: help lint format install-dev serve test coverage langgraph-dev lint-frontend add-license-all check-license-all help: ## Show this help message @echo "Deer Flow - Available Make Targets:" diff --git a/docs/LICENSE_HEADERS.md b/docs/LICENSE_HEADERS.md index f104799..942a9b1 100644 --- a/docs/LICENSE_HEADERS.md +++ b/docs/LICENSE_HEADERS.md @@ -102,7 +102,7 @@ The license header check is integrated into the pre-commit hook. Before allowing 1. Run linting (`make lint`) 2. Run formatting (`make format`) -This ensures all merged code has proper license headers for both Python and TypeScript fileill be blocked. Run `make add-license` to fix. +This ensures all merged code has proper license headers for both Python and TypeScript fileill be blocked. Run `make add-license-all` to fix. ## CI/CD Integration @@ -110,8 +110,7 @@ For continuous integration, add the license check to your workflow: ```bash # In your CI script or GitHub Actions -ma`.next` (Next.js build directory) -- ke check-license +- make check-license `.next` (Next.js build directory) ``` This ensures all merged code has proper license headers. @@ -142,7 +141,7 @@ LICENSE_HEADERS: Dict[str, str] = { } ``` -### Adding Mo-all: +### Adding Licenserce header to all files: @uv run python scripts/license_header.py src/ tests/ scripts/ web/src/ web/test 1. Add the extension to `FILE_TYPE_MAP` in `scripts/license_header.py` 2. Add the corresponding header format to `LICENSE_HEADERS` @@ -168,16 +167,16 @@ Checking license headers in all source files... ✅ All 289 source file(s) have license headers. ``` -### Example 2: Check Only TypeScript Files +### Example 2: Check Only Python and TypeScript Files ```bash -$ make check-license-ts -Checking license headers in TypeScript files... +$ make check-license-all +Checking license headers in Python and TypeScript files... ❌ 3 file(s) missing license header: - web/src/components/new-component.tsx - web/src/core/api/new-api.ts - web/tests/new-test.test.ts -Run 'make add-license-ts' to add headers. +Run 'make add-license-all' to add headers. ``` ### Example 3: Add Headers to New Module @@ -196,21 +195,21 @@ Header already present: web/src/components/editor/index.tsx ✅ All 24 sourceooks for exact matches (ignoring leading/trailing whitespace) ### "Pre-commit hook blocks my commit" -- Run `make add-license` to add headers to all files +- Run `make add-license-all` to add headers to all files - Or disable the check temporarily by editing the `pre-commit` file ## Examples ### Example 1: Check All Files ```bash -$ make check-license +$ make check-license-all Checking license headers in Python files... ✅ All 156 Python file(s) have license headers. ``` ### Example 2: Add Headers to New Module ```bash -$ make add-license +$ make add-license-all Adding license headers to Python files... ✅ Added license header to 11 file(s). ``` diff --git a/scripts/license_header.py b/scripts/license_header.py index 7d53bac..170c08f 100644 --- a/scripts/license_header.py +++ b/scripts/license_header.py @@ -209,7 +209,7 @@ def main(): print(f"\n❌ {len(missing_header)} file(s) missing license header:") for path in missing_header: print(f" - {path}") - print("\nRun 'make add-license' to add headers.") + print("\nRun 'make add-license-all' to add headers.") return 1 else: print(f"✅ All {len(all_files)} source file(s) have license headers.")