@4-r-c-4-n-4/todo 0.1.3 → 0.1.4
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/BIBLE.md +1 -0
- package/dist/cli.js +1 -1
- package/dist/commands/edit.js +49 -0
- package/dist/commands/link.js +2 -2
- package/package.json +1 -1
package/BIBLE.md
CHANGED
|
@@ -219,6 +219,7 @@ todo show <id> Show ticket detail
|
|
|
219
219
|
--raw
|
|
220
220
|
todo edit <id> Edit ticket fields
|
|
221
221
|
--summary --description --type --tags --add-tag --rm-tag
|
|
222
|
+
--parent <id> reparent under a different parent
|
|
222
223
|
todo transition <id> <state> Transition state
|
|
223
224
|
--commit --test --note --depends-on --duplicate-of
|
|
224
225
|
todo close <id> Shorthand: transition to done
|
package/dist/cli.js
CHANGED
|
@@ -10,8 +10,8 @@ const export_js_1 = require("./commands/export.js");
|
|
|
10
10
|
const init_js_1 = require("./commands/init.js");
|
|
11
11
|
const link_js_1 = require("./commands/link.js");
|
|
12
12
|
const list_js_1 = require("./commands/list.js");
|
|
13
|
-
const next_js_1 = require("./commands/next.js");
|
|
14
13
|
const new_js_1 = require("./commands/new.js");
|
|
14
|
+
const next_js_1 = require("./commands/next.js");
|
|
15
15
|
const scan_js_1 = require("./commands/scan.js");
|
|
16
16
|
const show_js_1 = require("./commands/show.js");
|
|
17
17
|
const transition_js_1 = require("./commands/transition.js");
|
package/dist/commands/edit.js
CHANGED
|
@@ -21,12 +21,61 @@ function registerEdit(program) {
|
|
|
21
21
|
.option("--tags <tags>", "replace all tags (comma-separated)")
|
|
22
22
|
.option("--add-tag <tag>", "add one tag")
|
|
23
23
|
.option("--rm-tag <tag>", "remove one tag")
|
|
24
|
+
.option("--parent <id>", "reparent ticket under a different parent")
|
|
24
25
|
.action((id, opts) => {
|
|
25
26
|
const ctx = (0, context_js_1.getContext)(true);
|
|
26
27
|
const { repoRoot } = ctx;
|
|
27
28
|
try {
|
|
28
29
|
const ticket = (0, ticket_js_1.readTicketByPrefix)(repoRoot, id);
|
|
29
30
|
let changed = false;
|
|
31
|
+
if (opts.parent !== undefined) {
|
|
32
|
+
let newParent;
|
|
33
|
+
try {
|
|
34
|
+
newParent = (0, ticket_js_1.readTicketByPrefix)(repoRoot, opts.parent);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
console.error(`Error: parent ticket '${opts.parent}' not found`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
if (newParent.id === ticket.id) {
|
|
41
|
+
console.error("Error: a ticket cannot be its own parent");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const oldParentId = ticket.relationships?.parent;
|
|
45
|
+
if (oldParentId !== newParent.id) {
|
|
46
|
+
const now = new Date().toISOString();
|
|
47
|
+
if (oldParentId) {
|
|
48
|
+
try {
|
|
49
|
+
const oldParent = (0, ticket_js_1.readTicketByPrefix)(repoRoot, oldParentId);
|
|
50
|
+
if (oldParent.relationships?.children) {
|
|
51
|
+
const before = oldParent.relationships.children.length;
|
|
52
|
+
oldParent.relationships.children =
|
|
53
|
+
oldParent.relationships.children.filter((c) => c !== ticket.id);
|
|
54
|
+
if (oldParent.relationships.children.length !== before) {
|
|
55
|
+
oldParent.updated_at = now;
|
|
56
|
+
(0, ticket_js_1.writeTicket)(repoRoot, oldParent);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// old parent missing — nothing to detach from
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!newParent.relationships)
|
|
65
|
+
newParent.relationships = {};
|
|
66
|
+
if (!newParent.relationships.children)
|
|
67
|
+
newParent.relationships.children = [];
|
|
68
|
+
if (!newParent.relationships.children.includes(ticket.id)) {
|
|
69
|
+
newParent.relationships.children.push(ticket.id);
|
|
70
|
+
newParent.updated_at = now;
|
|
71
|
+
(0, ticket_js_1.writeTicket)(repoRoot, newParent);
|
|
72
|
+
}
|
|
73
|
+
if (!ticket.relationships)
|
|
74
|
+
ticket.relationships = {};
|
|
75
|
+
ticket.relationships.parent = newParent.id;
|
|
76
|
+
changed = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
30
79
|
if (opts.summary !== undefined) {
|
|
31
80
|
ticket.summary = opts.summary;
|
|
32
81
|
changed = true;
|
package/dist/commands/link.js
CHANGED
|
@@ -58,8 +58,8 @@ function registerLink(program) {
|
|
|
58
58
|
const key = relation;
|
|
59
59
|
if (!ticket.relationships[key])
|
|
60
60
|
ticket.relationships[key] = [];
|
|
61
|
-
if (!ticket.relationships[key]
|
|
62
|
-
ticket.relationships[key]
|
|
61
|
+
if (!ticket.relationships[key]?.includes(resolvedTarget)) {
|
|
62
|
+
ticket.relationships[key]?.push(resolvedTarget);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|