okforest 0.17.0 → 0.18.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +4 -9
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  import { access, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, join, posix, resolve } from "node:path";
5
5
  import { parseArgs, styleText } from "node:util";
6
- import { TYPES_FOLDER, buildInventory, startPage } from "@okforest/okf";
6
+ import { TYPES_FOLDER, buildInventory, startPage, typeSlug } from "@okforest/okf";
7
7
  import { readTree } from "@okforest/okf/node";
8
8
  import { defaultRules, draftTypeSchema, okfRules, ruleDocs as ruleDocs$1, ruleUrl, toReport, validate } from "@okforest/validate";
9
9
  // src/io.ts
@@ -322,7 +322,7 @@ async function initCommand(args, io) {
322
322
  const target = resolve(io.cwd, path);
323
323
  const blocking = (await readdir(target).catch(() => [])).filter((name) => name !== ".git" && name !== ".DS_Store");
324
324
  if (blocking.length > 0) throw new UsageError(`${path} is not empty (${blocking.slice(0, 3).join(", ")}${blocking.length > 3 ? ", ..." : ""}).`);
325
- const name = typeof values.name === "string" ? values.name.trim() : `${capitalize(slug$1(basename(target).replace(/-(okf|knowledge)$/, "")) || "company")} knowledge`;
325
+ const name = typeof values.name === "string" ? values.name.trim() : `${capitalize(slug(basename(target).replace(/-(okf|knowledge)$/, "")) || "company")} knowledge`;
326
326
  if (name === "" || [...name].length > 100) throw new UsageError(`--name must be 1 to 100 characters (got ${[...name].length.toLocaleString("en-US")}).`);
327
327
  const files = starterFiles(name, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
328
328
  for (const [rel, text] of Object.entries(files)) {
@@ -338,7 +338,7 @@ For a company's tree, with its folders, types, and starter concepts, start from
338
338
  https://github.com/${COMPANY_TEMPLATE} instead.\n`);
339
339
  return EXIT.ok;
340
340
  }
341
- function slug$1(value) {
341
+ function slug(value) {
342
342
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
343
343
  }
344
344
  function capitalize(value) {
@@ -818,7 +818,7 @@ async function typesInit(args, io) {
818
818
  let drafted = 0;
819
819
  for (const type of wanted) {
820
820
  const concepts = byType.get(type);
821
- const file = `${TYPES_FOLDER}${slug(type)}.schema.json`;
821
+ const file = `${TYPES_FOLDER}${typeSlug(type)}.schema.json`;
822
822
  if (schemas.has(type)) {
823
823
  lines.push(` skipped ${type}: it has a schema already`);
824
824
  continue;
@@ -848,11 +848,6 @@ async function typesInit(args, io) {
848
848
  io.stdout(`${verb} ${drafted} type ${drafted === 1 ? "schema" : "schemas"} in ${path}.\n` + (lines.length > 0 ? `${lines.join("\n")}\n` : "") + (drafted > 0 && !values["dry-run"] ? `\nNext: review each draft, then check the tree with \`okforest validate ${path}\`.\n` : ""));
849
849
  return EXIT.ok;
850
850
  }
851
- /** `BigQuery Table` → `bigquery-table`, `顧客` → `顧客`; `type` when no
852
- * letter or digit is left. */
853
- function slug(type) {
854
- return type.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "") || "type";
855
- }
856
851
  // src/main.ts
857
852
  const HELP = `okforest ${VERSION}: validate, inventory, and scaffold Open Knowledge Format (OKF) trees
858
853
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okforest",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "description": "The OKForest CLI: validate Open Knowledge Format (OKF) trees, 0.2 and 0.3, inventory their metadata, and scaffold new trees and pages.",
5
5
  "keywords": [
6
6
  "okf",
@@ -31,8 +31,8 @@
31
31
  "node": ">=22"
32
32
  },
33
33
  "dependencies": {
34
- "@okforest/okf": "0.17.0",
35
- "@okforest/validate": "0.17.0"
34
+ "@okforest/okf": "0.18.1",
35
+ "@okforest/validate": "0.18.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^26.6.6",