1
0
Fork 0

Merge pull request #1725 from Salamandar/autopatch-schema

Add schema URLs via autopatch and convert_app_to_manifestv2
This commit is contained in:
Alexandre Aubin 2023-09-06 10:49:12 +02:00 committed by GitHub
commit b844b970df
4 changed files with 32 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -0,0 +1 @@
Add TOML schemas URLs

View file

@ -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)