flowcollab 0.3.7 → 0.3.8
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/bin/comment.mjs +29 -5
- package/bin/flow.mjs +1 -1
- package/package.json +1 -1
package/bin/comment.mjs
CHANGED
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* flow:comment — append a free-form comment to a task's timeline.
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
flow-comment <task_id> "<body>"
|
|
6
|
+
flow-comment <task_id> "<body>" --commit=<sha> link a specific commit
|
|
7
|
+
flow-comment <task_id> "<body>" --commit link the current HEAD
|
|
8
|
+
|
|
9
|
+
When a commit is linked, the comment renders a clickable "View changes" diff
|
|
10
|
+
in the board timeline (Theme 34). The commit must be pushed to GitHub to be
|
|
11
|
+
viewable.
|
|
4
12
|
*/
|
|
5
13
|
|
|
6
|
-
import {
|
|
14
|
+
import { execFileSync } from 'child_process';
|
|
15
|
+
import { flowFetch, resolveTaskId, positional, arg, die } from './_client.mjs';
|
|
16
|
+
|
|
17
|
+
function headSha() {
|
|
18
|
+
try {
|
|
19
|
+
return execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
|
|
20
|
+
} catch {
|
|
21
|
+
die('--commit with no value needs a git repo (could not run `git rev-parse HEAD`). Pass --commit=<sha> instead.');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
7
24
|
|
|
8
25
|
async function main() {
|
|
9
26
|
const raw = positional(0);
|
|
10
27
|
const body = positional(1);
|
|
11
|
-
if (!raw || !body) die('Usage: flow-comment <task_id> "<body>"');
|
|
28
|
+
if (!raw || !body) die('Usage: flow-comment <task_id> "<body>" [--commit[=<sha>]]');
|
|
29
|
+
|
|
30
|
+
let commit;
|
|
31
|
+
if (process.argv.includes('--commit') || process.argv.some(a => a.startsWith('--commit='))) {
|
|
32
|
+
commit = arg('commit') || headSha();
|
|
33
|
+
if (!/^[0-9a-f]{7,64}$/i.test(commit)) die(`Invalid commit SHA: ${commit}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
12
36
|
const id = await resolveTaskId(raw);
|
|
13
|
-
await flowFetch('/api/flow/comment', { method: 'POST', body: { task_id: id, body } });
|
|
14
|
-
process.stdout.write('Comment posted.\n');
|
|
37
|
+
await flowFetch('/api/flow/comment', { method: 'POST', body: { task_id: id, body, ...(commit ? { commit } : {}) } });
|
|
38
|
+
process.stdout.write(commit ? `Comment posted (linked commit ${commit.slice(0, 7)}).\n` : 'Comment posted.\n');
|
|
15
39
|
}
|
|
16
40
|
|
|
17
41
|
main().catch(e => die(e.message || e));
|
package/bin/flow.mjs
CHANGED
|
@@ -26,7 +26,7 @@ const CMDS = [
|
|
|
26
26
|
['login', 'login.mjs', 'Authorize the CLI via browser (device flow)'],
|
|
27
27
|
['pull', 'pull.mjs', 'Fetch board snapshot + @mentions (start of day)'],
|
|
28
28
|
['claim', 'claim.mjs', 'Claim a task and mark it in-progress'],
|
|
29
|
-
['comment', 'comment.mjs', 'Post a comment
|
|
29
|
+
['comment', 'comment.mjs', 'Post a comment (--commit[=<sha>] links a clickable diff)'],
|
|
30
30
|
['close', 'close.mjs', 'Mark a task done with a summary'],
|
|
31
31
|
['create', 'create.mjs', 'Create a new task'],
|
|
32
32
|
['edit', 'edit.mjs', 'Update task fields (title, priority, area, due…)'],
|