mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-08 06:58:42 +00:00
Add dependency check subcommand
This commit is contained in:
@@ -18,3 +18,9 @@ If problems persist, consult the OnionShare and Tor documentation for more advan
|
|||||||
|
|
||||||
## Electron GUI
|
## Electron GUI
|
||||||
If `npm start` fails with `spawn voxvera ENOENT`, the `voxvera` command is not in your `PATH`. Install it with `pipx install voxvera` or run `./install.sh` from the repository.
|
If `npm start` fails with `spawn voxvera ENOENT`, the `voxvera` command is not in your `PATH`. Install it with `pipx install voxvera` or run `./install.sh` from the repository.
|
||||||
|
|
||||||
|
## Missing dependencies
|
||||||
|
Run `voxvera check` to see which required tools are present. The command verifies
|
||||||
|
`node`, `javascript-obfuscator`, `html-minifier-terser`, `jq`, `qrencode`,
|
||||||
|
`onionshare-cli`, and other helpers, then prints a summary of any that are
|
||||||
|
missing so you can install them.
|
||||||
|
@@ -64,3 +64,20 @@ def test_import(tmp_path, monkeypatch):
|
|||||||
assert dest.is_dir()
|
assert dest.is_dir()
|
||||||
assert (dest / "index.html").exists()
|
assert (dest / "index.html").exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_all_present(capsys, monkeypatch):
|
||||||
|
monkeypatch.setattr(shutil, "which", lambda cmd: "/usr/bin/" + cmd)
|
||||||
|
cli.main(["check"])
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
assert "All required tools are installed." in captured.out
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_missing(capsys, monkeypatch):
|
||||||
|
def fake_which(cmd):
|
||||||
|
return None if cmd == "node" else "/usr/bin/" + cmd
|
||||||
|
|
||||||
|
monkeypatch.setattr(shutil, "which", fake_which)
|
||||||
|
cli.main(["check"])
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
assert "node: missing" in captured.out
|
||||||
|
|
||||||
|
@@ -31,6 +31,39 @@ def require_cmd(cmd: str):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def check_deps():
|
||||||
|
console = Console()
|
||||||
|
tools = [
|
||||||
|
"node",
|
||||||
|
"javascript-obfuscator",
|
||||||
|
"html-minifier-terser",
|
||||||
|
"jq",
|
||||||
|
"qrencode",
|
||||||
|
"onionshare-cli",
|
||||||
|
"convert",
|
||||||
|
"pdftotext",
|
||||||
|
]
|
||||||
|
|
||||||
|
found = []
|
||||||
|
missing = []
|
||||||
|
for t in tools:
|
||||||
|
if shutil.which(t):
|
||||||
|
found.append(t)
|
||||||
|
else:
|
||||||
|
missing.append(t)
|
||||||
|
|
||||||
|
console.rule("Dependency Check")
|
||||||
|
for t in tools:
|
||||||
|
status = "found" if t in found else "missing"
|
||||||
|
color = "green" if t in found else "red"
|
||||||
|
console.print(f"{t}: [{color}]{status}[/{color}]")
|
||||||
|
|
||||||
|
if missing:
|
||||||
|
console.print(f"[red]Missing tools:[/red] {', '.join(missing)}")
|
||||||
|
else:
|
||||||
|
console.print("[green]All required tools are installed.[/green]")
|
||||||
|
|
||||||
|
|
||||||
def run(cmd, **kwargs):
|
def run(cmd, **kwargs):
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, check=True, **kwargs)
|
subprocess.run(cmd, check=True, **kwargs)
|
||||||
@@ -327,6 +360,7 @@ def main(argv=None):
|
|||||||
sub.add_parser('import', help='Batch import JSON files from imports/')
|
sub.add_parser('import', help='Batch import JSON files from imports/')
|
||||||
sub.add_parser('serve', help='Serve flyer over OnionShare using config')
|
sub.add_parser('serve', help='Serve flyer over OnionShare using config')
|
||||||
sub.add_parser('quickstart', help='Init, build and serve in sequence')
|
sub.add_parser('quickstart', help='Init, build and serve in sequence')
|
||||||
|
sub.add_parser('check', help='Check for required external dependencies')
|
||||||
|
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
config_path = Path(args.config).resolve()
|
config_path = Path(args.config).resolve()
|
||||||
@@ -351,6 +385,8 @@ def main(argv=None):
|
|||||||
interactive_update(config_path)
|
interactive_update(config_path)
|
||||||
build_assets(config_path)
|
build_assets(config_path)
|
||||||
serve(config_path)
|
serve(config_path)
|
||||||
|
elif args.command == 'check':
|
||||||
|
check_deps()
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user