From ccbfdaf3e2a8b2ed48561bf28b558448efcb0a4c 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] Add autopatch to add schema to toml files --- autopatches/patches/add-schemas/patch.sh | 19 +++++++++++++++++++ autopatches/patches/add-schemas/pr_body.md | 9 +++++++++ autopatches/patches/add-schemas/pr_title.md | 1 + 3 files changed, 29 insertions(+) create mode 100644 autopatches/patches/add-schemas/patch.sh create mode 100644 autopatches/patches/add-schemas/pr_body.md create mode 100644 autopatches/patches/add-schemas/pr_title.md diff --git a/autopatches/patches/add-schemas/patch.sh b/autopatches/patches/add-schemas/patch.sh new file mode 100644 index 0000000..98c9499 --- /dev/null +++ b/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/autopatches/patches/add-schemas/pr_body.md b/autopatches/patches/add-schemas/pr_body.md new file mode 100644 index 0000000..fd837fe --- /dev/null +++ b/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/autopatches/patches/add-schemas/pr_title.md b/autopatches/patches/add-schemas/pr_title.md new file mode 100644 index 0000000..db8a013 --- /dev/null +++ b/autopatches/patches/add-schemas/pr_title.md @@ -0,0 +1 @@ +Add TOML schemas URLs