mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-05 15:27:53 +10:00
improve plugin tests and config
This commit is contained in:
@@ -5,7 +5,7 @@ Install a binary using a custom bash command.
|
||||
This provider runs arbitrary shell commands to install binaries
|
||||
that don't fit into standard package managers.
|
||||
|
||||
Usage: on_Dependency__install_using_custom_bash.py --dependency-id=<uuid> --bin-name=<name> --custom-cmd=<cmd>
|
||||
Usage: on_Binary__install_using_custom_bash.py --binary-id=<uuid> --machine-id=<uuid> --name=<name> --custom-cmd=<cmd>
|
||||
Output: Binary JSONL record to stdout after installation
|
||||
|
||||
Environment variables:
|
||||
@@ -22,22 +22,23 @@ from abx_pkg import Binary, EnvProvider
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--dependency-id', required=True, help="Dependency UUID")
|
||||
@click.option('--bin-name', required=True, help="Binary name to install")
|
||||
@click.option('--binary-id', required=True, help="Binary UUID")
|
||||
@click.option('--machine-id', required=True, help="Machine UUID")
|
||||
@click.option('--name', required=True, help="Binary name to install")
|
||||
@click.option('--binproviders', default='*', help="Allowed providers (comma-separated)")
|
||||
@click.option('--custom-cmd', required=True, help="Custom bash command to run")
|
||||
def main(dependency_id: str, bin_name: str, binproviders: str, custom_cmd: str):
|
||||
def main(binary_id: str, machine_id: str, name: str, binproviders: str, custom_cmd: str):
|
||||
"""Install binary using custom bash command."""
|
||||
|
||||
if binproviders != '*' and 'custom' not in binproviders.split(','):
|
||||
click.echo(f"custom provider not allowed for {bin_name}", err=True)
|
||||
click.echo(f"custom provider not allowed for {name}", err=True)
|
||||
sys.exit(0)
|
||||
|
||||
if not custom_cmd:
|
||||
click.echo("custom provider requires --custom-cmd", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
click.echo(f"Installing {bin_name} via custom command: {custom_cmd}", err=True)
|
||||
click.echo(f"Installing {name} via custom command: {custom_cmd}", err=True)
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
@@ -57,13 +58,13 @@ def main(dependency_id: str, bin_name: str, binproviders: str, custom_cmd: str):
|
||||
# Use abx-pkg to load the binary and get its info
|
||||
provider = EnvProvider()
|
||||
try:
|
||||
binary = Binary(name=bin_name, binproviders=[provider]).load()
|
||||
binary = Binary(name=name, binproviders=[provider]).load()
|
||||
except Exception as e:
|
||||
click.echo(f"{bin_name} not found after custom install: {e}", err=True)
|
||||
click.echo(f"{name} not found after custom install: {e}", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
if not binary.abspath:
|
||||
click.echo(f"{bin_name} not found after custom install", err=True)
|
||||
click.echo(f"{name} not found after custom install", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
machine_id = os.environ.get('MACHINE_ID', '')
|
||||
@@ -71,18 +72,18 @@ def main(dependency_id: str, bin_name: str, binproviders: str, custom_cmd: str):
|
||||
# Output Binary JSONL record to stdout
|
||||
record = {
|
||||
'type': 'Binary',
|
||||
'name': bin_name,
|
||||
'name': name,
|
||||
'abspath': str(binary.abspath),
|
||||
'version': str(binary.version) if binary.version else '',
|
||||
'sha256': binary.sha256 or '',
|
||||
'binprovider': 'custom',
|
||||
'machine_id': machine_id,
|
||||
'dependency_id': dependency_id,
|
||||
'binary_id': binary_id,
|
||||
}
|
||||
print(json.dumps(record))
|
||||
|
||||
# Log human-readable info to stderr
|
||||
click.echo(f"Installed {bin_name} at {binary.abspath}", err=True)
|
||||
click.echo(f"Installed {name} at {binary.abspath}", err=True)
|
||||
click.echo(f" version: {binary.version}", err=True)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
0
archivebox/plugins/custom/templates/icon.html
Normal file
0
archivebox/plugins/custom/templates/icon.html
Normal file
Reference in New Issue
Block a user