optolith-database-schema 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/config.d.ts +11 -0
- package/build/config.js +19 -0
- package/build/generate.js +64 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.11.1](https://github.com/elyukai/optolith-database-schema/compare/v0.11.0...v0.11.1) (2023-05-27)
|
|
6
|
+
|
|
5
7
|
## [0.11.0](https://github.com/elyukai/optolith-database-schema/compare/v0.10.1...v0.11.0) (2023-05-27)
|
|
6
8
|
|
|
7
9
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JsonSchemaSpec } from "optolith-tsjsonschemamd/renderers"
|
|
2
|
+
|
|
3
|
+
export const sourceDir: string
|
|
4
|
+
export const libDir: string
|
|
5
|
+
export const jsonSchemaDir: string
|
|
6
|
+
export const markdownDir: string
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The JSON Schema specification to use.
|
|
10
|
+
*/
|
|
11
|
+
export const jsonSchemaSpec: JsonSchemaSpec
|
package/build/config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { JsonSchemaSpec } from "optolith-tsjsonschemamd/renderers";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..")
|
|
8
|
+
|
|
9
|
+
const typesDir = main => join(root, main, "types")
|
|
10
|
+
|
|
11
|
+
export const sourceDir = typesDir("src")
|
|
12
|
+
export const libDir = typesDir("lib")
|
|
13
|
+
export const jsonSchemaDir = join(root, "schema")
|
|
14
|
+
export const markdownDir = join(root, "docs", "reference")
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {import("optolith-tsjsonschemamd/renderers").JsonSchemaSpec}
|
|
18
|
+
*/
|
|
19
|
+
export const jsonSchemaSpec = JsonSchemaSpec.Draft_2019_09
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { watch } from "fs/promises"
|
|
4
|
+
import { generate } from "optolith-tsjsonschemamd"
|
|
5
|
+
import { jsonSchema, markdown } from "optolith-tsjsonschemamd/renderers"
|
|
6
|
+
import { jsonSchemaDir, jsonSchemaSpec, markdownDir, sourceDir } from "./config.js"
|
|
7
|
+
|
|
8
|
+
/** @type {import("optolith-tsjsonschemamd").GeneratorOptions} */
|
|
9
|
+
const options = {
|
|
10
|
+
sourceDir: sourceDir,
|
|
11
|
+
outputs: [
|
|
12
|
+
{
|
|
13
|
+
targetDir: jsonSchemaDir,
|
|
14
|
+
renderer: jsonSchema({ spec: jsonSchemaSpec }),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
targetDir: markdownDir,
|
|
18
|
+
renderer: markdown,
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
clean: true,
|
|
22
|
+
verbose: false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (process.argv.includes("-w")) {
|
|
26
|
+
try {
|
|
27
|
+
generate(options)
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
console.error(err)
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
console.log("Watching for changes ...")
|
|
34
|
+
|
|
35
|
+
const generate$ = debounce(generate, 300)
|
|
36
|
+
|
|
37
|
+
for await (const _ of watch(sourceDir, { recursive: true })) {
|
|
38
|
+
try {
|
|
39
|
+
generate$(options)
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error(err)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
generate(options)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @template {any[]} T
|
|
54
|
+
* @param {(...args: T) => void} f
|
|
55
|
+
* @param {number} timeout
|
|
56
|
+
* @returns {(...args: T) => void}
|
|
57
|
+
*/
|
|
58
|
+
function debounce(f, timeout) {
|
|
59
|
+
let timer;
|
|
60
|
+
return (...args) => {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
timer = setTimeout(() => { f.apply(this, args); }, timeout);
|
|
63
|
+
}
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "optolith-database-schema",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Definitions and utilities for the flat-file database of Optolith, a character creation tool for the Pen and Paper RPG “The Dark Eye 5”, and its external integrations into other software.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tde",
|