mirror of
https://github.com/web3privacy/data
synced 2024-10-15 18:16:28 +02:00
refactor
This commit is contained in:
parent
be3825b5a1
commit
0e83c3897f
7 changed files with 64 additions and 29 deletions
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
all: build
|
all: test build
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
deno cache utils/build.js
|
deno cache utils/build.js
|
||||||
|
|
|
@ -41,25 +41,13 @@
|
||||||
links:
|
links:
|
||||||
web: https://lu.ma/w3pm-prg1
|
web: https://lu.ma/w3pm-prg1
|
||||||
|
|
||||||
- id: w3pm-bcn1
|
- id: w3pm-ath1
|
||||||
type: meetup
|
type: meetup
|
||||||
date: "2024/Q1"
|
date: "2024/Q1"
|
||||||
city: Barcelona
|
city: Athens
|
||||||
country: es
|
country: gr
|
||||||
coincidence: ""
|
coincidence: ""
|
||||||
lead: Tree
|
lead: Mykola
|
||||||
helpers:
|
|
||||||
- Mykola
|
|
||||||
optional: true
|
|
||||||
slots: 3
|
|
||||||
|
|
||||||
- id: w3pm-itxx
|
|
||||||
type: meetup
|
|
||||||
date: "2024/Q1"
|
|
||||||
city: Italy (TBD)
|
|
||||||
country: it
|
|
||||||
coincidence: ""
|
|
||||||
lead: PG
|
|
||||||
optional: true
|
optional: true
|
||||||
slots: 3
|
slots: 3
|
||||||
|
|
||||||
|
@ -125,9 +113,10 @@
|
||||||
|
|
||||||
- id: w3pm-ber1
|
- id: w3pm-ber1
|
||||||
type: meetup
|
type: meetup
|
||||||
date: "2024-05-25"
|
date: "2024-05-22"
|
||||||
city: Berlin
|
city: Berlin
|
||||||
country: de
|
country: de
|
||||||
|
place: "[c-base](https://c-base.org/)"
|
||||||
# ETHBerlin 4 - May 24-26, 2024
|
# ETHBerlin 4 - May 24-26, 2024
|
||||||
coincidence: "ETHBerlin"
|
coincidence: "ETHBerlin"
|
||||||
lead: Tree
|
lead: Tree
|
||||||
|
@ -137,9 +126,10 @@
|
||||||
|
|
||||||
- id: w3ps3
|
- id: w3ps3
|
||||||
type: summit
|
type: summit
|
||||||
date: "2024-06-04"
|
date: "2024-05-30"
|
||||||
city: Prague
|
city: Prague
|
||||||
country: cz
|
country: cz
|
||||||
|
# ETHPrague 2024 - May 31-June 2 2024
|
||||||
coincidence: "ETHPrague"
|
coincidence: "ETHPrague"
|
||||||
lead: Tree
|
lead: Tree
|
||||||
helpers:
|
helpers:
|
|
@ -3,4 +3,8 @@ core-team:
|
||||||
- name: Tree
|
- name: Tree
|
||||||
- name: Mykola
|
- name: Mykola
|
||||||
- name: PG
|
- name: PG
|
||||||
- name: Coinmandeer
|
- name: Coinmandeer
|
||||||
|
projects:
|
||||||
|
$load: projects
|
||||||
|
events:
|
||||||
|
$load: events
|
1
src/projects/pagency/index.yaml
Normal file
1
src/projects/pagency/index.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
name: Pagency
|
|
@ -4,3 +4,5 @@ const engine = new Engine();
|
||||||
await engine.init();
|
await engine.init();
|
||||||
|
|
||||||
await engine.build();
|
await engine.build();
|
||||||
|
|
||||||
|
console.log('Done')
|
|
@ -1,8 +1,9 @@
|
||||||
import { join } from "https://deno.land/std@0.208.0/path/mod.ts";
|
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 { emptyDir } from "https://deno.land/std@0.196.0/fs/empty_dir.ts";
|
||||||
import { parse, stringify } from "npm:yaml";
|
import { parse, stringify } from "npm:yaml";
|
||||||
|
import { exists } from "https://deno.land/std@0.213.0/fs/exists.ts";
|
||||||
|
|
||||||
const SRC_DIR = "./data";
|
const SRC_DIR = "./src";
|
||||||
const DEST_DIR = "./dist";
|
const DEST_DIR = "./dist";
|
||||||
const SCHEMA_DIR = "./schema";
|
const SCHEMA_DIR = "./schema";
|
||||||
|
|
||||||
|
@ -19,26 +20,60 @@ export class Engine {
|
||||||
const [fn, _] = dirEntry.name.split(".");
|
const [fn, _] = dirEntry.name.split(".");
|
||||||
this.schemas[fn] = await readYamlFile(join(SCHEMA_DIR, dirEntry.name));
|
this.schemas[fn] = await readYamlFile(join(SCHEMA_DIR, dirEntry.name));
|
||||||
}
|
}
|
||||||
// load data
|
// load
|
||||||
this.index = await readYamlFile(join(SRC_DIR, "index.yaml"));
|
this.index = await readYamlFile(join(SRC_DIR, "index.yaml"));
|
||||||
for await (const dirEntry of Deno.readDir(SRC_DIR)) {
|
this.rendered = await this.render(this.index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadDir(src) {
|
||||||
|
const out = {}
|
||||||
|
const dir = join(SRC_DIR, src)
|
||||||
|
console.log(`reading dir=${dir}`)
|
||||||
|
|
||||||
|
if (await exists(join(dir, "index.yaml"))) {
|
||||||
|
const out = readYamlFile(join(dir, "index.yaml"));
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
for await (const dirEntry of Deno.readDir(dir)) {
|
||||||
const [fn, ext] = dirEntry.name.split(".");
|
const [fn, ext] = dirEntry.name.split(".");
|
||||||
|
|
||||||
|
if (!ext) {
|
||||||
|
out[fn] = await this.loadDir(join(src, fn))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ext === "yaml" && fn !== "index") {
|
if (ext === "yaml" && fn !== "index") {
|
||||||
this.db[fn] = await readYamlFile(join(SRC_DIR, dirEntry.name));
|
out[fn] = await readYamlFile(join(dir, dirEntry.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(src) {
|
||||||
|
const out = {}
|
||||||
|
for (const key of Object.keys(src)) {
|
||||||
|
const val = src[key];
|
||||||
|
if (typeof val === "object" && val.$load) {
|
||||||
|
out[key] = await this.loadDir(val.$load);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
out[key] = val
|
||||||
|
}
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
async build() {
|
async build() {
|
||||||
await emptyDir(DEST_DIR);
|
await emptyDir(DEST_DIR);
|
||||||
await writeJSONFile(join(DEST_DIR, "index.json"), this.index);
|
//await writeJSONFile(join(DEST_DIR, "index.json"), this.index);
|
||||||
await writeJSONFile(
|
await writeJSONFile(
|
||||||
join(DEST_DIR, "bundle.json"),
|
join(DEST_DIR, "index.json"),
|
||||||
Object.assign({}, this.index, this.db),
|
Object.assign({}, this.rendered),
|
||||||
);
|
);
|
||||||
for (const col of Object.keys(this.db)) {
|
/*for (const col of Object.keys(this.db)) {
|
||||||
await writeJSONFile(join(DEST_DIR, `${col}.json`), this.db[col]);
|
await writeJSONFile(join(DEST_DIR, `${col}.json`), this.db[col]);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ addFormats(ajv);
|
||||||
|
|
||||||
function checkCollection (name, schema, data) {
|
function checkCollection (name, schema, data) {
|
||||||
Deno.test(name, () => {
|
Deno.test(name, () => {
|
||||||
|
if (!schema) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const validator = ajv.compile(schema);
|
const validator = ajv.compile(schema);
|
||||||
if (!validator(data)) {
|
if (!validator(data)) {
|
||||||
throw validator.errors;
|
throw validator.errors;
|
||||||
|
|
Loading…
Reference in a new issue