From 9adf5e522cb3a40d407101223f06571f3580976c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 16 Apr 2021 00:32:25 +0200 Subject: [PATCH] Add app_manifest to fetch manifest of an app from the catalog or using url --- data/actionsmap/yunohost.yml | 10 +++++++++- src/yunohost/app.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 4526989df..e0eb8893c 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -608,6 +608,14 @@ app: string: help: Return matching app name or description with "string" + ### app_manifest() + manifest: + action_help: Return the manifest of a given app from the manifest, or from a remote git repo + api: GET /apps/manifest + arguments: + app: + help: Name, local path or git URL of the app to fetch the manifest of + fetchlist: deprecated: true @@ -679,7 +687,7 @@ app: help: Do not ask confirmation if the app is not safe to use (low quality, experimental or 3rd party) action: store_true - ### app_remove() TODO: Write help + ### app_remove() remove: action_help: Remove app api: DELETE /apps/ diff --git a/src/yunohost/app.py b/src/yunohost/app.py index a3c10df0b..af23e9352 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -786,6 +786,21 @@ def app_upgrade(app=[], url=None, file=None, force=False): logger.success(m18n.n("upgrade_complete")) +def app_manifest(app): + + raw_app_list = _load_apps_catalog()["apps"] + + if app in raw_app_list or ("@" in app) or ("http://" in app) or ("https://" in app): + manifest, extracted_app_folder = _fetch_app_from_git(app) + elif os.path.exists(app): + manifest, extracted_app_folder = _extract_app_from_file(app) + else: + raise YunohostValidationError("app_unknown") + + shutil.rmtree(extracted_app_folder) + + return manifest + @is_unit_operation() def app_install( operation_logger,