From 82c629803e45d605aa1e42ebe12e02c87e41fd98 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 26 Aug 2023 11:28:31 +0200 Subject: [PATCH 1/3] listbuilder: add trick to compute when an app was added to catalog --- list_builder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/list_builder.py b/list_builder.py index 420cbd2..a712f38 100755 --- a/list_builder.py +++ b/list_builder.py @@ -293,6 +293,10 @@ def build_app_dict(app, infos): this_app_cache = app_cache_folder(app) assert os.path.exists(this_app_cache), "No cache yet for %s" % app + commit_timestamps_for_this_app_in_catalog = git(f'log -G "{app}"|\[{app}\] --first-parent --reverse --date=unix --format=%cd -- apps.json apps.toml') + # Assume the first entry we get (= the oldest) is the time the app was added + infos["added_in_catalog"] = int(commit_timestamps_for_this_app_in_catalog.split("\n")[0]) + infos["branch"] = infos.get("branch", "master") infos["revision"] = infos.get("revision", "HEAD") @@ -342,6 +346,7 @@ def build_app_dict(app, infos): "revision": infos["revision"], "url": infos["url"], }, + "added_in_catalog": infos["added_in_catalog"], "lastUpdate": timestamp, "manifest": manifest, "state": infos["state"], From 7eafa89dad0a91d917b54bf2f987b35472707434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 6 Sep 2023 10:34:36 +0200 Subject: [PATCH 2/3] Add autopatch to add schema to toml files --- .../autopatches/patches/add-schemas/patch.sh | 19 +++++++++++++++++++ .../patches/add-schemas/pr_body.md | 9 +++++++++ .../patches/add-schemas/pr_title.md | 1 + 3 files changed, 29 insertions(+) create mode 100644 tools/autopatches/patches/add-schemas/patch.sh create mode 100644 tools/autopatches/patches/add-schemas/pr_body.md create mode 100644 tools/autopatches/patches/add-schemas/pr_title.md diff --git a/tools/autopatches/patches/add-schemas/patch.sh b/tools/autopatches/patches/add-schemas/patch.sh new file mode 100644 index 0000000..98c9499 --- /dev/null +++ b/tools/autopatches/patches/add-schemas/patch.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +MANIFEST_SCHEMA_LINE='#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json' +TESTS_SCHEMA_LINE='#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json' + + +if [ -f "manifest.toml" ]; then + if ! grep "#:schema" "manifest.toml" >/dev/null; then + sed -i "1 s|^|$MANIFEST_SCHEMA_LINE\n|" manifest.toml + fi +fi + +if [ -f "tests.toml" ]; then + if ! grep "#:schema" "tests.toml" >/dev/null; then + sed -i "1 s|^|$TESTS_SCHEMA_LINE\n|" tests.toml + fi +fi + +git add manifest.toml tests.toml diff --git a/tools/autopatches/patches/add-schemas/pr_body.md b/tools/autopatches/patches/add-schemas/pr_body.md new file mode 100644 index 0000000..fd837fe --- /dev/null +++ b/tools/autopatches/patches/add-schemas/pr_body.md @@ -0,0 +1,9 @@ + +This is an ***automated*** patch to add the TOML schemas URLs to manifest.toml and tests.toml. + +This allows to check for the validity of your TOML files. + +Multiple tools can be used to validate files against their schema: + +* `taplo`, a command line tool: `taplo lint manifest.toml` +* IDEs like VScode have plugins to automagically validate files diff --git a/tools/autopatches/patches/add-schemas/pr_title.md b/tools/autopatches/patches/add-schemas/pr_title.md new file mode 100644 index 0000000..db8a013 --- /dev/null +++ b/tools/autopatches/patches/add-schemas/pr_title.md @@ -0,0 +1 @@ +Add TOML schemas URLs From e750c20f06e5404f701d166d2cd97ab943019940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 6 Sep 2023 10:37:16 +0200 Subject: [PATCH 3/3] Add manifest URL in conversion script manifestv1 -> manifestv2 --- tools/packaging_v2/convert_app_to_packaging_v2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/packaging_v2/convert_app_to_packaging_v2.py b/tools/packaging_v2/convert_app_to_packaging_v2.py index 2705321..7887cdb 100644 --- a/tools/packaging_v2/convert_app_to_packaging_v2.py +++ b/tools/packaging_v2/convert_app_to_packaging_v2.py @@ -474,6 +474,8 @@ if __name__ == "__main__": args = parser.parse_args() manifest = _convert_v1_manifest_to_v2(args.app_path) - open(args.app_path + "/manifest.toml", "w").write(_dump_v2_manifest_as_toml(manifest)) + with open(args.app_path + "/manifest.toml", "w") as manifest_file: + manifest_file.write("#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json\n\n") + manifest_file.write(_dump_v2_manifest_as_toml(manifest)) cleanup_scripts_and_conf(args.app_path)