From 499db257a174c57d5b5e456fbfa55515a8af2229 Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Wed, 23 Feb 2022 07:18:05 +0000 Subject: [PATCH 1/6] Add Anti-Features in READMEs --- tools/README-generator/make_readme.py | 12 ++++++++++++ tools/README-generator/requirements.txt | 1 + tools/README-generator/templates/README.md.j2 | 8 ++++++++ tools/README-generator/templates/README_fr.md.j2 | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/tools/README-generator/make_readme.py b/tools/README-generator/make_readme.py index ddcc3d29..3e8be5ab 100755 --- a/tools/README-generator/make_readme.py +++ b/tools/README-generator/make_readme.py @@ -3,6 +3,7 @@ import argparse import json import os +import yaml from pathlib import Path from jinja2 import Environment, FileSystemLoader @@ -18,6 +19,11 @@ def generate_READMEs(app_path: str): manifest = json.load(open(app_path / "manifest.json")) upstream = manifest.get("upstream", {}) + catalog = json.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "apps.json")) + from_catalog = catalog.get(manifest['id'], {}) + + antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yaml")) + if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists(): print( "There's no 'upstream' key in the manifest, and doc/DISCLAIMER.md doesn't exists - therefore assuming that we shall not auto-update the README.md for this app yet." @@ -53,6 +59,12 @@ def generate_READMEs(app_path: str): else: disclaimer = None + # TODO: Add url to the documentation... and actually create that documentation :D + antifeatures = [antifeatures_list[a] for a in from_catalog.get('antifeatures', [])] + for antifeature in antifeatures: + antifeature['title'] = antifeature['title'].get(lang_suffix, 'en') + antifeature['description'] = antifeature['description'].get(lang_suffix, 'en') + out = template.render( lang=lang, upstream=upstream, diff --git a/tools/README-generator/requirements.txt b/tools/README-generator/requirements.txt index 88cd6e2e..33fe25a7 100644 --- a/tools/README-generator/requirements.txt +++ b/tools/README-generator/requirements.txt @@ -1,2 +1,3 @@ jinja2 sanic +pyyaml diff --git a/tools/README-generator/templates/README.md.j2 b/tools/README-generator/templates/README.md.j2 index 6e58002a..8713a9a9 100644 --- a/tools/README-generator/templates/README.md.j2 +++ b/tools/README-generator/templates/README.md.j2 @@ -49,6 +49,14 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in {{ disclaimer }} {% endif -%} +{% if antifeatures -%} +## Antifeatures + +{% for antifeature in antifeatures -%} + - **{{ antifeature.title }}**: {{ antifeature.description }} +{% endfor -%} +{% endif -%} + ## Documentation and resources {% if upstream.website -%}* Official app website: {{ upstream.website }} diff --git a/tools/README-generator/templates/README_fr.md.j2 b/tools/README-generator/templates/README_fr.md.j2 index 9169cbbd..9e89c10c 100644 --- a/tools/README-generator/templates/README_fr.md.j2 +++ b/tools/README-generator/templates/README_fr.md.j2 @@ -31,6 +31,14 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour {{ disclaimer }} {% endif -%} +{% if antifeatures -%} +## Fonctions indésirables + +{% for antifeature in antifeatures -%} + - **{{ antifeature.title }}**: {{ antifeature.description }} +{% endfor -%} +{% endif -%} + ## Documentations et ressources {% if upstream.website -%}* Site officiel de l'app : {{ upstream.website }} From feb3abe7dbb8210b6bbde42c2a44c3aebb12f622 Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Mon, 30 May 2022 11:59:54 +0000 Subject: [PATCH 2/6] fix --- tools/README-generator/make_readme.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/README-generator/make_readme.py b/tools/README-generator/make_readme.py index 3e8be5ab..788b8a7b 100755 --- a/tools/README-generator/make_readme.py +++ b/tools/README-generator/make_readme.py @@ -22,7 +22,8 @@ def generate_READMEs(app_path: str): catalog = json.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "apps.json")) from_catalog = catalog.get(manifest['id'], {}) - antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yaml")) + antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yml")) + antifeatures_list = { e['id']: e for e in antifeatures_list } if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists(): print( @@ -60,10 +61,13 @@ def generate_READMEs(app_path: str): disclaimer = None # TODO: Add url to the documentation... and actually create that documentation :D - antifeatures = [antifeatures_list[a] for a in from_catalog.get('antifeatures', [])] - for antifeature in antifeatures: - antifeature['title'] = antifeature['title'].get(lang_suffix, 'en') - antifeature['description'] = antifeature['description'].get(lang_suffix, 'en') + antifeatures = { a: antifeatures_list[a] for a in from_catalog.get('antifeatures', [])} + for k, v in antifeatures: + v['title'] = v['title'].get(lang_suffix, 'en') + if manifest.get("antifeatures", {}).get(k, 'en'): + v['description'] = manifest.get("antifeatures", {}).get(k, 'en') + else: + antifeature['description'] = antifeature['description'].get(lang_suffix, 'en') out = template.render( lang=lang, From de8bd05e57949f4c3bdf79e7148bd47acd176c29 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 5 Aug 2022 11:29:53 +0200 Subject: [PATCH 3/6] Do not look for locales in JSON validation @alexAubin deleted the locales directory --- .github/workflows/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c3e65ff..af809144 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,3 @@ jobs: - name: Check apps.json run: | python -m json.tool apps.json - - name: Check locales - run: | - for i in ./locales/*.json; do python -m json.tool $i || return 1; done From 7f7218191ff21b1f94726f324595a51f1240cd99 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 5 Aug 2022 14:56:52 +0200 Subject: [PATCH 4/6] packaging v2: add a 'CPE' field in upstream section --- tools/packaging_v2/convert_app_to_packaging_v2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/packaging_v2/convert_app_to_packaging_v2.py b/tools/packaging_v2/convert_app_to_packaging_v2.py index b2a11c31..ba001531 100644 --- a/tools/packaging_v2/convert_app_to_packaging_v2.py +++ b/tools/packaging_v2/convert_app_to_packaging_v2.py @@ -26,6 +26,8 @@ def _convert_v1_manifest_to_v2(app_path): if "url" in manifest and "website" not in manifest["upstream"]: manifest["upstream"]["website"] = manifest["url"] + manifest["upstream"]["cpe"] = "???" + manifest["integration"] = { "yunohost": manifest.get("requirements", {}).get("yunohost"), "architectures": "all", @@ -158,6 +160,7 @@ def _dump_v2_manifest_as_toml(manifest): upstream = table() for key, value in manifest["upstream"].items(): upstream[key] = value + upstream["cpe"].comment("FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)") toml_manifest["upstream"] = upstream integration = table() From 43cde68aa795390bc64d085607a80ebff6521d9a Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 5 Aug 2022 16:39:38 +0200 Subject: [PATCH 5/6] Fix antifeatures list generation --- tools/README-generator/make_readme.py | 22 ++++++++++++++----- tools/README-generator/templates/README.md.j2 | 3 ++- .../templates/README_fr.md.j2 | 4 +++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/README-generator/make_readme.py b/tools/README-generator/make_readme.py index 788b8a7b..d9c03db4 100755 --- a/tools/README-generator/make_readme.py +++ b/tools/README-generator/make_readme.py @@ -8,6 +8,15 @@ from pathlib import Path from jinja2 import Environment, FileSystemLoader +def value_for_lang(values, lang): + if not isinstance(values, dict): + return values + if lang in values: + return values[lang] + elif "en" in values: + return values["en"] + else: + return list(values.values())[0] def generate_READMEs(app_path: str): @@ -22,7 +31,7 @@ def generate_READMEs(app_path: str): catalog = json.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "apps.json")) from_catalog = catalog.get(manifest['id'], {}) - antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yml")) + antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yml"), Loader=yaml.SafeLoader) antifeatures_list = { e['id']: e for e in antifeatures_list } if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists(): @@ -62,12 +71,12 @@ def generate_READMEs(app_path: str): # TODO: Add url to the documentation... and actually create that documentation :D antifeatures = { a: antifeatures_list[a] for a in from_catalog.get('antifeatures', [])} - for k, v in antifeatures: - v['title'] = v['title'].get(lang_suffix, 'en') - if manifest.get("antifeatures", {}).get(k, 'en'): - v['description'] = manifest.get("antifeatures", {}).get(k, 'en') + for k, v in antifeatures.items(): + antifeatures[k]['title'] = value_for_lang(v['title'], lang_suffix) + if manifest.get("antifeatures", {}).get(k, None): + antifeatures[k]['description'] = value_for_lang(manifest.get("antifeatures", {}).get(k, None), lang_suffix) else: - antifeature['description'] = antifeature['description'].get(lang_suffix, 'en') + antifeatures[k]['description'] = value_for_lang(antifeatures[k]['description'], lang_suffix) out = template.render( lang=lang, @@ -75,6 +84,7 @@ def generate_READMEs(app_path: str): description=description, screenshots=screenshots, disclaimer=disclaimer, + antifeatures=antifeatures, manifest=manifest, ) (app_path / f"README{lang_suffix}.md").write_text(out) diff --git a/tools/README-generator/templates/README.md.j2 b/tools/README-generator/templates/README.md.j2 index 8713a9a9..990b5e0d 100644 --- a/tools/README-generator/templates/README.md.j2 +++ b/tools/README-generator/templates/README.md.j2 @@ -52,8 +52,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in {% if antifeatures -%} ## Antifeatures -{% for antifeature in antifeatures -%} +{% for antifeature in antifeatures.values() -%} - **{{ antifeature.title }}**: {{ antifeature.description }} + {% endfor -%} {% endif -%} diff --git a/tools/README-generator/templates/README_fr.md.j2 b/tools/README-generator/templates/README_fr.md.j2 index 9e89c10c..864dc604 100644 --- a/tools/README-generator/templates/README_fr.md.j2 +++ b/tools/README-generator/templates/README_fr.md.j2 @@ -34,11 +34,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour {% if antifeatures -%} ## Fonctions indésirables -{% for antifeature in antifeatures -%} +{% for antifeature in antifeatures.values() -%} - **{{ antifeature.title }}**: {{ antifeature.description }} + {% endfor -%} {% endif -%} + ## Documentations et ressources {% if upstream.website -%}* Site officiel de l'app : {{ upstream.website }} From f931bde5009344c5ee712ad631951c2fd3f35ed3 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 5 Aug 2022 16:41:27 +0200 Subject: [PATCH 6/6] Add red circle to antifeatures title Co-authored-by: Alexandre Aubin --- tools/README-generator/templates/README.md.j2 | 2 +- tools/README-generator/templates/README_fr.md.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/README-generator/templates/README.md.j2 b/tools/README-generator/templates/README.md.j2 index 990b5e0d..91d65102 100644 --- a/tools/README-generator/templates/README.md.j2 +++ b/tools/README-generator/templates/README.md.j2 @@ -50,7 +50,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in {% endif -%} {% if antifeatures -%} -## Antifeatures +## :red_circle: Antifeatures {% for antifeature in antifeatures.values() -%} - **{{ antifeature.title }}**: {{ antifeature.description }} diff --git a/tools/README-generator/templates/README_fr.md.j2 b/tools/README-generator/templates/README_fr.md.j2 index 864dc604..22f4ebba 100644 --- a/tools/README-generator/templates/README_fr.md.j2 +++ b/tools/README-generator/templates/README_fr.md.j2 @@ -32,7 +32,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour {% endif -%} {% if antifeatures -%} -## Fonctions indésirables +## :red_circle: Fonctions indésirables {% for antifeature in antifeatures.values() -%} - **{{ antifeature.title }}**: {{ antifeature.description }}