From be3825b5a1d328b2fc7c77425046c8b051db6867 Mon Sep 17 00:00:00 2001 From: tree Date: Tue, 28 Nov 2023 03:05:02 +0100 Subject: [PATCH] update --- .github/workflows/deploy.yml | 47 +++++++ Makefile | 13 ++ data/events.yaml | 257 +++++++++++++++++++++++++++++++++++ data/index.yaml | 6 + schema/events.yaml | 55 ++++++++ schema/index.yaml | 1 + utils/build.js | 6 + utils/engine.js | 52 +++++++ utils/test.js | 25 ++++ 9 files changed, 462 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Makefile create mode 100644 data/events.yaml create mode 100644 data/index.yaml create mode 100644 schema/events.yaml create mode 100644 schema/index.yaml create mode 100644 utils/build.js create mode 100644 utils/engine.js create mode 100644 utils/test.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..940b296 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,47 @@ +name: Build and Deploy +on: + push: + branches: + - main # Set a branch to deploy + pull_request: + +permissions: + contents: write +jobs: + build-and-deploy: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - uses: szenius/set-timezone@v1.0 + with: + timezoneLinux: "Europe/Prague" + + - name: Cache + run: make cache + + - name: Test + run: make test + + - name: Build bundle + run: make build + + #- name: Add custom domain + # run: "touch dist/CNAME && echo \"data.web3privacy.info\" >> dist/CNAME" + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6f69019 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +all: build + +cache: + deno cache utils/build.js + +build: + deno run --allow-all utils/build.js + +test: + deno test --allow-all utils/test.js + +fmt: + deno fmt utils/*.js \ No newline at end of file diff --git a/data/events.yaml b/data/events.yaml new file mode 100644 index 0000000..4b65bbf --- /dev/null +++ b/data/events.yaml @@ -0,0 +1,257 @@ +- id: w3ps1 + type: summit + date: "2023-06-05" + city: Prague + country: cz + place: "[X10](https://www.divadlox10.cz/)" + confirmed: true + coincidence: "[ETHPrague](https://ethprague.com/)" + lead: Tree + slots: 16 + visitors: 180 + links: + web: https://prague.web3privacy.info/ + git: https://github.com/web3privacy/w3ps1 + +- id: w3ps2 + type: summit + date: "2023-10-05" + city: Rome + country: it + place: "[Villaggio Globale](https://maps.app.goo.gl/S7kUruNvbpjgHuSh9)" + confirmed: true + coincidence: "[ETHRome](https://ethrome.org/)" + lead: PG + slots: 10 + visitors: 139 + links: + web: https://lu.ma/web3privacynow_rome + +- id: w3pm-prg1 + type: meetup + date: "2023-11-14" + city: Prague + country: cz + place: "[Dílna](https://kafevdilne.cz/)" + confirmed: true + coincidence: "[DCxPrague](https://dcxprague.org/)" + lead: Tree + slots: 3 + visitors: 15 + links: + web: https://lu.ma/w3pm-prg1 + +- id: w3pm-bcn1 + type: meetup + date: "2024/Q1" + city: Barcelona + country: es + coincidence: "" + lead: Tree + helpers: + - Mykola + optional: true + slots: 3 + +- id: w3pm-itxx + type: meetup + date: "2024/Q1" + city: Italy (TBD) + country: it + coincidence: "" + lead: PG + optional: true + slots: 3 + +- id: w3pm-lib1 + type: meetup + date: "2024/Mar" + city: Liberec + country: cz + coincidence: "[ETHBohemia](https://ethbohemia.ethevents.club/)" + lead: Tree + optional: true + slots: 3 + +- id: w3pm-buc1 + type: meetup + date: "2024-03-28" + city: Bucharest + country: ro + # ETHBucharest 2024 - March 28-30 2024 + coincidence: "[ETHBucharest](https://www.ethbucharest.xyz/)" + optional: true + slots: 3 + lead: Tree + helpers: + - Alina + links: + rsvp: https://lu.ma/w3pn-meetup-bucharest1 + +- id: w3pm-ams1 + type: meetup + date: "2024-04-11" + city: Amsterdam + country: nl + lead: PG + helpers: + - Mykola + - Tree + - Alina + # ETHDam 2024 - April 12-14 2024 + coincidence: "[ETHDam](https://www.ethdam.com/)" + slots: 3 + links: + rsvp: https://lu.ma/w3pn-meetup-ams1 + +- id: w3pm-tal1 + type: meetup + date: "2024/Apr" + city: Tallinn + country: ee + # ETHTallinn - April 19 - 21, 2024 + coincidence: "[ETHTallinn](https://www.ethtallinn.org/)" + slots: 3 + optional: true + +- id: w3pm-por1 + type: meetup + date: "2024/May" + city: Porto + country: pt + coincidence: "[ETHPorto](https://ethporto.org/)" + slots: 3 + optional: true + +- id: w3pm-ber1 + type: meetup + date: "2024-05-25" + city: Berlin + country: de + # ETHBerlin 4 - May 24-26, 2024 + coincidence: "ETHBerlin" + lead: Tree + slots: 3 + links: + rsvp: https://lu.ma/w3pn-meetup-berlin1 + +- id: w3ps3 + type: summit + date: "2024-06-04" + city: Prague + country: cz + coincidence: "ETHPrague" + lead: Tree + helpers: + - PG + - Mykola + - Coinmandeer + slots: 16 + links: + rsvp: https://lu.ma/w3pn-summit-prague2 + +- id: w3ph1 + type: hackathon + date: "2024-06-19" + days: 7 + city: Bled + country: si + place: "[Subwork](https://subwork.xyz/)" + confirmed: true + coincidence: "W3PN Hackathon" + lead: Tree + helpers: + - PG + - Mykola + - Coinmandeer + slots: 10 + links: + rsvp: https://lu.ma/w3pn-bled-hackathon1 + +- id: w3pm-lju1 + type: meetup + date: "2024-06-21" + city: Ljubljana + country: si + coincidence: "W3PN Hackathon" + lead: Tree + helpers: + - PG + - Mykola + - Coinmandeer + slots: 5 + links: + rsvp: https://lu.ma/w3pn-meetup-ljubljana1 + +- id: w3pm-bcn2 + type: meetup + date: "2024/Jul" + city: Barcelona + country: es + coincidence: "ETHBarcelona" + slots: 3 + optional: true + +- id: w3pm-bru1 + type: meetup + date: "2024-07-12" + city: Brussels + country: be + # EthCC 7 - July 8-11, 2024 + coincidence: "[EthCC](https://www.ethcc.io/)" + slots: 3 + lead: Mykola + helpers: + - Tree + links: + rsvp: https://lu.ma/w3pn-meetup-bru1 + +- id: w3pm-waw1 + type: meetup + date: "2024/Sep" + city: Warsaw + country: pl + coincidence: "ETHWarsaw" + lead: Tree + slots: 3 + optional: true + +- id: w3pm-rom2 + type: meetup + date: "2024-10-04" + city: Rome + country: it + coincidence: "ETHRome" + lead: PG + slots: 5 + helpers: + - Mykola + - Alina + links: + rsvp: https://lu.ma/w3pn-meetup-rome1 + +- id: w3ps4 + type: summit + date: "2024-10-24" + city: Brno + country: cz + coincidence: "ETHBrno" + lead: Tree + helpers: + - PG + - Mykola + - Coinmandeer + slots: 16 + links: + rsvp: https://lu.ma/w3pn-summit-brno1 + +- id: w3pm-dc1 + type: meetup + date: "2024-11-20" + city: SE Asia + country: xx + # Devcon 7 - probably November (?) + coincidence: "[Devcon](https://devcon.org/)" + slots: 5 + links: + rsvp: https://lu.ma/w3pn-meetup-devcon7 \ No newline at end of file diff --git a/data/index.yaml b/data/index.yaml new file mode 100644 index 0000000..59a2bea --- /dev/null +++ b/data/index.yaml @@ -0,0 +1,6 @@ +name: Web3Privacy Now +core-team: + - name: Tree + - name: Mykola + - name: PG + - name: Coinmandeer \ No newline at end of file diff --git a/schema/events.yaml b/schema/events.yaml new file mode 100644 index 0000000..bfee586 --- /dev/null +++ b/schema/events.yaml @@ -0,0 +1,55 @@ +$defs: + event: + type: object + additionalProperties: false + required: + - id + - date + - city + - country + properties: + id: + type: string + type: + type: string + enum: + - summit + - meetup + - hackathon + confirmed: + type: boolean + date: + type: string + days: + type: number + city: + type: string + country: + type: string + pattern: "^\\w{2}$" + place: + type: string + coincidence: + type: string + lead: + type: string + helpers: + type: array + items: + type: string + slots: + type: number + visitors: + type: number + optional: + type: boolean + links: + type: object + additionalProperties: false + patternProperties: + "^[\\w]+": + type: string + format: uri +type: array +items: + $ref: "#/$defs/event" \ No newline at end of file diff --git a/schema/index.yaml b/schema/index.yaml new file mode 100644 index 0000000..d73ddd1 --- /dev/null +++ b/schema/index.yaml @@ -0,0 +1 @@ +type: object \ No newline at end of file diff --git a/utils/build.js b/utils/build.js new file mode 100644 index 0000000..b1c9ea0 --- /dev/null +++ b/utils/build.js @@ -0,0 +1,6 @@ +import { Engine } from "./engine.js"; + +const engine = new Engine(); +await engine.init(); + +await engine.build(); diff --git a/utils/engine.js b/utils/engine.js new file mode 100644 index 0000000..ef8b389 --- /dev/null +++ b/utils/engine.js @@ -0,0 +1,52 @@ +import { join } from "https://deno.land/std@0.208.0/path/mod.ts"; +import { emptyDir } from "https://deno.land/std@0.196.0/fs/empty_dir.ts"; +import { parse, stringify } from "npm:yaml"; + +const SRC_DIR = "./data"; +const DEST_DIR = "./dist"; +const SCHEMA_DIR = "./schema"; + +export class Engine { + constructor() { + this.index = {}; + this.db = {}; + this.schemas = {}; + } + + async init() { + // load schemas + for await (const dirEntry of Deno.readDir(SCHEMA_DIR)) { + const [fn, _] = dirEntry.name.split("."); + this.schemas[fn] = await readYamlFile(join(SCHEMA_DIR, dirEntry.name)); + } + // load data + this.index = await readYamlFile(join(SRC_DIR, "index.yaml")); + for await (const dirEntry of Deno.readDir(SRC_DIR)) { + const [fn, ext] = dirEntry.name.split("."); + if (ext === "yaml" && fn !== "index") { + this.db[fn] = await readYamlFile(join(SRC_DIR, dirEntry.name)); + } + } + } + + async build() { + await emptyDir(DEST_DIR); + await writeJSONFile(join(DEST_DIR, "index.json"), this.index); + await writeJSONFile( + join(DEST_DIR, "bundle.json"), + Object.assign({}, this.index, this.db), + ); + for (const col of Object.keys(this.db)) { + await writeJSONFile(join(DEST_DIR, `${col}.json`), this.db[col]); + } + } +} + +async function readYamlFile(fn) { + return parse(await Deno.readTextFile(fn)); +} + +async function writeJSONFile(fn, data) { + console.log(`File written: ${fn}`); + return Deno.writeTextFile(fn, JSON.stringify(data, null, 2)); +} diff --git a/utils/test.js b/utils/test.js new file mode 100644 index 0000000..ded3004 --- /dev/null +++ b/utils/test.js @@ -0,0 +1,25 @@ +import Ajv from "npm:ajv@8.8.2"; +import addFormats from "npm:ajv-formats@2.1.1"; + +import { Engine } from "./engine.js"; + +const engine = new Engine(); +await engine.init(); + +const ajv = new Ajv({ strict: false }); +addFormats(ajv); + +function checkCollection (name, schema, data) { + Deno.test(name, () => { + const validator = ajv.compile(schema); + if (!validator(data)) { + throw validator.errors; + } + }) +} + +// check index +checkCollection("index", engine.schemas.index, engine.index) +for (const col of Object.keys(engine.db)) { + checkCollection(`collection: ${col}`, engine.schemas[col], engine.db[col]) +} \ No newline at end of file