aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBraxton Hall2022-10-27 07:45:28 +0000
committerGitHub2022-10-27 07:45:28 +0000
commitc2cde6bb9c1a43a69a276a20ad083d88b6fa0693 (patch)
tree16dfc02eac5fe3b538c3e49719eb62e800f0b4cd /bin
parent4acadab99cb1e3241ed7e5fd3b39d07adbc54f21 (diff)
Workflow (#56)
* Make the people check more rigorous * Actually install ajv before trying to use it in an action * Automatically prettify people.json * Rename workflow step * Make sure correct branch is checked out * Use tabs
Diffstat (limited to 'bin')
-rw-r--r--bin/checkPeople.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/checkPeople.js b/bin/checkPeople.js
index 3c564a4..877ba8f 100644
--- a/bin/checkPeople.js
+++ b/bin/checkPeople.js
@@ -1,4 +1,37 @@
const fs = require("fs");
+const Ajv = require("ajv");
+
+const ajv = new Ajv();
+
+const schema = {
+ type: "array",
+ uniqueItems: true,
+ minItems: 1,
+ items: {
+ type: "object",
+ required: ["name", "title", "entries"],
+ properties: {
+ github: {type: "string"},
+ name: {type: "string"},
+ title: {type: "string"},
+ entries: {
+ type: "array",
+ uniqueItems: true,
+ minItems: 1,
+ items: {
+ type: "object",
+ required: ["name", "link"],
+ properties: {
+ name: {type: "string"},
+ link: {type: "string"},
+ },
+ additionalProperties: false,
+ },
+ },
+ },
+ additionalProperties: false,
+ },
+};
const PEOPLE_PATH = "./people.json";
@@ -33,4 +66,10 @@ for (const entry of person.entries) {
}
}
+const validate = ajv.compile(schema);
+if (!validate(people)) {
+ console.error(validate.errors);
+ throw "people.json does not conform to json schema";
+}
+
console.log("Checked!");