@monoedge/jdu-cli 0.1.0 → 0.2.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/README.md +1 -0
- package/dist/cli.js +24 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -3696,6 +3696,7 @@ async function pushDoc(api, entryArg, opts) {
|
|
|
3696
3696
|
else if (opts.id === void 0 || opts.id === "") body.title = inferTitle(collected.entry.path);
|
|
3697
3697
|
if (opts.id !== void 0 && opts.id !== "") body.id = opts.id;
|
|
3698
3698
|
if (opts.tag !== void 0) body.tags = opts.tag.flatMap((t) => t.split(",")).map((t) => t.trim()).filter((t) => t.length > 0);
|
|
3699
|
+
if (opts.official === true) body.official = true;
|
|
3699
3700
|
const res = await api.postJson("/api/docs", body);
|
|
3700
3701
|
const id = typeof res?.id === "string" ? res.id : opts.id;
|
|
3701
3702
|
const url = typeof res?.url === "string" && res.url !== "" ? res.url : id !== void 0 ? api.url(`/d/${id}`) : void 0;
|
|
@@ -3852,7 +3853,7 @@ program.command("login").description("登录到 jiandu server(forward-auth 会
|
|
|
3852
3853
|
if (result.source === "oidc-browser") process.stderr.write("SSO 登录成功。\n");
|
|
3853
3854
|
if (result.warning) process.stderr.write(`jdu: ${result.warning}\n`);
|
|
3854
3855
|
});
|
|
3855
|
-
program.command("push").argument("<entry.md>", "入口 markdown 文件").description("递归收集本地引用、增量上传并发布一个新版本").option("--title <title>", "文档标题,默认取首个一级标题").option("--visibility <v>", `${VISIBILITIES.join(" | ")}(新文档默认 private;更新已有文档时不传则保持原值)`).option("--id <docId>", "复用已有文档 id(发布新版本)").option("--tag <name>", "打标签,可重复;不传则保持原有标签", collectTag, void 0).action(async (entry, opts) => {
|
|
3856
|
+
program.command("push").argument("<entry.md>", "入口 markdown 文件").description("递归收集本地引用、增量上传并发布一个新版本").option("--title <title>", "文档标题,默认取首个一级标题").option("--visibility <v>", `${VISIBILITIES.join(" | ")}(新文档默认 private;更新已有文档时不传则保持原值)`).option("--id <docId>", "复用已有文档 id(发布新版本)").option("--tag <name>", "打标签,可重复;不传则保持原有标签", collectTag, void 0).option("--official", "上架到官方知识库(需管理员;同时公开)").action(async (entry, opts) => {
|
|
3856
3857
|
await pushDoc(await client(), entry, opts);
|
|
3857
3858
|
});
|
|
3858
3859
|
program.command("list").description("列出文档").option("--all", "包含已归档", false).action(async (opts) => {
|
|
@@ -3865,6 +3866,10 @@ program.command("list").description("列出文档").option("--all", "包含已
|
|
|
3865
3866
|
key: "visibility",
|
|
3866
3867
|
header: "VISIBILITY"
|
|
3867
3868
|
},
|
|
3869
|
+
{
|
|
3870
|
+
key: "official",
|
|
3871
|
+
header: "OFFICIAL"
|
|
3872
|
+
},
|
|
3868
3873
|
{
|
|
3869
3874
|
key: "archived",
|
|
3870
3875
|
header: "ARCHIVED"
|
|
@@ -3974,6 +3979,24 @@ program.command("share").argument("<docId>").description("改可见性 / 团队
|
|
|
3974
3979
|
process.stdout.write(`已授权:${list.join(", ") || "(已清空)"}\n`);
|
|
3975
3980
|
}
|
|
3976
3981
|
});
|
|
3982
|
+
var officialCmd = program.command("official").description("官方知识库上架");
|
|
3983
|
+
officialCmd.command("list").description("列出已上架的官方文档").action(async () => {
|
|
3984
|
+
printTable(asRows(await (await client()).getJson("/api/official"), "docs"), [{
|
|
3985
|
+
key: "id",
|
|
3986
|
+
header: "ID"
|
|
3987
|
+
}, {
|
|
3988
|
+
key: "title",
|
|
3989
|
+
header: "TITLE"
|
|
3990
|
+
}]);
|
|
3991
|
+
});
|
|
3992
|
+
officialCmd.command("add").argument("<docId>").description("上架到官方知识库(需管理员;同时公开)").action(async (docId) => {
|
|
3993
|
+
await (await client()).putJson(`/api/docs/${encodeURIComponent(docId)}/official`, { official: true });
|
|
3994
|
+
process.stdout.write(`official ${docId}\n`);
|
|
3995
|
+
});
|
|
3996
|
+
officialCmd.command("rm").argument("<docId>").description("从官方知识库拿下(正文和下架前的可见性保留)").action(async (docId) => {
|
|
3997
|
+
await (await client()).putJson(`/api/docs/${encodeURIComponent(docId)}/official`, { official: false });
|
|
3998
|
+
process.stdout.write(`unofficial ${docId}\n`);
|
|
3999
|
+
});
|
|
3977
4000
|
program.command("teams").description("列出我所属的团队").action(async () => {
|
|
3978
4001
|
printTable(asRows(await (await client()).getJson("/api/teams"), "teams"), [
|
|
3979
4002
|
{
|