okforest 0.6.2 → 0.8.0
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/dist/cli.mjs +9 -18
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { parseArgs, styleText } from "node:util";
|
|
|
7
7
|
import { buildInventory } from "@okforest/okf";
|
|
8
8
|
import { readTree } from "@okforest/okf/node";
|
|
9
9
|
import { defaultRules, okfRules, ruleDocs, ruleUrl, toReport, validate } from "@okforest/validate";
|
|
10
|
-
|
|
10
|
+
// src/io.ts
|
|
11
11
|
/** Exit codes: 0 success, 1 validation errors, 2 usage or read problems. */
|
|
12
12
|
const EXIT = {
|
|
13
13
|
ok: 0,
|
|
@@ -22,8 +22,7 @@ function paint(io, style, text) {
|
|
|
22
22
|
const packageRoot = new URL("../", import.meta.url);
|
|
23
23
|
const VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
24
24
|
const TEMPLATES_DIR = new URL("templates/", packageRoot);
|
|
25
|
-
|
|
26
|
-
//#region src/args.ts
|
|
25
|
+
// src/args.ts
|
|
27
26
|
/** Parse a command's arguments: options plus at most one positional path. */
|
|
28
27
|
function parseCommand(args, options) {
|
|
29
28
|
const { values, positionals } = parseArgs({
|
|
@@ -49,8 +48,7 @@ function formatOption(value) {
|
|
|
49
48
|
if (value === "json") return "json";
|
|
50
49
|
throw new UsageError(`--format must be \`text\` or \`json\` (got \`${String(value)}\`).`);
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
//#region src/commands/init.ts
|
|
51
|
+
// src/commands/init.ts
|
|
54
52
|
const HELP$4 = `Usage: okforest init [path] --template <name> [--name <name>]
|
|
55
53
|
|
|
56
54
|
Create a new OKF v0.2 tree at path (default: the current directory, which must
|
|
@@ -125,8 +123,7 @@ function slug(value) {
|
|
|
125
123
|
function capitalize(value) {
|
|
126
124
|
return value.charAt(0).toUpperCase() + value.slice(1).replaceAll("-", " ");
|
|
127
125
|
}
|
|
128
|
-
|
|
129
|
-
//#region src/tree.ts
|
|
126
|
+
// src/tree.ts
|
|
130
127
|
/** Read the tree at a user-supplied path, or explain why not. */
|
|
131
128
|
async function loadTree(path, io) {
|
|
132
129
|
const dir = resolve(io.cwd, path);
|
|
@@ -139,8 +136,7 @@ async function loadTree(path, io) {
|
|
|
139
136
|
throw new UsageError(`Could not read ${path}: ${error.message}`);
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
|
-
|
|
143
|
-
//#region src/commands/inventory.ts
|
|
139
|
+
// src/commands/inventory.ts
|
|
144
140
|
const HELP$3 = `Usage: okforest inventory [path] [--format text|json]
|
|
145
141
|
|
|
146
142
|
List every type, tag, and frontmatter key in use in the tree at path (default:
|
|
@@ -197,8 +193,7 @@ function inventoryText(inventory, io) {
|
|
|
197
193
|
}
|
|
198
194
|
return `${out.join("\n")}\n`;
|
|
199
195
|
}
|
|
200
|
-
|
|
201
|
-
//#region src/commands/rule.ts
|
|
196
|
+
// src/commands/rule.ts
|
|
202
197
|
const HELP$2 = `Usage: okforest rule [rule] [--format text|json]
|
|
203
198
|
|
|
204
199
|
Explain a rule: why it exists, an example that breaks it, what
|
|
@@ -361,8 +356,7 @@ function edits(a, b) {
|
|
|
361
356
|
}
|
|
362
357
|
return previous[b.length];
|
|
363
358
|
}
|
|
364
|
-
|
|
365
|
-
//#region src/commands/validate.ts
|
|
359
|
+
// src/commands/validate.ts
|
|
366
360
|
const HELP$1 = `Usage: okforest validate [path] [--format text|json]
|
|
367
361
|
|
|
368
362
|
Check the OKF v0.2 tree at path (default: the current directory) against the
|
|
@@ -439,8 +433,7 @@ function summary(result, io) {
|
|
|
439
433
|
const counts = `${plural(result.errors, "error")}, ${plural(result.warnings, "warning")}, ${result.infos} info`;
|
|
440
434
|
return result.ok ? `${paint(io, "green", "✔")} ${counts} · ${scope}` : `${paint(io, "red", "✖")} ${counts} · ${scope}`;
|
|
441
435
|
}
|
|
442
|
-
|
|
443
|
-
//#region src/main.ts
|
|
436
|
+
// src/main.ts
|
|
444
437
|
const HELP = `okforest ${VERSION}: validate, inventory, and scaffold Open Knowledge Format (OKF) v0.2 trees
|
|
445
438
|
|
|
446
439
|
Usage
|
|
@@ -500,8 +493,7 @@ function isArgsError(error) {
|
|
|
500
493
|
const code = error?.code;
|
|
501
494
|
return typeof code === "string" && code.startsWith("ERR_PARSE_ARGS_");
|
|
502
495
|
}
|
|
503
|
-
|
|
504
|
-
//#region src/cli.ts
|
|
496
|
+
// src/cli.ts
|
|
505
497
|
const env = process.env;
|
|
506
498
|
const color = env.FORCE_COLOR !== void 0 ? env.FORCE_COLOR !== "0" : Boolean(process.stdout.isTTY) && env.NO_COLOR === void 0 && env.TERM !== "dumb";
|
|
507
499
|
process.exitCode = await main(process.argv.slice(2), {
|
|
@@ -510,5 +502,4 @@ process.exitCode = await main(process.argv.slice(2), {
|
|
|
510
502
|
color,
|
|
511
503
|
cwd: process.cwd()
|
|
512
504
|
});
|
|
513
|
-
//#endregion
|
|
514
505
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okforest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "The OKForest CLI: validate Open Knowledge Format (OKF) v0.2 trees, inventory their metadata, and scaffold new trees from templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"okf",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"node": ">=22"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@okforest/okf": "0.
|
|
36
|
-
"@okforest/validate": "0.
|
|
35
|
+
"@okforest/okf": "0.8.0",
|
|
36
|
+
"@okforest/validate": "0.8.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^26.6.
|
|
39
|
+
"@types/node": "^26.6.6",
|
|
40
40
|
"@vitest/coverage-v8": "^5.0.5",
|
|
41
|
-
"tsdown": "^0.23.
|
|
41
|
+
"tsdown": "^0.23.4",
|
|
42
42
|
"typescript": "^7.0.2",
|
|
43
43
|
"vitest": "^5.0.5"
|
|
44
44
|
},
|