optolith-database-schema 0.11.1 → 0.11.2

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 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.2](https://github.com/elyukai/optolith-database-schema/compare/v0.11.1...v0.11.2) (2023-05-27)
6
+
5
7
  ### [0.11.1](https://github.com/elyukai/optolith-database-schema/compare/v0.11.0...v0.11.1) (2023-05-27)
6
8
 
7
9
  ## [0.11.0](https://github.com/elyukai/optolith-database-schema/compare/v0.10.1...v0.11.0) (2023-05-27)
package/folders.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export const sourceDir: string
2
+ export const libDir: string
3
+ export const jsonSchemaDir: string
4
+ export const markdownDir: string
package/folders.js ADDED
@@ -0,0 +1,13 @@
1
+ // @ts-check
2
+
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = dirname(fileURLToPath(import.meta.url))
7
+
8
+ const typesDir = main => join(root, main, "types")
9
+
10
+ export const sourceDir = typesDir("src")
11
+ export const libDir = typesDir("lib")
12
+ export const jsonSchemaDir = join(root, "schema")
13
+ export const markdownDir = join(root, "docs", "reference")
@@ -1,6 +1,6 @@
1
1
  import { basename, relative, sep } from "path";
2
2
  import { fileURLToPath } from "url";
3
- import { libDir } from "../../../build/config.js";
3
+ import { libDir } from "../../../folders.js";
4
4
  import { changeFileExtension } from "../../helpers/io.js";
5
5
  import { error, ok } from "../../helpers/result.js";
6
6
  const schemaIdFromSourcePath = (sourcePath) => {
@@ -1,6 +1,7 @@
1
1
  import { readdir } from "fs/promises";
2
2
  import { join } from "path";
3
- import { jsonSchemaDir, jsonSchemaSpec } from "../../build/config.js";
3
+ import { jsonSchemaSpec } from "../../build/config.js";
4
+ import { jsonSchemaDir } from "../../folders.js";
4
5
  import { configMap } from "../config.js";
5
6
  import "../helpers/array.js";
6
7
  import { collator } from "../helpers/i18n.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "optolith-database-schema",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
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",
package/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- * @elyukai
package/build/config.d.ts DELETED
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,19 +0,0 @@
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
package/build/generate.js DELETED
@@ -1,64 +0,0 @@
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
- }