scm-kit 0.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.
scm_kit-0.0.0/PKG-INFO ADDED
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: scm-kit
3
+ Version: 0.0.0
4
+ Requires-Python: >=3.11
5
+ Description-Content-Type: text/markdown
File without changes
@@ -0,0 +1,9 @@
1
+ [project]
2
+ name = "scm-kit"
3
+ version = "0.0.0"
4
+ readme = "README.md"
5
+ requires-python = ">=3.11"
6
+
7
+ [project.scripts]
8
+ scm-format = "scm_utils.format:main"
9
+ scm-lint = "scm_utils.lint:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: scm-kit
3
+ Version: 0.0.0
4
+ Requires-Python: >=3.11
5
+ Description-Content-Type: text/markdown
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/scm_kit.egg-info/PKG-INFO
4
+ src/scm_kit.egg-info/SOURCES.txt
5
+ src/scm_kit.egg-info/dependency_links.txt
6
+ src/scm_kit.egg-info/entry_points.txt
7
+ src/scm_kit.egg-info/top_level.txt
8
+ src/scm_utils/common.py
9
+ src/scm_utils/format.py
10
+ src/scm_utils/lint.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ scm-format = scm_utils.format:main
3
+ scm-lint = scm_utils.lint:main
@@ -0,0 +1 @@
1
+ scm_utils
@@ -0,0 +1,43 @@
1
+ import shutil
2
+ import subprocess
3
+ import sys
4
+
5
+
6
+ def run(cmd: list[str], capture: bool = False) -> subprocess.CompletedProcess:
7
+ return subprocess.run(cmd, check=True, capture_output=capture, text=capture)
8
+
9
+
10
+ def maybe_run(cmd: list[str]) -> None:
11
+ if not shutil.which(cmd[0]):
12
+ return
13
+ run(cmd)
14
+
15
+
16
+ def check_for_required_tools() -> None:
17
+ """Check that required tools are available, exit if not."""
18
+ missing = []
19
+ if not shutil.which("uvx"):
20
+ missing.append("uvx")
21
+ if not shutil.which("npx"):
22
+ missing.append("npx")
23
+ if missing:
24
+ print(f"Error: Required tools not found: {', '.join(missing)}", file=sys.stderr)
25
+ sys.exit(1)
26
+
27
+
28
+ def get_files_by_ext(ext: str, all_files: bool) -> set[str]:
29
+ def _git(cmd: list[str]) -> set[str]:
30
+ stdout = run(["git"] + cmd, capture=True).stdout.strip()
31
+ return set(stdout.splitlines()) if stdout else set()
32
+
33
+ if all_files:
34
+ # All non-deleted files.
35
+ files = _git(["ls-files", "-c", "-o", "--exclude-standard", f"*.{ext}"])
36
+ deleted = _git(["ls-files", "-d"])
37
+ return files - deleted
38
+ else:
39
+ # New or modified files relative to main branch, and untracked files.
40
+ changed = _git(["diff", "--name-only", "--diff-filter=d", "main"])
41
+ changed = {x for x in changed if x.endswith(f".{ext}")}
42
+ untracked = _git(["ls-files", "-o", "--exclude-standard", f"*.{ext}"])
43
+ return changed | untracked
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import subprocess
4
+ import sys
5
+
6
+ from common import check_for_required_tools, maybe_run, run
7
+
8
+
9
+ def format_code() -> None:
10
+ maybe_run(["gofmt", "-s", "-w", "."])
11
+ run(["npx", "prettier", "--write", "."])
12
+ run(["uvx", "ruff", "check", "--fix-only", "."])
13
+ run(["uvx", "ruff", "format", "."])
14
+
15
+
16
+ def main() -> None:
17
+ check_for_required_tools()
18
+ try:
19
+ format_code()
20
+ except subprocess.CalledProcessError:
21
+ sys.exit(1)
22
+
23
+
24
+ if __name__ == "__main__":
25
+ main()
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import subprocess
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ from common import check_for_required_tools, get_files_by_ext, maybe_run, run
9
+
10
+
11
+ def lint_code(all_files: bool) -> None:
12
+ if (Path.cwd() / "go.mod").exists():
13
+ maybe_run(["go", "vet", "./..."])
14
+ run(["npx", "prettier", "--check", "."])
15
+ run(["npx", "jshint", "."])
16
+ run(["uvx", "ruff", "check", "."])
17
+ run(["uvx", "ruff", "format", "--check", "."])
18
+ py_files = list(get_files_by_ext("py", all_files))
19
+ if py_files:
20
+ run(["uvx", "pyright"] + py_files)
21
+
22
+
23
+ def main() -> None:
24
+ check_for_required_tools()
25
+ parser = argparse.ArgumentParser()
26
+ parser.add_argument("-a", "--all-files", action="store_true")
27
+ args = parser.parse_args()
28
+ try:
29
+ lint_code(args.all_files)
30
+ except subprocess.CalledProcessError:
31
+ sys.exit(1)
32
+
33
+
34
+ if __name__ == "__main__":
35
+ main()