Publish schema to gh-pages

This commit is contained in:
tree 2022-01-28 17:07:43 +01:00
rodič d011bf8a79
revize 1a9040e0b0
12 změnil soubory, kde provedl 37 přidání a 11 odebrání

Zobrazit soubor

@ -17,7 +17,7 @@ format:
fmt: format fmt: format
build: build:
deno run --unstable --allow-read --allow-write utils/build.js deno run --unstable --allow-read --allow-write utils/exec.js build
docs-update: docs-update:
deno run --unstable --allow-read --allow-write utils/update-docs.js deno run --unstable --allow-read --allow-write utils/update-docs.js
@ -52,5 +52,8 @@ twitter-photos:
events: events:
deno run --unstable --allow-read utils/events.js deno run --unstable --allow-read utils/events.js
schema:
deno run --unstable --allow-read --allow-write utils/schema.js
server: server:
cd dist && python -m SimpleHTTPServer 8000 cd dist && python -m SimpleHTTPServer 8000

Zobrazit soubor

@ -15,6 +15,7 @@ links:
substack: https://utxoprague.substack.com/ substack: https://utxoprague.substack.com/
instagram: https://www.instagram.com/utxoprague/ instagram: https://www.instagram.com/utxoprague/
youtube: https://www.youtube.com/channel/UCXLBCW1pstQPQf-4zRESepA youtube: https://www.youtube.com/channel/UCXLBCW1pstQPQf-4zRESepA
schemaVersion: 1
specDef: specDef:
- type: speakers - type: speakers
- type: tracks - type: tracks

Zobrazit soubor

@ -1,6 +0,0 @@
import { UTXOEngine } from "./engine.js";
const utxo = new UTXOEngine({ srcDir: "./spec" });
await utxo.init();
await utxo.build("./dist");

Zobrazit soubor

@ -16,6 +16,7 @@ const banner = `
export class UTXOEngine { export class UTXOEngine {
constructor(options = {}) { constructor(options = {}) {
this.options = options; this.options = options;
this.defaultSchemaVersion = "1";
this.srcDir = this.options.srcDir || "./spec"; this.srcDir = this.options.srcDir || "./spec";
if (!this.options.silent) { if (!this.options.silent) {
console.log(banner); console.log(banner);
@ -96,7 +97,7 @@ export class UTXOEngine {
return Object.keys(this.entries); return Object.keys(this.entries);
} }
async build(outputDir) { async build(outputDir = "./dist") {
await emptyDir(outputDir); await emptyDir(outputDir);
const entriesIndex = []; const entriesIndex = [];
@ -148,10 +149,26 @@ export class UTXOEngine {
entriesIndex.push({ entriesIndex.push({
id: `utxo${entryId}`, id: `utxo${entryId}`,
entryId, entryId,
url: `${baseUrl}/${entryId}`, url: `${baseUrl}/${entryId}/`,
schema: `${baseUrl}/schema/${entry.schemaVersion || "1"}/`,
}); });
} }
// write schemas
const schemaVersion = this.defaultSchemaVersion;
const schemas = await this.schemas(schemaVersion);
const outputSchemaDir = [outputDir, "schema", schemaVersion].join("/");
await emptyDir(outputSchemaDir);
console.log(`UTXO: writing schema (v${schemaVersion}) ..`);
for (const schema of schemas) {
await this._jsonWrite(
[outputSchemaDir, schema.name + ".json"],
schema.schema,
);
}
// write global index // write global index
await this._jsonWrite([outputDir, "index.json"], entriesIndex); await this._jsonWrite([outputDir, "index.json"], entriesIndex);
@ -160,8 +177,8 @@ export class UTXOEngine {
} }
} }
async schemas() { async schemas(version = "1") {
const schemaDir = "./utils/schema"; const schemaDir = `./utils/schema/${version}`;
const arr = []; const arr = [];
for await (const f of Deno.readDir(schemaDir)) { for await (const f of Deno.readDir(schemaDir)) {
const m = f.name.match(/^(.+)\.yaml$/); const m = f.name.match(/^(.+)\.yaml$/);

9
utils/exec.js Normal file
Zobrazit soubor

@ -0,0 +1,9 @@
import { UTXOEngine } from "./engine.js";
const utxo = new UTXOEngine();
await utxo.init();
let cmd = Deno.args[0] || "build";
let args = Deno.args.slice(1) || [];
await utxo[cmd](...args);

Zobrazit soubor

@ -34,5 +34,7 @@ properties:
type: type:
type: string type: string
pattern: "[a-z]+" pattern: "[a-z]+"
schemaVersion:
type: number