release: public alpha 0.6.0 baseline
This commit is contained in:
Executable
+69
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate one or more JWeBot plugin manifests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path[:0] = [
|
||||
str(ROOT / "packages" / "jwebot-sdk" / "src"),
|
||||
str(ROOT / "packages" / "jwebot-kernel" / "src"),
|
||||
]
|
||||
|
||||
from jwebot_kernel import ( # noqa: E402
|
||||
ManifestError,
|
||||
SourcePolicyError,
|
||||
load_manifest,
|
||||
validate_source_tree,
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("manifest", nargs="+", type=Path)
|
||||
args = parser.parse_args()
|
||||
results: list[dict[str, object]] = []
|
||||
for path in args.manifest:
|
||||
try:
|
||||
manifest = load_manifest(path)
|
||||
source_paths = validate_source_tree(path.parent, manifest)
|
||||
except (ManifestError, SourcePolicyError) as error:
|
||||
print(
|
||||
json.dumps(
|
||||
{"path": str(path), "valid": False, "error": str(error)},
|
||||
ensure_ascii=False,
|
||||
sort_keys=True,
|
||||
)
|
||||
)
|
||||
return 1
|
||||
results.append(
|
||||
{
|
||||
"path": str(path),
|
||||
"valid": True,
|
||||
"id": manifest.plugin_id,
|
||||
"author": manifest.author,
|
||||
"version": manifest.version,
|
||||
"api_version": manifest.api_version,
|
||||
"type": manifest.plugin_type.value,
|
||||
"commands": list(manifest.capabilities.commands),
|
||||
"network_profiles": list(
|
||||
manifest.capabilities.network_profiles
|
||||
),
|
||||
"service_profiles": list(
|
||||
manifest.capabilities.service_profiles
|
||||
),
|
||||
"source_files": len(source_paths),
|
||||
}
|
||||
)
|
||||
for result in results:
|
||||
print(json.dumps(result, ensure_ascii=False, sort_keys=True))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user