diffwiki 0.10.0 → 0.11.0-rc.202607301234.850d29d
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 +21 -139
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { spawn as spawn4 } from "child_process";
|
|
5
|
-
import { Command } from "commander";
|
|
5
|
+
import { Command, Option } from "commander";
|
|
6
6
|
import {
|
|
7
7
|
addExternalCollection,
|
|
8
8
|
addTags,
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
resolveCwdCollection,
|
|
27
27
|
resolveEditorCommand,
|
|
28
28
|
resolveEditTarget,
|
|
29
|
+
setArticleMeta,
|
|
29
30
|
setConfigValue,
|
|
30
31
|
setTags,
|
|
31
32
|
updateArticleBody
|
|
@@ -57,9 +58,6 @@ function withErrors(fn) {
|
|
|
57
58
|
}
|
|
58
59
|
var collect = (value, previous) => previous.concat([value]);
|
|
59
60
|
var splitTags = (raw) => raw.flatMap((t) => t.split(",")).map((t) => t.trim()).filter((t) => t.length > 0);
|
|
60
|
-
var deprecated = (oldForm, newForm) => {
|
|
61
|
-
console.error(`\u26A0 "diffwiki ${oldForm}" is deprecated; use "diffwiki ${newForm}".`);
|
|
62
|
-
};
|
|
63
61
|
|
|
64
62
|
// src/ui-server.ts
|
|
65
63
|
import { spawn } from "child_process";
|
|
@@ -318,16 +316,28 @@ async function createCollectionAction(name) {
|
|
|
318
316
|
const entry = await createCollection(name);
|
|
319
317
|
console.log(`Created collection "${entry.name}" at ${entry.path}`);
|
|
320
318
|
}
|
|
321
|
-
async function createArticleAction(target,
|
|
319
|
+
async function createArticleAction(target, opts) {
|
|
322
320
|
const article = await createArticle({
|
|
323
321
|
target,
|
|
324
|
-
tags: splitTags(
|
|
325
|
-
body
|
|
322
|
+
tags: splitTags(opts.tag),
|
|
323
|
+
body: opts.body,
|
|
324
|
+
audience: opts.audience,
|
|
325
|
+
status: opts.status
|
|
326
326
|
});
|
|
327
327
|
console.log(article.path);
|
|
328
328
|
}
|
|
329
|
-
async function updateArticleAction(target,
|
|
330
|
-
const
|
|
329
|
+
async function updateArticleAction(target, opts) {
|
|
330
|
+
const tagList = splitTags(opts.tag);
|
|
331
|
+
const hasMeta = opts.audience !== void 0 || opts.status !== void 0;
|
|
332
|
+
if (opts.body === void 0 && tagList.length === 0 && !hasMeta) {
|
|
333
|
+
console.error("Nothing to update \u2014 pass -b/--body, -t/--tag, --audience, and/or --status.");
|
|
334
|
+
process.exitCode = 1;
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
let article;
|
|
338
|
+
if (opts.body !== void 0) article = await updateArticleBody(target, opts.body);
|
|
339
|
+
if (tagList.length > 0) article = await setTags(target, tagList);
|
|
340
|
+
if (hasMeta) article = await setArticleMeta(target, { audience: opts.audience, status: opts.status });
|
|
331
341
|
console.log(`Updated ${article.path}`);
|
|
332
342
|
}
|
|
333
343
|
async function removeArticleAction(target) {
|
|
@@ -522,12 +532,8 @@ function createProgram() {
|
|
|
522
532
|
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)));
|
|
523
533
|
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)));
|
|
524
534
|
const article = program.command("article").description("Manage articles (documents)");
|
|
525
|
-
article.command("create").description("Add an article to a collection").argument("<target>", '"[collection:]title"').
|
|
526
|
-
|
|
527
|
-
(target, body, opts) => createArticleAction(target, body, opts.tag)
|
|
528
|
-
)
|
|
529
|
-
);
|
|
530
|
-
article.command("update").description("Replace an article's body").argument("<target>", '"collection:slug"').argument("<body>", "new markdown body").action(withErrors((target, body) => updateArticleAction(target, body)));
|
|
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(new Option("--audience <audience>", "visibility (default: public)").choices(["public", "private"])).addOption(new Option("--status <status>", "publish status (default: published)").choices(["draft", "published"])).action(withErrors((target, opts) => createArticleAction(target, opts)));
|
|
536
|
+
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"])).addOption(new Option("--status <status>", "set publish status").choices(["draft", "published"])).action(withErrors((target, opts) => updateArticleAction(target, opts)));
|
|
531
537
|
article.command("remove").description("Delete an article").argument("<target>", '"collection:slug"').action(withErrors((target) => removeArticleAction(target)));
|
|
532
538
|
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)));
|
|
533
539
|
const tags = program.command("tags").description("Manage an article's tags");
|
|
@@ -569,132 +575,8 @@ function createProgram() {
|
|
|
569
575
|
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)));
|
|
570
576
|
config.command("get").description("Read a config value").argument("<key>", "config key").action(withErrors((key) => configGetAction(key)));
|
|
571
577
|
program.command("doctor").description("Diagnose configuration issues").action(withErrors(doctorAction));
|
|
572
|
-
registerDeprecatedAliases(program);
|
|
573
578
|
return program;
|
|
574
579
|
}
|
|
575
|
-
function registerDeprecatedAliases(program) {
|
|
576
|
-
program.command("list", { hidden: true }).action(
|
|
577
|
-
withErrors(() => {
|
|
578
|
-
deprecated("list", "collection list");
|
|
579
|
-
return listCollectionsAction();
|
|
580
|
-
})
|
|
581
|
-
);
|
|
582
|
-
program.command("add", { hidden: true }).option("-d, --docs <dir>", "content dir relative to repo root", "docs").action(
|
|
583
|
-
withErrors((opts) => {
|
|
584
|
-
deprecated("add", "collection add");
|
|
585
|
-
return addExternalAction(opts);
|
|
586
|
-
})
|
|
587
|
-
);
|
|
588
|
-
program.command("create", { hidden: true }).argument("<name>", "collection name").action(
|
|
589
|
-
withErrors((name) => {
|
|
590
|
-
deprecated("create", "collection create");
|
|
591
|
-
return createCollectionAction(name);
|
|
592
|
-
})
|
|
593
|
-
);
|
|
594
|
-
program.command("add-article", { hidden: true }).requiredOption("-p, --path <target>", '"[collection:]title"').option("-t, --tag <tag>", "tag (repeatable, comma-separated)", collect, []).argument("[body]", "markdown body").action(
|
|
595
|
-
withErrors((body, opts) => {
|
|
596
|
-
deprecated("add-article", "article create");
|
|
597
|
-
return createArticleAction(opts.path, body, opts.tag);
|
|
598
|
-
})
|
|
599
|
-
);
|
|
600
|
-
program.command("update-article", { hidden: true }).requiredOption("-p, --path <target>", '"collection:path"').argument("<body>", "new markdown body").action(
|
|
601
|
-
withErrors((body, opts) => {
|
|
602
|
-
deprecated("update-article", "article update");
|
|
603
|
-
return updateArticleAction(opts.path, body);
|
|
604
|
-
})
|
|
605
|
-
);
|
|
606
|
-
program.command("remove-article", { hidden: true }).requiredOption("-p, --path <target>", '"collection:path"').action(
|
|
607
|
-
withErrors((opts) => {
|
|
608
|
-
deprecated("remove-article", "article remove");
|
|
609
|
-
return removeArticleAction(opts.path);
|
|
610
|
-
})
|
|
611
|
-
);
|
|
612
|
-
const registerDeprecatedTag = (name, newForm, fn) => {
|
|
613
|
-
program.command(name, { hidden: true }).requiredOption("-p, --path <target>", '"collection:path"').argument("<tags>", "comma-separated tags").action(
|
|
614
|
-
withErrors((tagList, opts) => {
|
|
615
|
-
deprecated(name, newForm);
|
|
616
|
-
return tagsAction(fn, opts.path, tagList);
|
|
617
|
-
})
|
|
618
|
-
);
|
|
619
|
-
};
|
|
620
|
-
registerDeprecatedTag("add-tags", "tags add", addTags);
|
|
621
|
-
registerDeprecatedTag("remove-tags", "tags remove", removeTags);
|
|
622
|
-
registerDeprecatedTag("update-tags", "tags set", setTags);
|
|
623
|
-
program.command("index", { hidden: true }).option("--embed", "also build vector embeddings (may download models on first run)").action(
|
|
624
|
-
withErrors((opts) => {
|
|
625
|
-
deprecated("index", "search index");
|
|
626
|
-
return indexAction(opts);
|
|
627
|
-
})
|
|
628
|
-
);
|
|
629
|
-
program.command("query", { hidden: true }).option("--engine <name>", "search engine/plugin (default: config defaultSearch, else native)").option("-c, --collection <name>", "limit to a collection").option("-t, --type <type>", "search type (engine-defined, e.g. keyword|semantic|hybrid)").argument("[term]", "search term", "").action(
|
|
630
|
-
withErrors((term, opts) => {
|
|
631
|
-
deprecated("query", "search query");
|
|
632
|
-
return queryAction(term, opts);
|
|
633
|
-
})
|
|
634
|
-
);
|
|
635
|
-
program.command("init", { hidden: true }).option("-c, --collection <name>", "collection name (default: repo name)").option("-p, --path <path>", "wiki path within the repo (default: wiki)").action(
|
|
636
|
-
withErrors((opts) => {
|
|
637
|
-
deprecated("init", "collection init");
|
|
638
|
-
return initAction(opts);
|
|
639
|
-
})
|
|
640
|
-
);
|
|
641
|
-
program.command("export", { hidden: true }).requiredOption("-o, --out <dir>", "output directory").option("-b, --base <path>", "base URL path (e.g. /my-repo/ for GitHub Pages)", "/").option("-f, --filter <globs>", "only export collections matching these globs (comma-separated)").option("-e, --exclude <globs>", "exclude collections matching these globs (comma-separated)").option("--project [dir]", "build only the repo project from its diffwiki.yaml (default: cwd)").action(
|
|
642
|
-
withErrors(
|
|
643
|
-
(opts) => {
|
|
644
|
-
deprecated("export", "site export");
|
|
645
|
-
return exportAction(opts);
|
|
646
|
-
}
|
|
647
|
-
)
|
|
648
|
-
);
|
|
649
|
-
program.command("config-set", { hidden: true }).argument("<key>", "config key").argument("<value>", "config value").action(
|
|
650
|
-
withErrors((key, value) => {
|
|
651
|
-
deprecated("config-set", "config set");
|
|
652
|
-
return configSetAction(key, value);
|
|
653
|
-
})
|
|
654
|
-
);
|
|
655
|
-
program.command("config-get", { hidden: true }).argument("<key>", "config key").action(
|
|
656
|
-
withErrors((key) => {
|
|
657
|
-
deprecated("config-get", "config get");
|
|
658
|
-
return configGetAction(key);
|
|
659
|
-
})
|
|
660
|
-
);
|
|
661
|
-
program.command("up", { hidden: true }).option("-p, --port <port>", "port to serve on", "4321").action(
|
|
662
|
-
withErrors((opts) => {
|
|
663
|
-
deprecated("up", "ui up");
|
|
664
|
-
return upAction(opts);
|
|
665
|
-
})
|
|
666
|
-
);
|
|
667
|
-
program.command("down", { hidden: true }).action(
|
|
668
|
-
withErrors(() => {
|
|
669
|
-
deprecated("down", "ui down");
|
|
670
|
-
return downAction();
|
|
671
|
-
})
|
|
672
|
-
);
|
|
673
|
-
program.command("status", { hidden: true }).action(
|
|
674
|
-
withErrors(() => {
|
|
675
|
-
deprecated("status", "ui status");
|
|
676
|
-
return statusAction();
|
|
677
|
-
})
|
|
678
|
-
);
|
|
679
|
-
program.command("open", { hidden: true }).option("-p, --port <port>", "port to serve on", "4321").action(
|
|
680
|
-
withErrors((opts) => {
|
|
681
|
-
deprecated("open", "ui open");
|
|
682
|
-
return openAction(opts);
|
|
683
|
-
})
|
|
684
|
-
);
|
|
685
|
-
program.command("edit", { hidden: true }).argument("[target]", 'collection or "collection:slug" (default: the current repo collection)').option("--editor <cmd>", "editor command (overrides config `editor`, $VISUAL, $EDITOR)").action(
|
|
686
|
-
withErrors((target, opts) => {
|
|
687
|
-
deprecated("edit", "collection edit / article edit");
|
|
688
|
-
return editAction(target, opts.editor);
|
|
689
|
-
})
|
|
690
|
-
);
|
|
691
|
-
program.command("preview", { hidden: true }).option("-p, --port <port>", "port to serve on", "4321").action(
|
|
692
|
-
withErrors((opts) => {
|
|
693
|
-
deprecated("preview", "site preview");
|
|
694
|
-
return previewAction(opts);
|
|
695
|
-
})
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
580
|
|
|
699
581
|
// src/logging.ts
|
|
700
582
|
import { mkdirSync } from "fs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diffwiki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-rc.202607301234.850d29d",
|
|
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.11.0-rc.202607301234.850d29d"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^22.0.0"
|