omgbase 0.5.0 → 0.6.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.
- package/dist/build-info.json +2 -2
- package/dist/src/cmd/docs.js +36 -11
- package/package.json +3 -3
package/dist/build-info.json
CHANGED
package/dist/src/cmd/docs.js
CHANGED
|
@@ -30,18 +30,39 @@ function report(cli, verb, res) {
|
|
|
30
30
|
cli.io.out(res.docId);
|
|
31
31
|
return EXIT_OK;
|
|
32
32
|
}
|
|
33
|
-
// `mv`
|
|
34
|
-
// (spec/cli §6 `mv`):
|
|
35
|
-
// the
|
|
33
|
+
// `mv` rewrites the inbound links by default (spec/mutate 1.3; `--no-retarget`
|
|
34
|
+
// opts out); say what happened wherever the move is reported (spec/cli §6 `mv`):
|
|
35
|
+
// the human confirmation carries the `retargeted` count and the same `dangling`
|
|
36
|
+
// list the --json result does, with the fix for each kind — `retarget` for
|
|
37
|
+
// authored links left as written, `meta` for a frontmatter relation (never
|
|
38
|
+
// rewritten by a move).
|
|
36
39
|
function reportMove(cli, from, res) {
|
|
37
40
|
const code = report(cli, "moved to", res);
|
|
38
|
-
if (cli.flags.mode !== "human"
|
|
41
|
+
if (cli.flags.mode !== "human")
|
|
39
42
|
return code;
|
|
40
43
|
const { style, io } = cli;
|
|
44
|
+
if (!cli.flags.dryRun && res.retargeted && res.retargeted.blocks.length > 0) {
|
|
45
|
+
const b = res.retargeted.blocks.length;
|
|
46
|
+
const d = res.retargeted.docs.length;
|
|
47
|
+
io.err(style.dim(` ${style.ok(cli.render.g.ok)} retargeted ${b} inbound link${b === 1 ? "" : "s"} in ${d} document${d === 1 ? "" : "s"}`));
|
|
48
|
+
}
|
|
49
|
+
if (res.dangling.length === 0)
|
|
50
|
+
return code;
|
|
41
51
|
const where = res.dangling.map((l) => (l.block ? `${l.path} ${l.block}` : `${l.path} (frontmatter)`)).join(", ");
|
|
42
52
|
const n = res.dangling.length;
|
|
43
53
|
io.err(style.warn(` ${style.warn(cli.render.g.warn)} ${n} inbound link${n === 1 ? "" : "s"} still name${n === 1 ? "s" : ""} the old path: ${where}`));
|
|
44
|
-
|
|
54
|
+
if (res.dangling.some((l) => l.block))
|
|
55
|
+
io.err(style.dim(` fix: ${cli.prog} retarget /${from} /${res.path} --apply`));
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
for (const l of res.dangling) {
|
|
58
|
+
if (l.block || !l.field)
|
|
59
|
+
continue;
|
|
60
|
+
const key = `${l.path}\u0000${l.field}`;
|
|
61
|
+
if (seen.has(key))
|
|
62
|
+
continue;
|
|
63
|
+
seen.add(key);
|
|
64
|
+
io.err(style.dim(` fix: ${cli.prog} meta ${l.path} --set ${l.field}=/${res.path}`));
|
|
65
|
+
}
|
|
45
66
|
return code;
|
|
46
67
|
}
|
|
47
68
|
// ---- new --------------------------------------------------------------------
|
|
@@ -82,27 +103,31 @@ async function runMv(cli, args) {
|
|
|
82
103
|
const { values, positionals } = parseArgs({
|
|
83
104
|
args,
|
|
84
105
|
allowPositionals: true,
|
|
85
|
-
options: { actor: { type: "string" }, help: { type: "boolean" } },
|
|
106
|
+
options: { actor: { type: "string" }, "no-retarget": { type: "boolean" }, help: { type: "boolean" } },
|
|
86
107
|
});
|
|
87
108
|
if (values.help) {
|
|
88
109
|
return renderHelp(cli, {
|
|
89
110
|
name: "mv",
|
|
90
|
-
summary: "Rename/move a document to a new path; its identity and history are preserved",
|
|
91
|
-
usage: "mv <doc> <new-path> [--actor <s>] [--dry-run]",
|
|
92
|
-
options: [
|
|
111
|
+
summary: "Rename/move a document to a new path; its identity and history are preserved and inbound links follow it",
|
|
112
|
+
usage: "mv <doc> <new-path> [--no-retarget] [--actor <s>] [--dry-run]",
|
|
113
|
+
options: [
|
|
114
|
+
["--no-retarget", "leave the inbound links as written (they dangle; fix later with retarget)"],
|
|
115
|
+
["--actor <s>", "commit actor (default human:$USER)"],
|
|
116
|
+
],
|
|
93
117
|
});
|
|
94
118
|
}
|
|
95
119
|
const doc = positionals[0];
|
|
96
120
|
const toPath = positionals[1];
|
|
97
121
|
if (!doc || !toPath)
|
|
98
122
|
throw new CliUsageError("mv requires <doc> and <new-path>");
|
|
123
|
+
const noRetarget = values["no-retarget"] === true;
|
|
99
124
|
if (cli.flags.server) {
|
|
100
|
-
const res = await remoteCall(cli, "docs_move", { doc, to_path: toPath, ...dryRunArg(cli) });
|
|
125
|
+
const res = await remoteCall(cli, "docs_move", { doc, to_path: toPath, ...(noRetarget ? { retarget_inbound: false } : {}), ...dryRunArg(cli) });
|
|
101
126
|
return reportMove(cli, fromPathOf(res, doc), res);
|
|
102
127
|
}
|
|
103
128
|
const ws = cli.workspace();
|
|
104
129
|
const repo = cli.repo(ws);
|
|
105
|
-
const res = docsMove(ws.store, ctxOf(cli, ws, repo.repoId, repo.rootPath, values.actor), doc, toPath);
|
|
130
|
+
const res = docsMove(ws.store, ctxOf(cli, ws, repo.repoId, repo.rootPath, values.actor), doc, toPath, noRetarget ? { retargetInbound: false } : {});
|
|
106
131
|
return reportMove(cli, fromPathOf(res, doc), res);
|
|
107
132
|
}
|
|
108
133
|
// ---- rm --doc (block rm lives in mutate.ts; this handles the --doc branch) --
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omgbase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Open Markdown Graph Base — CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"omg": "./dist/src/main.js"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@omgbase/core": "^0.
|
|
48
|
+
"@omgbase/core": "^0.6.1",
|
|
49
49
|
"@omgbase/fs-adapter": "^0.2.0",
|
|
50
|
-
"@omgbase/sync": "^0.4.
|
|
50
|
+
"@omgbase/sync": "^0.4.4",
|
|
51
51
|
"yaml": "^2.9.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|