arbiterdesign 0.1.8 → 0.1.9

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.
@@ -8,6 +8,10 @@
8
8
  * the repo keeps it — the archive, the queue, DECISIONS.md, its picture, requests and comments —
9
9
  * and notes the move in .arbiter/renamed.json, so the next publish moves the board's comments too.
10
10
  *
11
+ * With `--merge`, the new name may be one a piece of work already has: this one joins it. Its decisions take
12
+ * that name, its pictures join that one's by when each was taken, and its comments and requests move to
13
+ * it. For work started under a new name that turned out to continue an existing change.
14
+ *
11
15
  * Screens (C-0002) aren't renamed here: their id is a number, so a new name never moves a comment.
12
16
  */
13
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -19,7 +23,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
19
23
  const node_path_1 = __importDefault(require("node:path"));
20
24
  const store_1 = require("../store");
21
25
  const candidates_1 = require("../candidates");
22
- const hosted_1 = require("../hosted");
26
+ const comments_1 = require("../comments");
23
27
  const requests_1 = require("../requests");
24
28
  const work_1 = require("../work");
25
29
  const fail = (errors) => ({ exitCode: 1, output: { status: 'invalid', errors } });
@@ -49,12 +53,14 @@ function renameWork(from, to, opts = {}) {
49
53
  const current = found[0].trigger;
50
54
  if (current === newName)
51
55
  return fail([`"${current}" is already called that`]);
52
- // Two pieces of work with one id would be one card with two names. Merging them is a different act.
56
+ // Two pieces of work with one id would be one card with two names: merging them is asked for by name.
53
57
  const taken = newId !== oldId ? all.find((d) => (0, work_1.workId)(d.trigger) === newId) : undefined;
54
- if (taken)
55
- return fail([`there's already a piece of work called "${taken.trigger}" — renaming "${current}" onto it would merge the two`]);
58
+ if (taken && !opts.merge)
59
+ return fail([`there's already a piece of work called "${taken.trigger}" — renaming "${current}" onto it would merge the two. To merge them: npx arbiter rename "${current}" "${taken.trigger}" --merge`]);
60
+ // Merged, its decisions take the other's name exactly as that one has it.
61
+ const target = taken ? taken.trigger : newName;
56
62
  const wrote = [];
57
- const rename = (ds) => ds.map((d) => (mine(d) ? { ...d, trigger: newName } : d));
63
+ const rename = (ds) => ds.map((d) => (mine(d) ? { ...d, trigger: target } : d));
58
64
  if (archive.some(mine)) {
59
65
  (0, store_1.writeArchive)(paths, rename(archive));
60
66
  wrote.push('.arbiter/archive.md');
@@ -68,9 +74,14 @@ function renameWork(from, to, opts = {}) {
68
74
  wrote.push('DECISIONS.md');
69
75
  }
70
76
  if (newId !== oldId) {
77
+ // Merged: its pictures join the other's, in the order they were taken.
78
+ if (taken) {
79
+ if ((0, work_1.mergePictures)(paths, oldId, newId))
80
+ wrote.push(`.arbiter/work/${newId}`);
81
+ }
71
82
  // The picture is filed under the id; it follows. Anything already filed under the new id belongs
72
83
  // to no decision (that was checked above), so it's a leftover and goes.
73
- const shot = (0, work_1.workSnapshot)(paths, oldId);
84
+ const shot = taken ? null : (0, work_1.workSnapshot)(paths, oldId);
74
85
  if (shot) {
75
86
  const stale = (0, work_1.workSnapshot)(paths, newId);
76
87
  if (stale)
@@ -79,14 +90,17 @@ function renameWork(from, to, opts = {}) {
79
90
  node_fs_1.default.renameSync(shot, next);
80
91
  wrote.push(`.arbiter/work/${node_path_1.default.basename(next)}`);
81
92
  }
93
+ // Its earlier pictures go with it.
94
+ if (!taken && (0, work_1.moveHistory)(paths, oldId, newId))
95
+ wrote.push(`.arbiter/work/history/${newId}/`);
82
96
  const requests = (0, requests_1.readRequests)(paths);
83
97
  if (requests.some((r) => r.screen === oldId)) {
84
98
  (0, requests_1.writeRequests)(paths, requests.map((r) => (r.screen === oldId ? { ...r, screen: newId } : r)));
85
99
  wrote.push('.arbiter/requests.json');
86
100
  }
87
- const comments = (0, hosted_1.readComments)(paths);
101
+ const comments = (0, comments_1.readComments)(paths);
88
102
  if (comments.some((c) => c.candidate_id === oldId)) {
89
- (0, hosted_1.writeComments)(paths, comments.map((c) => (c.candidate_id === oldId ? { ...c, candidate_id: newId } : c)));
103
+ (0, comments_1.writeComments)(paths, comments.map((c) => (c.candidate_id === oldId ? { ...c, candidate_id: newId } : c)));
90
104
  wrote.push('.arbiter/comments.json');
91
105
  }
92
106
  (0, work_1.addRename)(paths, oldId, newId);
@@ -95,9 +109,9 @@ function renameWork(from, to, opts = {}) {
95
109
  return {
96
110
  exitCode: 0,
97
111
  output: {
98
- status: 'renamed',
112
+ status: taken ? 'merged' : 'renamed',
99
113
  from: current,
100
- to: newName,
114
+ to: target,
101
115
  decisions: found.length,
102
116
  ...(newId !== oldId ? { card: { from: oldId, to: newId } } : {}),
103
117
  wrote,