bjira 0.0.17 → 0.0.18
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 +1 -1
- package/src/attachment.js +37 -0
- package/src/index.js +2 -0
- package/src/issue.js +34 -2
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2021 Andrea Marchesini <baku@bnode.dev>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
import Command from './command.js';
|
|
6
|
+
import Field from './field.js';
|
|
7
|
+
import Issue from './issue.js';
|
|
8
|
+
import Jira from './jira.js';
|
|
9
|
+
import Utils from './utils.js';
|
|
10
|
+
|
|
11
|
+
class Attachment extends Command {
|
|
12
|
+
addOptions(program) {
|
|
13
|
+
const cmd = program.command('attachment')
|
|
14
|
+
.description('Play with attachments');
|
|
15
|
+
cmd.command('get')
|
|
16
|
+
.description('Get the attachment')
|
|
17
|
+
.argument('<issueID>', 'The issue ID')
|
|
18
|
+
.argument('<attachmentID>', 'The attachment ID')
|
|
19
|
+
.action(async (issueId, attachmentId) => {
|
|
20
|
+
const jira = new Jira(program);
|
|
21
|
+
|
|
22
|
+
const resultFields = await Field.listFields(jira);
|
|
23
|
+
|
|
24
|
+
const result = await jira.spin('Running query...', jira.api.findIssue(issueId));
|
|
25
|
+
const issue = Issue.replaceFields(result, resultFields);
|
|
26
|
+
|
|
27
|
+
const attachment = issue.fields['Attachment'].find(attachment => attachment.id === attachmentId);
|
|
28
|
+
const attachmentData = await jira.api.downloadAttachment(attachment);
|
|
29
|
+
process.stdout.write(attachmentData);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// TODO: delete attachment
|
|
33
|
+
// TODO: upload attachment
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Attachment;
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import fs from 'fs';
|
|
|
9
9
|
import os from 'os';
|
|
10
10
|
import path from 'path';
|
|
11
11
|
|
|
12
|
+
import Attachment from './attachment.js';
|
|
12
13
|
import Comment from './comment.js';
|
|
13
14
|
import Create from './create.js';
|
|
14
15
|
import Field from './field.js';
|
|
@@ -24,6 +25,7 @@ import Sprint from './sprint.js';
|
|
|
24
25
|
const DEFAULT_CONFIG_FILE = path.join(os.homedir(), ".bjira.json")
|
|
25
26
|
|
|
26
27
|
const commands = [
|
|
28
|
+
new Attachment(),
|
|
27
29
|
new Comment(),
|
|
28
30
|
new Create(),
|
|
29
31
|
new Field(),
|
package/src/issue.js
CHANGED
|
@@ -19,6 +19,7 @@ class Issue extends Command {
|
|
|
19
19
|
addOptions(program) {
|
|
20
20
|
const cmd = program.command('show')
|
|
21
21
|
.description('Show an issue')
|
|
22
|
+
.option('-a, --attachments', 'Show the attachments too')
|
|
22
23
|
.option('-C, --comments', 'Show the comments too')
|
|
23
24
|
.option('-s, --subissues', 'Show the comments too')
|
|
24
25
|
.argument('<id>', 'The issue ID')
|
|
@@ -120,11 +121,42 @@ class Issue extends Command {
|
|
|
120
121
|
[
|
|
121
122
|
'', ''
|
|
122
123
|
],
|
|
124
|
+
[
|
|
125
|
+
'Attachments', issue.fields['Attachment'].length
|
|
126
|
+
],
|
|
123
127
|
[
|
|
124
128
|
'Comments', issue.fields['Comment'].total
|
|
125
|
-
]
|
|
129
|
+
],
|
|
126
130
|
]);
|
|
127
131
|
|
|
132
|
+
if (cmd.opts().attachments) {
|
|
133
|
+
issue.fields['Attachment'].forEach(attachment => {
|
|
134
|
+
table.addRows([
|
|
135
|
+
[
|
|
136
|
+
'', ''
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
'Attachment', {
|
|
140
|
+
color: "yellow",
|
|
141
|
+
text: attachment.id
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
'Filename', attachment.filename
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
'Author', Issue.showUser(attachment.author)
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
'Size', attachment.size
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
'Mime-type', attachment.mimeType
|
|
155
|
+
],
|
|
156
|
+
]);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
128
160
|
if (cmd.opts().comments) {
|
|
129
161
|
issue.fields['Comment'].comments.forEach(comment => {
|
|
130
162
|
table.addRows([
|
|
@@ -148,7 +180,7 @@ class Issue extends Command {
|
|
|
148
180
|
],
|
|
149
181
|
[
|
|
150
182
|
'Body', comment.body
|
|
151
|
-
]
|
|
183
|
+
],
|
|
152
184
|
]);
|
|
153
185
|
});
|
|
154
186
|
}
|