From 390768c4772d20c67b2a0c17af7dd8209727c850 Mon Sep 17 00:00:00 2001 From: tree Date: Sun, 5 Nov 2023 21:36:11 +0100 Subject: [PATCH] put all events into one source file --- README.tpl.eta | 4 ++-- events/{meetups.yaml => events.yaml} | 17 +++++++++++++++++ events/summits.yaml | 10 ---------- index.js | 19 ++++++++----------- schema.yaml | 8 ++++++-- 5 files changed, 33 insertions(+), 25 deletions(-) rename events/{meetups.yaml => events.yaml} (68%) delete mode 100644 events/summits.yaml diff --git a/README.tpl.eta b/README.tpl.eta index 430016d..91b64b1 100644 --- a/README.tpl.eta +++ b/README.tpl.eta @@ -27,7 +27,7 @@ research and community of [Web3Privacy Now](https://web3privacy.info). | # id | date | location | 👥 | coincidence | dri | links | | --- | --- | --- | --- | --- | --- | --- | -<% it.events.summits.forEach(function(event, i){ %> +<% it.events.filter(e => e.type === 'summit').forEach(function(event, i){ %> | #<%= i+1%> → `<%= event.id %>` | <%= event.date.match(/^\d{4}-\d{2}-\d{2}$/) ? `**${event.date}**` : event.date %> | <%= it.getFlagEmoji(event.country) %> <%= event.city %> | <%= event.visitors || '-' %> | <%= event.coincidence %> | <%= event.lead || "-" %> | <%= (event.links && Object.keys(event.links).map(k => `[${k}](${event.links[k]})`).join(", ")) || "" %> | <% }) %> @@ -35,7 +35,7 @@ research and community of [Web3Privacy Now](https://web3privacy.info). | # id | date | location | 👥 | coincidence | dri | links | | --- | --- | --- | --- | --- | --- | --- | -<% it.events.meetups.forEach(function(event, i){ %> +<% it.events.filter(e => e.type === 'meetup').forEach(function(event, i){ %> | <% if (event.links?.git) { %>[`<%= event.id %>`](<%= event.links.git %>)<% } else { %>`<%= event.id.replace('w3pm-','') %>`<% } %> | <%= event.date.match(/^\d{4}-\d{2}-\d{2}$/) ? `**${event.date}**` : event.date %> | <%= it.getFlagEmoji(event.country) %> <%= event.city %> | <%= event.visitors || '-' %> | <%= event.coincidence %> | <%= event.lead || "-" %> | <%= (event.links && Object.keys(event.links).map(k => `[${k}](${event.links[k]})`).join(", ")) || "" %> | <% }) %> diff --git a/events/meetups.yaml b/events/events.yaml similarity index 68% rename from events/meetups.yaml rename to events/events.yaml index 0167b4b..3fd18f8 100644 --- a/events/meetups.yaml +++ b/events/events.yaml @@ -1,4 +1,17 @@ +- id: w3ps1 + type: summit + date: "2023-06-05" + city: Prague + country: cz + coincidence: "[PBW](https://prgblockweek.com/) w/ [ETHPrague](https://ethprague.com/)" + lead: Tree + visitors: 180 + links: + web: https://prague.web3privacy.info/ + git: https://github.com/web3privacy/w3ps1 + - id: w3pm-rom-1 + type: meetup date: "2023-10-05" city: Rome country: it @@ -9,6 +22,7 @@ web: https://lu.ma/web3privacynow_rome - id: w3pm-prg-1 + type: meetup date: "2023-11-14" city: Prague country: cz @@ -18,12 +32,14 @@ web: https://lu.ma/w3pm-prg1 - id: w3pm-ist-1 + type: meetup date: "2023/Nov" city: Istanbul country: tr coincidence: "[Devconnect Istanbul](https://devconnect.org/)" - id: w3pm-ams-1 + type: meetup date: "2024/May" city: Amsterdam country: nl @@ -31,6 +47,7 @@ coincidence: "[ETHDam 2024](https://www.ethdam.com/)" - id: w3pm-ber-1 + type: meetup date: "2024/May" city: Berlin country: de diff --git a/events/summits.yaml b/events/summits.yaml deleted file mode 100644 index f3fc55b..0000000 --- a/events/summits.yaml +++ /dev/null @@ -1,10 +0,0 @@ -- id: w3ps1 - date: "2023-06-05" - city: Prague - country: cz - coincidence: "[PBW](https://prgblockweek.com/) w/ [ETHPrague](https://ethprague.com/)" - lead: Tree - visitors: 180 - links: - web: https://prague.web3privacy.info/ - git: https://github.com/web3privacy/w3ps1 \ No newline at end of file diff --git a/index.js b/index.js index 8db2dce..a4a3833 100644 --- a/index.js +++ b/index.js @@ -24,10 +24,11 @@ async function test() { const schema = await _loadYaml("./schema.yaml"); const validator = ajv.compile(schema); - for (const type of types) { - Deno.test(`Check schema: ${type}`, async () => { - const list = await _loadYaml(`./events/${type}.yaml`); - if (!validator(list)) { + const list = await _loadYaml(`./events/events.yaml`); + + for (const item of list) { + Deno.test(`${item.id}`, async () => { + if (!validator(item)) { throw validator.errors; } }); @@ -35,14 +36,10 @@ async function test() { } async function build() { - const output = {}; - for (const type of types) { - const list = await _loadYaml(`./events/${type}.yaml`); - output[type] = list; - } + const list = await _loadYaml(`./events/events.yaml`); await emptyDir("./dist"); const fn = "./dist/index.json"; - await Deno.writeTextFile(fn, JSON.stringify(output, null, 2)); + await Deno.writeTextFile(fn, JSON.stringify(list, null, 2)); console.log(`File saved: `, fn); const readmeFn = "./README.md" @@ -55,7 +52,7 @@ EDIT "./README.tpl.eta" INSTEAD !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->` - await Deno.writeTextFile(readmeFn, warning + "\n\n" + eta.render("./README.tpl.eta", { events: output, getFlagEmoji })) + await Deno.writeTextFile(readmeFn, warning + "\n\n" + eta.render("./README.tpl.eta", { events: list, getFlagEmoji })) console.log(`File saved: `, readmeFn); } diff --git a/schema.yaml b/schema.yaml index 26f8bff..e898d0c 100644 --- a/schema.yaml +++ b/schema.yaml @@ -1,5 +1,4 @@ -type: array -items: { "$ref": "#/$defs/event" } +$ref: "#/$defs/event" $defs: event: type: object @@ -12,6 +11,11 @@ $defs: properties: id: type: string + type: + type: string + enum: + - summit + - meetup date: type: string city: