From dd13463b6e8c0714fbac4b2d7cf3b733d0a9662a Mon Sep 17 00:00:00 2001 From: tree Date: Sat, 21 Jan 2023 22:07:27 +0100 Subject: [PATCH] Preparations (1) --- Makefile | 17 ++++++++ README.md | 6 ++- .../{ethprague.toml => ethprague/index.toml} | 0 data/23/events/utxo/index.toml | 1 + data/23/index.toml | 1 + utils/engine.js | 40 +++++++++++++++++++ utils/exec.js | 12 ++++++ utils/test.js | 0 8 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 Makefile rename data/23/events/{ethprague.toml => ethprague/index.toml} (100%) create mode 100644 data/23/events/utxo/index.toml create mode 100644 data/23/index.toml create mode 100644 utils/engine.js create mode 100644 utils/exec.js create mode 100644 utils/test.js diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bee2cda --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: all build + +all: test build + +test: + deno test --unstable --allow-read utils/test.js + +link-check: + lychee spec/**/*.yaml + +format: + deno fmt utils/*.js README.md + +fmt: format + +build: + deno run --unstable --allow-read --allow-write utils/exec.js build \ No newline at end of file diff --git a/README.md b/README.md index c6ade85..2b366a4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ - # Prague Blockchain Week (PBW) +# Prague Blockchain Week (PBW) - A decentralized conference hosted by [UTXO Foundation](https://utxo.foundation/). We are using this GitHub repository to coordinate event listings. +A decentralized conference hosted by +[UTXO Foundation](https://utxo.foundation/). We are using this GitHub repository +to coordinate event listings. https://prgblockweek.com diff --git a/data/23/events/ethprague.toml b/data/23/events/ethprague/index.toml similarity index 100% rename from data/23/events/ethprague.toml rename to data/23/events/ethprague/index.toml diff --git a/data/23/events/utxo/index.toml b/data/23/events/utxo/index.toml new file mode 100644 index 0000000..b277901 --- /dev/null +++ b/data/23/events/utxo/index.toml @@ -0,0 +1 @@ +name = "UTXO.23" \ No newline at end of file diff --git a/data/23/index.toml b/data/23/index.toml new file mode 100644 index 0000000..80f54bd --- /dev/null +++ b/data/23/index.toml @@ -0,0 +1 @@ +name = "Prague Blockchain Week 2023" \ No newline at end of file diff --git a/utils/engine.js b/utils/engine.js new file mode 100644 index 0000000..425cf5a --- /dev/null +++ b/utils/engine.js @@ -0,0 +1,40 @@ +import { parse as tomlParse } from "https://deno.land/std@0.173.0/encoding/toml.ts"; + +export class DeConfEngine { + constructor(options = {}) { + this.options = options; + this.srcDir = this.options.srcDir || "./data"; + } + async init() {} + async build() { + this.entries = {}; + for await (const f of Deno.readDir(this.srcDir)) { + if (!f.name.match(/^\d+$/)) { + continue; + } + const specDir = [this.srcDir, f.name].join("/"); + + const entry = this.entries[f.name] = {}; + // load year index + entry.index = await this._tomlLoad([specDir, "index.toml"].join("/")); + console.log(`\n##\n## [${entry.index.name}] \n##`); + // load sub-events + entry.events = []; + for await (const ef of Deno.readDir([specDir, "events"].join("/"))) { + if (!ef.name.match(/^[\w\d\-]+$/)) { + continue; + } + const efDir = [specDir, "events", ef.name].join("/"); + const efIndex = await this._tomlLoad([efDir, "index.toml"].join("/")); + const event = { + index: efIndex, + }; + entry.events.push(event); + } + console.table(entry.events.map((e) => e.index), ["name"]); + } + } + async _tomlLoad(fn) { + return tomlParse(await Deno.readTextFile(fn)); + } +} diff --git a/utils/exec.js b/utils/exec.js new file mode 100644 index 0000000..26c8fdb --- /dev/null +++ b/utils/exec.js @@ -0,0 +1,12 @@ +import { DeConfEngine } from "./engine.js"; + +const deconf = new DeConfEngine(); +await deconf.init(); + +let cmd = Deno.args[0] || "build"; +let args = Deno.args.slice(1) || []; + +const output = await deconf[cmd](...args); +if (output) { + console.log(output); +} diff --git a/utils/test.js b/utils/test.js new file mode 100644 index 0000000..e69de29