mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
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>
This commit is contained in:
2
Makefile
2
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
|
help: ## Show this help message
|
||||||
@echo "Deer Flow - Available Make Targets:"
|
@echo "Deer Flow - Available Make Targets:"
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ The license header check is integrated into the pre-commit hook. Before allowing
|
|||||||
1. Run linting (`make lint`)
|
1. Run linting (`make lint`)
|
||||||
2. Run formatting (`make format`)
|
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
|
## CI/CD Integration
|
||||||
|
|
||||||
@@ -110,8 +110,7 @@ For continuous integration, add the license check to your workflow:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# In your CI script or GitHub Actions
|
# In your CI script or GitHub Actions
|
||||||
ma`.next` (Next.js build directory)
|
- make check-license `.next` (Next.js build directory)
|
||||||
- ke check-license
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This ensures all merged code has proper license headers.
|
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
|
@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`
|
1. Add the extension to `FILE_TYPE_MAP` in `scripts/license_header.py`
|
||||||
2. Add the corresponding header format to `LICENSE_HEADERS`
|
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.
|
✅ All 289 source file(s) have license headers.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example 2: Check Only TypeScript Files
|
### Example 2: Check Only Python and TypeScript Files
|
||||||
```bash
|
```bash
|
||||||
$ make check-license-ts
|
$ make check-license-all
|
||||||
Checking license headers in TypeScript files...
|
Checking license headers in Python and TypeScript files...
|
||||||
❌ 3 file(s) missing license header:
|
❌ 3 file(s) missing license header:
|
||||||
- web/src/components/new-component.tsx
|
- web/src/components/new-component.tsx
|
||||||
- web/src/core/api/new-api.ts
|
- web/src/core/api/new-api.ts
|
||||||
- web/tests/new-test.test.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
|
### 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)
|
✅ All 24 sourceooks for exact matches (ignoring leading/trailing whitespace)
|
||||||
|
|
||||||
### "Pre-commit hook blocks my commit"
|
### "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
|
- Or disable the check temporarily by editing the `pre-commit` file
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Example 1: Check All Files
|
### Example 1: Check All Files
|
||||||
```bash
|
```bash
|
||||||
$ make check-license
|
$ make check-license-all
|
||||||
Checking license headers in Python files...
|
Checking license headers in Python files...
|
||||||
✅ All 156 Python file(s) have license headers.
|
✅ All 156 Python file(s) have license headers.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example 2: Add Headers to New Module
|
### Example 2: Add Headers to New Module
|
||||||
```bash
|
```bash
|
||||||
$ make add-license
|
$ make add-license-all
|
||||||
Adding license headers to Python files...
|
Adding license headers to Python files...
|
||||||
✅ Added license header to 11 file(s).
|
✅ Added license header to 11 file(s).
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ def main():
|
|||||||
print(f"\n❌ {len(missing_header)} file(s) missing license header:")
|
print(f"\n❌ {len(missing_header)} file(s) missing license header:")
|
||||||
for path in missing_header:
|
for path in missing_header:
|
||||||
print(f" - {path}")
|
print(f" - {path}")
|
||||||
print("\nRun 'make add-license' to add headers.")
|
print("\nRun 'make add-license-all' to add headers.")
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
print(f"✅ All {len(all_files)} source file(s) have license headers.")
|
print(f"✅ All {len(all_files)} source file(s) have license headers.")
|
||||||
|
|||||||
Reference in New Issue
Block a user