bjira 0.0.25 → 0.0.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bjira",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "A simple jira CLI tool",
5
5
  "main": "src/index.js",
6
6
  "author": {
package/src/comment.js CHANGED
@@ -24,9 +24,54 @@ class Comment extends Command {
24
24
 
25
25
  const jira = new Jira(program);
26
26
 
27
- await jira.spin('Adding the comment...', jira.api.addComment(id, comment));
27
+ await jira.spin('Adding the comment...', jira.api.addComment(id, this.createComment(comment)));
28
28
  });
29
29
  }
30
+
31
+ createComment(comment) {
32
+ return {
33
+ content: [{
34
+ content: [{
35
+ text: comment,
36
+ "type": "text"
37
+ }],
38
+ type: "paragraph"
39
+ }],
40
+ type: "doc",
41
+ version: 1
42
+ }
43
+ }
44
+
45
+ static showComment(obj) {
46
+ if (typeof obj === "string") return obj;
47
+
48
+ switch (obj.type) {
49
+ case 'doc':
50
+ case 'paragraph':
51
+ return obj.content.map(a => Comment.showComment(a)).join("");
52
+
53
+ case 'text':
54
+ return obj.text;
55
+
56
+ case 'inlineCard':
57
+ return obj.attrs.url;
58
+
59
+ case 'status':
60
+ case 'mention':
61
+ case 'emoji':
62
+ return obj.attrs.text;
63
+
64
+ case 'hardBreak':
65
+ return '\n';
66
+
67
+ case 'date':
68
+ const date = new Date(obj.attrs.timestamp * 1000);
69
+ return date.toLocaleString();
70
+
71
+ default:
72
+ return '';
73
+ }
74
+ }
30
75
  };
31
76
 
32
77
  export default Comment;
package/src/issue.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // SPDX-License-Identifier: MIT
4
4
 
5
5
  import Command from './command.js';
6
+ import Comment from './comment.js';
6
7
  import Field from './field.js';
7
8
  import Jira from './jira.js';
8
9
  import Project from './project.js';
@@ -188,7 +189,7 @@ class Issue extends Command {
188
189
  'Updated on', comment['Updated']
189
190
  ],
190
191
  [
191
- 'Body', Issue.showComment(comment.body)
192
+ 'Body', Comment.showComment(comment.body)
192
193
  ],
193
194
  ]);
194
195
  });
@@ -243,37 +244,6 @@ class Issue extends Command {
243
244
  return str;
244
245
  }
245
246
 
246
- static showComment(obj) {
247
- if (typeof obj === "string") return obj;
248
-
249
- switch (obj.type) {
250
- case 'doc':
251
- case 'paragraph':
252
- return obj.content.map(a => Issue.showComment(a)).join("");
253
-
254
- case 'text':
255
- return obj.text;
256
-
257
- case 'inlineCard':
258
- return obj.attrs.url;
259
-
260
- case 'status':
261
- case 'mention':
262
- case 'emoji':
263
- return obj.attrs.text;
264
-
265
- case 'hardBreak':
266
- return '\n';
267
-
268
- case 'date':
269
- const date = new Date(obj.attrs.timestamp * 1000);
270
- return date.toLocaleString();
271
-
272
- default:
273
- return '';
274
- }
275
- }
276
-
277
247
  showEpicIssue(issue) {
278
248
  if (!issue) return "";
279
249
  return `${issue.key} (${issue.fields['Summary'].trim()})`;