From 6908527ebdd3ab36102386c9ae323695eb6a8d30 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Thu, 2 May 2024 17:53:27 +0200 Subject: [PATCH] Throw error on missing clanModule description or if description too long. Add xfce description. --- clanModules/xfce/README.md | 1 + clanModules/zt-tcp-relay/README.md | 1 + lib/default.nix | 2 +- lib/description.nix | 15 +++++++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/clanModules/xfce/README.md b/clanModules/xfce/README.md index ed97d539c..85e35918f 100644 --- a/clanModules/xfce/README.md +++ b/clanModules/xfce/README.md @@ -1 +1,2 @@ +A lightweight desktop manager --- diff --git a/clanModules/zt-tcp-relay/README.md b/clanModules/zt-tcp-relay/README.md index ed97d539c..2101ad330 100644 --- a/clanModules/zt-tcp-relay/README.md +++ b/clanModules/zt-tcp-relay/README.md @@ -1 +1,2 @@ +Enable ZeroTier VPN over TCP for networks where UDP is blocked. --- diff --git a/lib/default.nix b/lib/default.nix index 4f5558cee..e9fbde4d5 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -6,6 +6,6 @@ }: { jsonschema = import ./jsonschema { inherit lib; }; - modules = import ./description.nix { inherit clan-core; }; + modules = import ./description.nix { inherit clan-core lib; }; buildClan = import ./build-clan { inherit clan-core lib nixpkgs; }; } diff --git a/lib/description.nix b/lib/description.nix index deb315b44..dc2857306 100644 --- a/lib/description.nix +++ b/lib/description.nix @@ -1,4 +1,4 @@ -{ clan-core, ... }: +{ lib, clan-core, ... }: rec { getReadme = @@ -17,10 +17,17 @@ rec { modulename: let content = (getReadme modulename); - parts = builtins.split "---" content; + parts = lib.splitString "---" content; + description = builtins.head parts; + number_of_newlines = builtins.length (lib.splitString "\n" description); in - if (builtins.length parts) > 0 then - builtins.head parts + if (builtins.length parts) > 1 then + if number_of_newlines > 4 then + throw "Short description in README.md for module ${modulename} is too long. Max 3 newlines." + else if number_of_newlines <= 1 then + throw "Missing short description in README.md for module ${modulename}." + else + description else throw "Short description delimiter `---` not found in README.md for module ${modulename}"; }