gitforce 0.3.0__py3-none-any.whl
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.
- gitforce-0.3.0.dist-info/METADATA +47 -0
- gitforce-0.3.0.dist-info/RECORD +10 -0
- gitforce-0.3.0.dist-info/WHEEL +5 -0
- gitforce-0.3.0.dist-info/entry_points.txt +2 -0
- gitforce-0.3.0.dist-info/top_level.txt +1 -0
- gitforce_py/__init__.py +3 -0
- gitforce_py/__main__.py +5 -0
- gitforce_py/_vendor/README.md +12 -0
- gitforce_py/_vendor/gitforce-cli.js +9451 -0
- gitforce_py/cli.py +68 -0
gitforce_py/cli.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from importlib import resources
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _find_node_executable() -> str | None:
|
|
12
|
+
env_override = os.environ.get("GITFORCE_NODE_BIN", "").strip()
|
|
13
|
+
if env_override:
|
|
14
|
+
return env_override
|
|
15
|
+
return shutil.which("node")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _resolve_bundled_cli_path() -> Path | None:
|
|
19
|
+
try:
|
|
20
|
+
vendor_root = resources.files("gitforce_py").joinpath("_vendor")
|
|
21
|
+
except Exception:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
for filename in ("gitforce-cli.js", "index.js"):
|
|
25
|
+
candidate = vendor_root.joinpath(filename)
|
|
26
|
+
try:
|
|
27
|
+
if candidate.is_file():
|
|
28
|
+
return Path(str(candidate))
|
|
29
|
+
except Exception:
|
|
30
|
+
continue
|
|
31
|
+
return None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _print_node_missing_error() -> None:
|
|
35
|
+
message = (
|
|
36
|
+
"Gitforce requires Node.js on PATH.\n"
|
|
37
|
+
"Install Node.js (recommended LTS) and retry.\n"
|
|
38
|
+
"https://nodejs.org/en/download\n"
|
|
39
|
+
)
|
|
40
|
+
print(message, file=sys.stderr, end="")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _print_bundle_missing_error() -> None:
|
|
44
|
+
message = (
|
|
45
|
+
"Gitforce Python wrapper is missing the bundled CLI artifact.\n"
|
|
46
|
+
"Reinstall the package, or rebuild the wrapper bundle before publishing.\n"
|
|
47
|
+
)
|
|
48
|
+
print(message, file=sys.stderr, end="")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def main() -> int:
|
|
52
|
+
node_executable = _find_node_executable()
|
|
53
|
+
if not node_executable:
|
|
54
|
+
_print_node_missing_error()
|
|
55
|
+
return 1
|
|
56
|
+
|
|
57
|
+
bundled_cli_path = _resolve_bundled_cli_path()
|
|
58
|
+
if not bundled_cli_path:
|
|
59
|
+
_print_bundle_missing_error()
|
|
60
|
+
return 1
|
|
61
|
+
|
|
62
|
+
command = [node_executable, str(bundled_cli_path), *sys.argv[1:]]
|
|
63
|
+
completed = subprocess.run(command, check=False)
|
|
64
|
+
return int(completed.returncode)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
raise SystemExit(main())
|