📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -30,7 +30,7 @@ def detect_project_type(project_path: Path) -> dict:
|
||||
"type": "unknown",
|
||||
"linters": []
|
||||
}
|
||||
|
||||
|
||||
# Node.js project
|
||||
package_json = project_path / "package.json"
|
||||
if package_json.exists():
|
||||
@@ -39,31 +39,31 @@ def detect_project_type(project_path: Path) -> dict:
|
||||
pkg = json.loads(package_json.read_text(encoding='utf-8'))
|
||||
scripts = pkg.get("scripts", {})
|
||||
deps = {**pkg.get("dependencies", {}), **pkg.get("devDependencies", {})}
|
||||
|
||||
|
||||
# Check for lint script
|
||||
if "lint" in scripts:
|
||||
result["linters"].append({"name": "npm lint", "cmd": ["npm", "run", "lint"]})
|
||||
elif "eslint" in deps:
|
||||
result["linters"].append({"name": "eslint", "cmd": ["npx", "eslint", "."]})
|
||||
|
||||
|
||||
# Check for TypeScript
|
||||
if "typescript" in deps or (project_path / "tsconfig.json").exists():
|
||||
result["linters"].append({"name": "tsc", "cmd": ["npx", "tsc", "--noEmit"]})
|
||||
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# Python project
|
||||
if (project_path / "pyproject.toml").exists() or (project_path / "requirements.txt").exists():
|
||||
result["type"] = "python"
|
||||
|
||||
|
||||
# Check for ruff
|
||||
result["linters"].append({"name": "ruff", "cmd": ["ruff", "check", "."]})
|
||||
|
||||
|
||||
# Check for mypy
|
||||
if (project_path / "mypy.ini").exists() or (project_path / "pyproject.toml").exists():
|
||||
result["linters"].append({"name": "mypy", "cmd": ["mypy", "."]})
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ def run_linter(linter: dict, cwd: Path) -> dict:
|
||||
"output": "",
|
||||
"error": ""
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
linter["cmd"],
|
||||
@@ -86,36 +86,36 @@ def run_linter(linter: dict, cwd: Path) -> dict:
|
||||
errors='replace',
|
||||
timeout=120
|
||||
)
|
||||
|
||||
|
||||
result["output"] = proc.stdout[:2000] if proc.stdout else ""
|
||||
result["error"] = proc.stderr[:500] if proc.stderr else ""
|
||||
result["passed"] = proc.returncode == 0
|
||||
|
||||
|
||||
except FileNotFoundError:
|
||||
result["error"] = f"Command not found: {linter['cmd'][0]}"
|
||||
except subprocess.TimeoutExpired:
|
||||
result["error"] = "Timeout after 120s"
|
||||
except Exception as e:
|
||||
result["error"] = str(e)
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
project_path = Path(sys.argv[1] if len(sys.argv) > 1 else ".").resolve()
|
||||
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"[LINT RUNNER] Unified Linting")
|
||||
print(f"{'='*60}")
|
||||
print(f"Project: {project_path}")
|
||||
print(f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
|
||||
|
||||
# Detect project type
|
||||
project_info = detect_project_type(project_path)
|
||||
print(f"Type: {project_info['type']}")
|
||||
print(f"Linters: {len(project_info['linters'])}")
|
||||
print("-"*60)
|
||||
|
||||
|
||||
if not project_info["linters"]:
|
||||
print("No linters found for this project type.")
|
||||
output = {
|
||||
@@ -128,16 +128,16 @@ def main():
|
||||
}
|
||||
print(json.dumps(output, indent=2))
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Run each linter
|
||||
results = []
|
||||
all_passed = True
|
||||
|
||||
|
||||
for linter in project_info["linters"]:
|
||||
print(f"\nRunning: {linter['name']}...")
|
||||
result = run_linter(linter, project_path)
|
||||
results.append(result)
|
||||
|
||||
|
||||
if result["passed"]:
|
||||
print(f" [PASS] {linter['name']}")
|
||||
else:
|
||||
@@ -145,16 +145,16 @@ def main():
|
||||
if result["error"]:
|
||||
print(f" Error: {result['error'][:200]}")
|
||||
all_passed = False
|
||||
|
||||
|
||||
# Summary
|
||||
print("\n" + "="*60)
|
||||
print("SUMMARY")
|
||||
print("="*60)
|
||||
|
||||
|
||||
for r in results:
|
||||
icon = "[PASS]" if r["passed"] else "[FAIL]"
|
||||
print(f"{icon} {r['name']}")
|
||||
|
||||
|
||||
output = {
|
||||
"script": "lint_runner",
|
||||
"project": str(project_path),
|
||||
@@ -162,9 +162,9 @@ def main():
|
||||
"checks": results,
|
||||
"passed": all_passed
|
||||
}
|
||||
|
||||
|
||||
print("\n" + json.dumps(output, indent=2))
|
||||
|
||||
|
||||
sys.exit(0 if all_passed else 1)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user