chub-guard-init 1.0.0__tar.gz
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.
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# chub-guard-init (pip)
|
|
2
|
+
|
|
3
|
+
One command to set up [chub_guard](https://github.com/rhealaloo45/chub-guard)
|
|
4
|
+
in any Python project.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
- Python >= 3.10
|
|
9
|
+
- pip or pipx
|
|
10
|
+
- git
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Option 1 — pipx (recommended, no permanent install)
|
|
15
|
+
|
|
16
|
+
pipx run chub-guard-init
|
|
17
|
+
|
|
18
|
+
### Option 2 — pip
|
|
19
|
+
|
|
20
|
+
pip install chub-guard-init
|
|
21
|
+
chub-guard-init
|
|
22
|
+
|
|
23
|
+
This will:
|
|
24
|
+
- Copy `chub_guard.py` into `scripts/`
|
|
25
|
+
- Write `.pre-commit-config.yaml`
|
|
26
|
+
- Write `.chub-docs/registry.json`
|
|
27
|
+
- Update `.gitignore` to ignore doc caches
|
|
28
|
+
- Run `pre-commit install` automatically
|
|
29
|
+
|
|
30
|
+
## After Setup
|
|
31
|
+
|
|
32
|
+
Install chub so the guard can fetch live docs:
|
|
33
|
+
|
|
34
|
+
npm install -g @aisuite/chub
|
|
35
|
+
|
|
36
|
+
Make a commit to test it:
|
|
37
|
+
|
|
38
|
+
git commit -m "test"
|
|
39
|
+
|
|
40
|
+
## Suppressing False Positives
|
|
41
|
+
|
|
42
|
+
Add `# noqa: UP035` to any line to skip:
|
|
43
|
+
|
|
44
|
+
import google.generativeai as genai # noqa: UP035
|
|
45
|
+
|
|
46
|
+
## Also available via npm
|
|
47
|
+
|
|
48
|
+
npx chub-guard-init
|
|
49
|
+
|
|
50
|
+
## Part of chub-guard
|
|
51
|
+
|
|
52
|
+
Full docs: https://github.com/rhealaloo45/chub-guard
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
# Resolve paths to source files in the repo
|
|
7
|
+
PACKAGE_DIR = Path(__file__).parent
|
|
8
|
+
REPO_ROOT = PACKAGE_DIR.parent.parent
|
|
9
|
+
|
|
10
|
+
CHUB_GUARD_PY = (REPO_ROOT / "scripts" / "chub_guard.py").read_text(encoding="utf-8")
|
|
11
|
+
PRE_COMMIT_YAML = (REPO_ROOT / ".pre-commit-config.yaml").read_text(encoding="utf-8")
|
|
12
|
+
REGISTRY_JSON = (REPO_ROOT / ".chub-docs" / "registry.json").read_text(encoding="utf-8")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def is_pre_commit_installed() -> bool:
|
|
16
|
+
return shutil.which("pre-commit") is not None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def is_git_repo(cwd: Path) -> bool:
|
|
20
|
+
return (cwd / ".git").exists()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def ask(question: str) -> str:
|
|
24
|
+
try:
|
|
25
|
+
return input(question).strip().lower()
|
|
26
|
+
except (EOFError, KeyboardInterrupt):
|
|
27
|
+
return "n"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def safe_write(file_path: Path, content: str, label: str) -> None:
|
|
31
|
+
if file_path.exists():
|
|
32
|
+
answer = ask(f"⚠ {label} already exists. Overwrite? (y/n): ")
|
|
33
|
+
if answer != "y":
|
|
34
|
+
print(f" skipped {label}")
|
|
35
|
+
return
|
|
36
|
+
try:
|
|
37
|
+
file_path.write_text(content, encoding="utf-8")
|
|
38
|
+
print(f"✓ {label}")
|
|
39
|
+
except Exception as e:
|
|
40
|
+
print(f"✗ Failed to write {label}: {e}")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main() -> None:
|
|
44
|
+
cwd = Path.cwd()
|
|
45
|
+
|
|
46
|
+
print("")
|
|
47
|
+
print("chub-guard-init")
|
|
48
|
+
print("───────────────────────────────────────")
|
|
49
|
+
print("Setting up chub_guard in this project...")
|
|
50
|
+
print("")
|
|
51
|
+
|
|
52
|
+
# 1. Create directories
|
|
53
|
+
(cwd / "scripts").mkdir(parents=True, exist_ok=True)
|
|
54
|
+
(cwd / ".chub-docs").mkdir(parents=True, exist_ok=True)
|
|
55
|
+
|
|
56
|
+
# 2. Write files
|
|
57
|
+
safe_write(cwd / "scripts" / "chub_guard.py", CHUB_GUARD_PY, "scripts/chub_guard.py")
|
|
58
|
+
safe_write(cwd / ".pre-commit-config.yaml", PRE_COMMIT_YAML, ".pre-commit-config.yaml")
|
|
59
|
+
safe_write(cwd / ".chub-docs" / "registry.json", REGISTRY_JSON, ".chub-docs/registry.json")
|
|
60
|
+
|
|
61
|
+
# 3. Update .gitignore
|
|
62
|
+
gitignore_path = cwd / ".gitignore"
|
|
63
|
+
gitignore_entry = ".chub-docs/*.md"
|
|
64
|
+
if gitignore_path.exists():
|
|
65
|
+
content = gitignore_path.read_text(encoding="utf-8")
|
|
66
|
+
if gitignore_entry not in content:
|
|
67
|
+
gitignore_path.write_text(content.rstrip() + f"\n{gitignore_entry}\n", encoding="utf-8")
|
|
68
|
+
print("✓ .gitignore updated")
|
|
69
|
+
else:
|
|
70
|
+
gitignore_path.write_text(f"{gitignore_entry}\n", encoding="utf-8")
|
|
71
|
+
print("✓ .gitignore created")
|
|
72
|
+
|
|
73
|
+
print("")
|
|
74
|
+
|
|
75
|
+
# 4. Check for git repo
|
|
76
|
+
if not is_git_repo(cwd):
|
|
77
|
+
print("⚠ No .git directory found.")
|
|
78
|
+
print(" Run git init first, then: pre-commit install")
|
|
79
|
+
print("")
|
|
80
|
+
sys.exit(0)
|
|
81
|
+
|
|
82
|
+
# 5. Run pre-commit install
|
|
83
|
+
if is_pre_commit_installed():
|
|
84
|
+
try:
|
|
85
|
+
subprocess.run(["pre-commit", "install"], cwd=cwd, check=True)
|
|
86
|
+
print("")
|
|
87
|
+
print("✓ pre-commit hook installed")
|
|
88
|
+
print("")
|
|
89
|
+
print("───────────────────────────────────────")
|
|
90
|
+
print("Done! chub_guard will now run on every commit.")
|
|
91
|
+
print("")
|
|
92
|
+
print("Next steps:")
|
|
93
|
+
print(" 1. Install chub: npm install -g @aisuite/chub")
|
|
94
|
+
print(" 2. Make a commit to test the guard")
|
|
95
|
+
print("")
|
|
96
|
+
except subprocess.CalledProcessError:
|
|
97
|
+
print("⚠ pre-commit install failed. Run manually: pre-commit install")
|
|
98
|
+
else:
|
|
99
|
+
print("⚠ pre-commit not found. To finish setup:")
|
|
100
|
+
print("")
|
|
101
|
+
print(" pip install pre-commit")
|
|
102
|
+
print(" pre-commit install")
|
|
103
|
+
print("")
|
|
104
|
+
print("Then install chub: npm install -g @aisuite/chub")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
if __name__ == "__main__":
|
|
108
|
+
main()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "chub-guard-init"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "One-command setup for chub_guard — the AI SDK deprecation linter"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
dependencies = []
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
chub-guard-init = "chub_guard_init.main:main"
|
|
14
|
+
|
|
15
|
+
[tool.hatch.build.targets.wheel]
|
|
16
|
+
include = [
|
|
17
|
+
"chub_guard_init/",
|
|
18
|
+
"../../scripts/chub_guard.py",
|
|
19
|
+
"../../.pre-commit-config.yaml",
|
|
20
|
+
"../../.chub-docs/registry.json"
|
|
21
|
+
]
|