diffwiki 0.11.0 → 0.12.0-rc.202608011809.0c68acd
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/bin.js +38 -8
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getConfigValue,
|
|
14
14
|
initRepoWiki,
|
|
15
15
|
installPlugin,
|
|
16
|
+
lintCollections,
|
|
16
17
|
listCollections as listCollections2,
|
|
17
18
|
listAvailablePlugins,
|
|
18
19
|
listPlugins,
|
|
@@ -312,9 +313,9 @@ async function addExternalAction(opts) {
|
|
|
312
313
|
console.log(`Added "${entry.name}"${branch} \u2192 ${entry.path}`);
|
|
313
314
|
console.log("Registered globally \u2014 discoverable via: diffwiki collection list");
|
|
314
315
|
}
|
|
315
|
-
async function createCollectionAction(name) {
|
|
316
|
-
const entry = await createCollection(name);
|
|
317
|
-
console.log(`Created collection "${entry.name}" at ${entry.path}`);
|
|
316
|
+
async function createCollectionAction(name, opts) {
|
|
317
|
+
const entry = await createCollection(name, opts.hidden ? { audience: "system" } : void 0);
|
|
318
|
+
console.log(`Created ${entry.audience === "system" ? "hidden " : ""}collection "${entry.name}" at ${entry.path}`);
|
|
318
319
|
}
|
|
319
320
|
async function createArticleAction(target, opts) {
|
|
320
321
|
const article = await createArticle({
|
|
@@ -361,7 +362,12 @@ async function indexAction(opts) {
|
|
|
361
362
|
console.log(`Indexed ${indexed} document(s).`);
|
|
362
363
|
}
|
|
363
364
|
async function queryAction(term, opts) {
|
|
364
|
-
const
|
|
365
|
+
const names = opts.collection ? opts.collection.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
|
|
366
|
+
const queryOpts = {
|
|
367
|
+
engine: opts.engine,
|
|
368
|
+
collection: names && names.length === 1 ? names[0] : names,
|
|
369
|
+
type: opts.type
|
|
370
|
+
};
|
|
365
371
|
const outcome = await search(term, queryOpts);
|
|
366
372
|
const hits = outcome.hits;
|
|
367
373
|
console.log(`${hits.length} result(s)`);
|
|
@@ -459,6 +465,21 @@ async function doctorAction() {
|
|
|
459
465
|
process.exitCode = 1;
|
|
460
466
|
}
|
|
461
467
|
}
|
|
468
|
+
async function lintAction(opts) {
|
|
469
|
+
const result = await lintCollections(opts.collections);
|
|
470
|
+
for (const file of result.files) {
|
|
471
|
+
if (file.findings.length === 0) {
|
|
472
|
+
console.log(`\u2713 ${file.path}`);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
for (const f of file.findings) {
|
|
476
|
+
console.log(`${f.level === "error" ? "\u2716" : "!"} ${file.path}: ${f.message}`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
console.log(`
|
|
480
|
+
${result.fileCount} file(s), ${result.errorCount} error(s), ${result.warnCount} warning(s)`);
|
|
481
|
+
if (result.errorCount > 0) process.exitCode = 1;
|
|
482
|
+
}
|
|
462
483
|
async function upAction(opts) {
|
|
463
484
|
const existing = await readState();
|
|
464
485
|
if (existing && isAlive(existing.pid)) {
|
|
@@ -527,13 +548,21 @@ function createProgram() {
|
|
|
527
548
|
});
|
|
528
549
|
const collection = program.command("collection").description("Manage collections (containers)");
|
|
529
550
|
collection.command("list").description("List all collections").action(withErrors(listCollectionsAction));
|
|
530
|
-
collection.command("create").description("Create a new global collection").argument("<name>", "collection name").action(withErrors((name) => createCollectionAction(name)));
|
|
551
|
+
collection.command("create").description("Create a new global collection").argument("<name>", "collection name").option("--hidden", "create as a hidden system collection (audience: system)").action(withErrors((name, opts) => createCollectionAction(name, opts)));
|
|
531
552
|
collection.command("add").description("Add the current git repo as an external collection (docs dir, no diffwiki.yaml)").option("-d, --docs <dir>", "content dir relative to repo root", "docs").action(withErrors((opts) => addExternalAction(opts)));
|
|
532
553
|
collection.command("init").description("Initialize an in-repo wiki and register it globally").option("-c, --collection <name>", "collection name (default: repo name)").option("-p, --path <path>", "wiki path within the repo (default: wiki)").action(withErrors((opts) => initAction(opts)));
|
|
533
554
|
collection.command("edit").description("Open a collection in your editor \u2014 GUI not required").argument("[name]", "collection (default: the current repo collection)").option("--editor <cmd>", "editor command (overrides config `editor`, $VISUAL, $EDITOR)").action(withErrors((name, opts) => editAction(name, opts.editor)));
|
|
534
555
|
const article = program.command("article").description("Manage articles (documents)");
|
|
535
|
-
article.command("create").description("Add an article to a collection").argument("<target>", '"[collection:]title"').option("-b, --body <markdown>", 'article body (default: a "# <title>" heading)').option("-t, --tag <tag>", "tag (repeatable, comma-separated)", collect, []).addOption(
|
|
536
|
-
|
|
556
|
+
article.command("create").description("Add an article to a collection").argument("<target>", '"[collection:]title"').option("-b, --body <markdown>", 'article body (default: a "# <title>" heading)').option("-t, --tag <tag>", "tag (repeatable, comma-separated)", collect, []).addOption(
|
|
557
|
+
new Option("--audience <audience>", "visibility (default: public)").choices(["public", "private", "system"])
|
|
558
|
+
).addOption(
|
|
559
|
+
new Option("--status <status>", "publish status (default: published)").choices([
|
|
560
|
+
"draft",
|
|
561
|
+
"published",
|
|
562
|
+
"deprecated"
|
|
563
|
+
])
|
|
564
|
+
).action(withErrors((target, opts) => createArticleAction(target, opts)));
|
|
565
|
+
article.command("update").description("Update an article's body, tags, audience, and/or status").argument("<target>", '"collection:slug"').option("-b, --body <markdown>", "replace the article body").option("-t, --tag <tag>", "replace all tags (repeatable, comma-separated)", collect, []).addOption(new Option("--audience <audience>", "set visibility").choices(["public", "private", "system"])).addOption(new Option("--status <status>", "set publish status").choices(["draft", "published", "deprecated"])).action(withErrors((target, opts) => updateArticleAction(target, opts)));
|
|
537
566
|
article.command("remove").description("Delete an article").argument("<target>", '"collection:slug"').action(withErrors((target) => removeArticleAction(target)));
|
|
538
567
|
article.command("edit").description("Open an article in your editor \u2014 GUI not required").argument("<target>", '"collection:slug"').option("--editor <cmd>", "editor command (overrides config `editor`, $VISUAL, $EDITOR)").action(withErrors((target, opts) => editAction(target, opts.editor)));
|
|
539
568
|
const tags = program.command("tags").description("Manage an article's tags");
|
|
@@ -544,7 +573,7 @@ function createProgram() {
|
|
|
544
573
|
registerTagsSub("remove", "Remove from an article's tags", removeTags);
|
|
545
574
|
registerTagsSub("set", "Replace an article's tags", setTags);
|
|
546
575
|
const searchCmd = program.command("search").description("Search articles and manage the index");
|
|
547
|
-
searchCmd.command("query").alias("q").description("Search articles via the resolved search engine (native fallback if none)").option("--engine <name>", "search engine/plugin (default: config defaultSearch, else native)").option("-c, --collection <
|
|
576
|
+
searchCmd.command("query").alias("q").description("Search articles via the resolved search engine (native fallback if none)").option("--engine <name>", "search engine/plugin (default: config defaultSearch, else native)").option("-c, --collection <names>", "limit to a collection (comma-separated for a set)").option("-t, --type <type>", "search type (engine-defined, e.g. keyword|semantic|hybrid)").argument("[term]", "search term", "").action(
|
|
548
577
|
withErrors(
|
|
549
578
|
(term, opts) => queryAction(term, opts)
|
|
550
579
|
)
|
|
@@ -575,6 +604,7 @@ function createProgram() {
|
|
|
575
604
|
config.command("set").description("Set a config value (e.g. defaultCollection, or defaultSearch <engine[:type]>)").argument("<key>", "config key").argument("<value>", "config value").action(withErrors((key, value) => configSetAction(key, value)));
|
|
576
605
|
config.command("get").description("Read a config value").argument("<key>", "config key").action(withErrors((key) => configGetAction(key)));
|
|
577
606
|
program.command("doctor").description("Diagnose configuration issues").action(withErrors(doctorAction));
|
|
607
|
+
program.command("lint").description("Lint articles against the template shapes (frontmatter, budgets, references)").option("-c, --collections <scope>", "current | all | comma-separated names", "current").action(withErrors((opts) => lintAction(opts)));
|
|
578
608
|
return program;
|
|
579
609
|
}
|
|
580
610
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diffwiki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-rc.202608011809.0c68acd",
|
|
4
4
|
"description": "diffwiki command-line interface",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@logtape/logtape": "^2.2.4",
|
|
18
18
|
"@logtape/file": "^2.2.4",
|
|
19
19
|
"commander": "^13.0.0",
|
|
20
|
-
"diffwiki-core": "0.
|
|
20
|
+
"diffwiki-core": "0.12.0-rc.202608011809.0c68acd"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^22.0.0"
|