Publish schema to gh-pages
This commit is contained in:
rodič
d011bf8a79
revize
1a9040e0b0
5
Makefile
5
Makefile
|
@ -17,7 +17,7 @@ format:
|
|||
fmt: format
|
||||
|
||||
build:
|
||||
deno run --unstable --allow-read --allow-write utils/build.js
|
||||
deno run --unstable --allow-read --allow-write utils/exec.js build
|
||||
|
||||
docs-update:
|
||||
deno run --unstable --allow-read --allow-write utils/update-docs.js
|
||||
|
@ -52,5 +52,8 @@ twitter-photos:
|
|||
events:
|
||||
deno run --unstable --allow-read utils/events.js
|
||||
|
||||
schema:
|
||||
deno run --unstable --allow-read --allow-write utils/schema.js
|
||||
|
||||
server:
|
||||
cd dist && python -m SimpleHTTPServer 8000
|
||||
|
|
|
@ -15,6 +15,7 @@ links:
|
|||
substack: https://utxoprague.substack.com/
|
||||
instagram: https://www.instagram.com/utxoprague/
|
||||
youtube: https://www.youtube.com/channel/UCXLBCW1pstQPQf-4zRESepA
|
||||
schemaVersion: 1
|
||||
specDef:
|
||||
- type: speakers
|
||||
- type: tracks
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import { UTXOEngine } from "./engine.js";
|
||||
|
||||
const utxo = new UTXOEngine({ srcDir: "./spec" });
|
||||
await utxo.init();
|
||||
|
||||
await utxo.build("./dist");
|
|
@ -16,6 +16,7 @@ const banner = `
|
|||
export class UTXOEngine {
|
||||
constructor(options = {}) {
|
||||
this.options = options;
|
||||
this.defaultSchemaVersion = "1";
|
||||
this.srcDir = this.options.srcDir || "./spec";
|
||||
if (!this.options.silent) {
|
||||
console.log(banner);
|
||||
|
@ -96,7 +97,7 @@ export class UTXOEngine {
|
|||
return Object.keys(this.entries);
|
||||
}
|
||||
|
||||
async build(outputDir) {
|
||||
async build(outputDir = "./dist") {
|
||||
await emptyDir(outputDir);
|
||||
const entriesIndex = [];
|
||||
|
||||
|
@ -148,10 +149,26 @@ export class UTXOEngine {
|
|||
entriesIndex.push({
|
||||
id: `utxo${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
|
||||
await this._jsonWrite([outputDir, "index.json"], entriesIndex);
|
||||
|
||||
|
@ -160,8 +177,8 @@ export class UTXOEngine {
|
|||
}
|
||||
}
|
||||
|
||||
async schemas() {
|
||||
const schemaDir = "./utils/schema";
|
||||
async schemas(version = "1") {
|
||||
const schemaDir = `./utils/schema/${version}`;
|
||||
const arr = [];
|
||||
for await (const f of Deno.readDir(schemaDir)) {
|
||||
const m = f.name.match(/^(.+)\.yaml$/);
|
||||
|
|
|
@ -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);
|
|
@ -34,5 +34,7 @@ properties:
|
|||
type:
|
||||
type: string
|
||||
pattern: "[a-z]+"
|
||||
schemaVersion:
|
||||
type: number
|
||||
|
||||
|
Načítá se…
Odkázat v novém úkolu