bjira 0.0.3 → 0.0.7
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/README.md +70 -2
- package/package.json +5 -6
- package/src/ask.js +57 -0
- package/src/comment.js +1 -3
- package/src/create.js +27 -73
- package/src/errorhandler.js +9 -6
- package/src/field.js +21 -38
- package/src/index.js +1 -1
- package/src/init.js +5 -25
- package/src/issue.js +105 -85
- package/src/jira.js +5 -2
- package/src/preset.js +8 -8
- package/src/project.js +12 -35
- package/src/query.js +23 -26
- package/src/run.js +6 -21
- package/src/set.js +45 -101
- package/src/sprint.js +25 -84
- package/src/table.js +162 -0
- package/.babelrc +0 -13
- package/dist/command.js +0 -15
- package/dist/comment.js +0 -70
- package/dist/create.js +0 -127
- package/dist/errorhandler.js +0 -37
- package/dist/field.js +0 -158
- package/dist/index.js +0 -49
- package/dist/init.js +0 -63
- package/dist/issue.js +0 -176
- package/dist/jira.js +0 -116
- package/dist/preset.js +0 -56
- package/dist/project.js +0 -88
- package/dist/query.js +0 -83
- package/dist/run.js +0 -104
- package/dist/set.js +0 -137
- package/dist/sprint.js +0 -129
- package/dist/user.js +0 -34
package/src/issue.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import color from 'chalk';
|
|
2
|
-
import Table from 'cli-table3';
|
|
3
|
-
|
|
4
1
|
import Command from './command.js';
|
|
5
|
-
import ErrorHandler from './errorhandler.js'
|
|
6
2
|
import Field from './field.js';
|
|
7
3
|
import Jira from './jira.js';
|
|
4
|
+
import Table from './table.js';
|
|
8
5
|
|
|
9
6
|
const DEFAULT_QUERY_LIMIT = 20;
|
|
10
7
|
|
|
@@ -21,22 +18,9 @@ class Issue extends Command {
|
|
|
21
18
|
.action(async id => {
|
|
22
19
|
const jira = new Jira(program);
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
resultFields = await Field.listFields(jira);
|
|
27
|
-
} catch (e) {
|
|
28
|
-
ErrorHandler.showError(jira, e);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let result;
|
|
33
|
-
try {
|
|
34
|
-
result = await jira.spin('Running query...', jira.api.findIssue(id));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
ErrorHandler.showError(jira, e);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
21
|
+
const resultFields = await Field.listFields(jira);
|
|
39
22
|
|
|
23
|
+
const result = await jira.spin('Running query...', jira.api.findIssue(id));
|
|
40
24
|
const issue = Issue.replaceFields(result, resultFields);
|
|
41
25
|
|
|
42
26
|
let epicIssue = null;
|
|
@@ -46,71 +30,107 @@ class Issue extends Command {
|
|
|
46
30
|
epicIssue = Issue.replaceFields(epicResult, resultFields);
|
|
47
31
|
}
|
|
48
32
|
|
|
49
|
-
const table = new Table({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
33
|
+
const table = new Table({});
|
|
34
|
+
|
|
35
|
+
table.addRows([
|
|
36
|
+
[
|
|
37
|
+
'Summary', issue.fields['Summary'].trim()
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
'URL', {
|
|
41
|
+
color: "blue",
|
|
42
|
+
text: Issue.url(jira, id)
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
'Status', {
|
|
47
|
+
color: "green",
|
|
48
|
+
text: issue.fields['Status'].name
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
'Type', issue.fields['Issue Type'].name
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
'Project', issue.fields['Project'].name + ' (' + issue.fields['Project'].key + ')'
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'Reporter', Issue.showUser(issue.fields['Reporter'])
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
'Assignee', Issue.showUser(issue.fields['Assignee'])
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
'Priority', issue.fields['Priority'].name
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
'Epic Link', {
|
|
68
|
+
color: "yellow",
|
|
69
|
+
text: this.showEpicIssue(epicIssue)
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
'Labels', issue.fields['Labels'].join(', ')
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
'Sprint', {
|
|
77
|
+
color: "yellow",
|
|
78
|
+
text: issue.fields['Sprint']?.map(sprint => this.showSprint(sprint)).join(', ')
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
jira.fields.forEach(fieldName => table.addRow([fieldName, issue.fields[fieldName] || "unset"]));
|
|
84
|
+
|
|
85
|
+
table.addRows([
|
|
86
|
+
[
|
|
87
|
+
'', ''
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
'Created on', issue.fields['Created']
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
'Updated on', issue.fields['Updated']
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
'', ''
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'Description', issue.fields['Description']
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
'', ''
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
'Comments', issue.fields['Comment'].total
|
|
106
|
+
]
|
|
107
|
+
]);
|
|
98
108
|
|
|
99
109
|
if (cmd.opts().comments) {
|
|
100
110
|
issue.fields['Comment'].comments.forEach(comment => {
|
|
101
|
-
table.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
table.addRows([
|
|
112
|
+
[
|
|
113
|
+
'', ''
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
'Comment', {
|
|
117
|
+
color: "yellow",
|
|
118
|
+
text: comment.id
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
'Author', Issue.showUser(comment.author)
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
'Created on', comment['Created']
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
'Updated on', comment['Updated']
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
'Body', comment.body
|
|
132
|
+
]
|
|
133
|
+
]);
|
|
114
134
|
});
|
|
115
135
|
}
|
|
116
136
|
|
|
@@ -143,20 +163,20 @@ class Issue extends Command {
|
|
|
143
163
|
return obj;
|
|
144
164
|
}
|
|
145
165
|
|
|
146
|
-
showUser(user) {
|
|
166
|
+
static showUser(user) {
|
|
147
167
|
if (!user) return "(null)";
|
|
148
168
|
let str = user.displayName;
|
|
149
|
-
if (user.emailAddress) str += ` (${
|
|
169
|
+
if (user.emailAddress) str += ` (${user.emailAddress})`;
|
|
150
170
|
return str;
|
|
151
171
|
}
|
|
152
172
|
|
|
153
173
|
showEpicIssue(issue) {
|
|
154
174
|
if (!issue) return "";
|
|
155
|
-
return `${
|
|
175
|
+
return `${issue.key} (${issue.fields['Summary'].trim()})`;
|
|
156
176
|
}
|
|
157
177
|
|
|
158
178
|
showSprint(sprint) {
|
|
159
|
-
return `${
|
|
179
|
+
return `${sprint.name} (${sprint.state})`;
|
|
160
180
|
}
|
|
161
181
|
};
|
|
162
182
|
|
package/src/jira.js
CHANGED
|
@@ -2,6 +2,8 @@ import jiraClient from 'jira-client';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
|
|
5
|
+
import ErrorHandler from './errorhandler.js'
|
|
6
|
+
|
|
5
7
|
class Jira {
|
|
6
8
|
constructor(program) {
|
|
7
9
|
const opts = program.opts();
|
|
@@ -74,11 +76,12 @@ class Jira {
|
|
|
74
76
|
|
|
75
77
|
try {
|
|
76
78
|
const result = await promise;
|
|
79
|
+
spinner.stop();
|
|
77
80
|
return result;
|
|
78
81
|
} catch (e) {
|
|
79
|
-
throw e;
|
|
80
|
-
} finally {
|
|
81
82
|
spinner.stop();
|
|
83
|
+
ErrorHandler.showError(this, e);
|
|
84
|
+
process.exit(1);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
|
package/src/preset.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import color from 'chalk';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import Table from 'cli-table3';
|
|
4
|
-
|
|
5
1
|
import Command from './command.js';
|
|
6
2
|
import Jira from './jira.js';
|
|
3
|
+
import Table from './table.js';
|
|
7
4
|
|
|
8
5
|
class Preset extends Command {
|
|
9
6
|
addOptions(program) {
|
|
@@ -44,13 +41,16 @@ class Preset extends Command {
|
|
|
44
41
|
const jira = new Jira(program);
|
|
45
42
|
|
|
46
43
|
const table = new Table({
|
|
47
|
-
chars: jira.tableChars,
|
|
48
44
|
head: ['Name', 'Query']
|
|
49
45
|
});
|
|
50
46
|
|
|
51
|
-
Object.keys(jira.config.presets).forEach(key => table.
|
|
52
|
-
color
|
|
53
|
-
|
|
47
|
+
Object.keys(jira.config.presets).forEach(key => table.addRow([{
|
|
48
|
+
color: "blue",
|
|
49
|
+
text: key
|
|
50
|
+
}, {
|
|
51
|
+
color: "green",
|
|
52
|
+
text: jira.config.presets[key]
|
|
53
|
+
}, ]));
|
|
54
54
|
console.log(table.toString());
|
|
55
55
|
});
|
|
56
56
|
}
|
package/src/project.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Table from 'cli-table3';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
|
|
1
|
+
import Ask from './ask.js';
|
|
5
2
|
import Command from './command.js';
|
|
6
3
|
import Jira from './jira.js';
|
|
4
|
+
import Table from './table.js';
|
|
7
5
|
|
|
8
6
|
class Project extends Command {
|
|
9
7
|
addOptions(program) {
|
|
@@ -17,11 +15,13 @@ class Project extends Command {
|
|
|
17
15
|
const projects = await jira.spin("Loading projects...", jira.api.listProjects());
|
|
18
16
|
|
|
19
17
|
const table = new Table({
|
|
20
|
-
chars: jira.tableChars,
|
|
21
18
|
head: ['Key', 'Name']
|
|
22
19
|
});
|
|
23
20
|
|
|
24
|
-
projects.forEach(project => table.
|
|
21
|
+
projects.forEach(project => table.addRow([{
|
|
22
|
+
color: "blue",
|
|
23
|
+
text: project.key
|
|
24
|
+
}, project.name]));
|
|
25
25
|
console.log(table.toString());
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -42,39 +42,16 @@ class Project extends Command {
|
|
|
42
42
|
return a.name > b.name;
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const issueTypes = [];
|
|
48
|
-
|
|
49
|
-
meta.projects.forEach(project => {
|
|
50
|
-
projectNames.push(project.name);
|
|
51
|
-
projectKeys.push(project.key);
|
|
52
|
-
issueTypes.push(project.issuetypes);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const projectQuestion = [{
|
|
56
|
-
type: 'list',
|
|
57
|
-
name: 'project',
|
|
58
|
-
message: 'Project:',
|
|
59
|
-
choices: projectNames,
|
|
60
|
-
filter: name => {
|
|
61
|
-
const pos = projectNames.indexOf(name);
|
|
62
|
-
return {
|
|
63
|
-
pos,
|
|
64
|
-
name,
|
|
65
|
-
key: projectKeys[pos]
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}];
|
|
69
|
-
|
|
70
|
-
const projectAnswer = await inquirer.prompt(projectQuestion);
|
|
45
|
+
const projectPos = await Ask.askList('Project:', meta.projects.map(project => project.name));
|
|
46
|
+
const project = meta.projects[projectPos];
|
|
71
47
|
|
|
72
|
-
jira.latestProject =
|
|
48
|
+
jira.latestProject = project.key;
|
|
73
49
|
jira.syncConfig();
|
|
74
50
|
|
|
75
51
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
name: project.name,
|
|
53
|
+
key: project.key,
|
|
54
|
+
issueTypes: project.issuetypes,
|
|
78
55
|
};
|
|
79
56
|
}
|
|
80
57
|
};
|
package/src/query.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import color from 'chalk';
|
|
2
|
-
import Table from 'cli-table3';
|
|
3
|
-
|
|
4
1
|
import Command from './command.js';
|
|
5
2
|
import ErrorHandler from './errorhandler.js';
|
|
6
3
|
import Field from './field.js';
|
|
4
|
+
import Issue from './issue.js';
|
|
7
5
|
import Jira from './jira.js';
|
|
6
|
+
import Table from './table.js';
|
|
8
7
|
|
|
9
8
|
const DEFAULT_QUERY_LIMIT = 20;
|
|
10
9
|
|
|
@@ -20,29 +19,17 @@ class Query extends Command {
|
|
|
20
19
|
const jira = new Jira(program);
|
|
21
20
|
const opts = cmd.opts();
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
resultFields = await Field.listFields(jira);
|
|
26
|
-
} catch (e) {
|
|
27
|
-
ErrorHandler.showError(jira, e);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
22
|
+
const resultFields = await Field.listFields(jira);
|
|
30
23
|
|
|
31
24
|
let expectedResult = opts.limit;
|
|
32
25
|
let issues = [];
|
|
33
26
|
|
|
34
27
|
while (issues.length < opts.limit) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
maxResults: opts.limit - issues.length
|
|
41
|
-
}));
|
|
42
|
-
} catch (e) {
|
|
43
|
-
ErrorHandler.showError(jira, e);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
28
|
+
const result = await jira.spin('Running query...',
|
|
29
|
+
jira.api.searchJira(query, {
|
|
30
|
+
startAt: issues.lengh,
|
|
31
|
+
maxResults: opts.limit - issues.length
|
|
32
|
+
}));
|
|
46
33
|
|
|
47
34
|
if (result.warningMessages) {
|
|
48
35
|
ErrorHandler.showWarningMessages(result.warningMessages);
|
|
@@ -59,15 +46,25 @@ class Query extends Command {
|
|
|
59
46
|
|
|
60
47
|
static showIssues(jira, issues, fields) {
|
|
61
48
|
const table = new Table({
|
|
62
|
-
|
|
63
|
-
head: ['Key', 'Status', 'Type', 'Summary']
|
|
49
|
+
head: ['Key', 'Status', 'Type', 'Assignee', 'Summary']
|
|
64
50
|
});
|
|
65
51
|
|
|
66
|
-
issues.forEach(issue => table.
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
issues.forEach(issue => table.addRow([{
|
|
53
|
+
color: "blue",
|
|
54
|
+
text: issue.key
|
|
55
|
+
}, {
|
|
56
|
+
color: "green",
|
|
57
|
+
text: issue.fields.status.name
|
|
58
|
+
}, {
|
|
59
|
+
color: "green",
|
|
60
|
+
text: issue.fields.issuetype.name
|
|
61
|
+
}, {
|
|
62
|
+
color: "yellow",
|
|
63
|
+
text: Issue.showUser(issue.fields.assignee)
|
|
64
|
+
},
|
|
69
65
|
issue.fields.summary
|
|
70
66
|
]))
|
|
67
|
+
|
|
71
68
|
console.log(table.toString());
|
|
72
69
|
}
|
|
73
70
|
};
|
package/src/run.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import color from 'chalk';
|
|
2
|
-
import Table from 'cli-table3';
|
|
3
|
-
|
|
4
1
|
import Command from './command.js';
|
|
5
2
|
import ErrorHandler from './errorhandler.js';
|
|
6
3
|
import Field from './field.js';
|
|
@@ -42,29 +39,17 @@ class Run extends Command {
|
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
resultFields = await Field.listFields(jira);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
ErrorHandler.showError(jira, e);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
42
|
+
const resultFields = await Field.listFields(jira);
|
|
52
43
|
|
|
53
44
|
let expectedResult = opts.limit;
|
|
54
45
|
let issues = [];
|
|
55
46
|
|
|
56
47
|
while (issues.length < opts.limit) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
maxResults: opts.limit - issues.length
|
|
63
|
-
}));
|
|
64
|
-
} catch (e) {
|
|
65
|
-
ErrorHandler.showError(jira, e);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
48
|
+
const result = await jira.spin('Running query...',
|
|
49
|
+
jira.api.searchJira(query, {
|
|
50
|
+
startAt: issues.lengh,
|
|
51
|
+
maxResults: opts.limit - issues.length
|
|
52
|
+
}));
|
|
68
53
|
|
|
69
54
|
if (result.warningMessages) {
|
|
70
55
|
ErrorHandler.showWarningMessages(result.warningMessages);
|
package/src/set.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import Ask from './ask.js';
|
|
3
2
|
import Command from './command.js';
|
|
4
3
|
import Field from './field.js';
|
|
5
4
|
import Jira from './jira.js';
|
|
6
|
-
import
|
|
5
|
+
import User from './user.js';
|
|
7
6
|
|
|
8
7
|
class Set extends Command {
|
|
9
8
|
addOptions(program) {
|
|
@@ -14,46 +13,7 @@ class Set extends Command {
|
|
|
14
13
|
.argument('<id>', 'The issue ID')
|
|
15
14
|
.action(async id => {
|
|
16
15
|
const jira = new Jira(program);
|
|
17
|
-
|
|
18
|
-
const userList = await User.pickUser(jira);
|
|
19
|
-
const userNames = [];
|
|
20
|
-
const userIds = [];
|
|
21
|
-
userList.forEach(user => {
|
|
22
|
-
if (user.active) {
|
|
23
|
-
userNames.push(user.displayName);
|
|
24
|
-
userIds.push(user.accountId);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const assigneeQuestion = [{
|
|
29
|
-
type: 'list',
|
|
30
|
-
name: 'assignee',
|
|
31
|
-
message: 'Assignee:',
|
|
32
|
-
choices: userNames,
|
|
33
|
-
filter: name => {
|
|
34
|
-
const pos = userNames.indexOf(name);
|
|
35
|
-
return {
|
|
36
|
-
pos,
|
|
37
|
-
name,
|
|
38
|
-
id: userIds[pos]
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}];
|
|
42
|
-
|
|
43
|
-
const assigneeAnswer = await inquirer.prompt(assigneeQuestion);
|
|
44
|
-
const issue = {
|
|
45
|
-
fields: {
|
|
46
|
-
assignee: {
|
|
47
|
-
accountId: assigneeAnswer.assignee.id
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
await jira.spin('Updating the issue...', jira.api.updateIssue(id, issue));
|
|
54
|
-
} catch (e) {
|
|
55
|
-
ErrorHandler.showError(jira, e);
|
|
56
|
-
}
|
|
16
|
+
await Set.assignIssue(jira, id);
|
|
57
17
|
});
|
|
58
18
|
|
|
59
19
|
setCmd.command('status')
|
|
@@ -61,42 +21,7 @@ class Set extends Command {
|
|
|
61
21
|
.argument('<id>', 'The issue ID')
|
|
62
22
|
.action(async id => {
|
|
63
23
|
const jira = new Jira(program);
|
|
64
|
-
|
|
65
|
-
const transitionList = await jira.spin('Retrieving transitions...', jira.api.listTransitions(id));
|
|
66
|
-
const transitionNames = [];
|
|
67
|
-
const transitionIds = [];
|
|
68
|
-
transitionList.transitions.forEach(transition => {
|
|
69
|
-
transitionNames.push(transition.name);
|
|
70
|
-
transitionIds.push(transition.id);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const transitionQuestion = [{
|
|
74
|
-
type: 'list',
|
|
75
|
-
name: 'transition',
|
|
76
|
-
message: 'Status:',
|
|
77
|
-
choices: transitionNames,
|
|
78
|
-
filter: name => {
|
|
79
|
-
const pos = transitionNames.indexOf(name);
|
|
80
|
-
return {
|
|
81
|
-
pos,
|
|
82
|
-
name,
|
|
83
|
-
id: transitionIds[pos]
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}];
|
|
87
|
-
|
|
88
|
-
const transitionAnswer = await inquirer.prompt(transitionQuestion);
|
|
89
|
-
|
|
90
|
-
const transition = {
|
|
91
|
-
transition: {
|
|
92
|
-
id: transitionAnswer.transition.id
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
try {
|
|
96
|
-
await jira.spin('Updating the issue...', jira.api.transitionIssue(id, transition));
|
|
97
|
-
} catch (e) {
|
|
98
|
-
ErrorHandler.showError(jira, e);
|
|
99
|
-
}
|
|
24
|
+
await Set.setStatus(jira, id);
|
|
100
25
|
});
|
|
101
26
|
|
|
102
27
|
setCmd.command('custom')
|
|
@@ -105,34 +30,53 @@ class Set extends Command {
|
|
|
105
30
|
.argument('<id>', 'The issue ID')
|
|
106
31
|
.action(async (fieldName, id) => {
|
|
107
32
|
const jira = new Jira(program);
|
|
33
|
+
await Set.setCustomField(jira, fieldName, id);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static async assignIssue(jira, id) {
|
|
38
|
+
const userList = await User.pickUser(jira);
|
|
39
|
+
const activeUsers = userList.filter(user => user.active);
|
|
40
|
+
const assignee = await Ask.askList('Assignee:', activeUsers.map(user => user.displayName));
|
|
108
41
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
42
|
+
const issue = {
|
|
43
|
+
fields: {
|
|
44
|
+
assignee: {
|
|
45
|
+
accountId: activeUsers[assignee].accountId
|
|
113
46
|
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
114
49
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
name: 'value',
|
|
118
|
-
message: `${fieldName}:`,
|
|
119
|
-
}];
|
|
50
|
+
await jira.spin('Updating the issue...', jira.api.updateIssue(id, issue));
|
|
51
|
+
}
|
|
120
52
|
|
|
121
|
-
|
|
53
|
+
static async setCustomField(jira, fieldName, id) {
|
|
54
|
+
const field = await Field.askFieldIfSupported(jira, fieldName);
|
|
55
|
+
if (!field) {
|
|
56
|
+
console.log("Unsupported field type");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const data = {};
|
|
61
|
+
data[field.key] = field.value;
|
|
62
|
+
|
|
63
|
+
await jira.spin('Updating the issue...', jira.api.updateIssue(id, {
|
|
64
|
+
fields: {
|
|
65
|
+
...data
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
122
69
|
|
|
123
|
-
|
|
124
|
-
|
|
70
|
+
static async setStatus(jira, id) {
|
|
71
|
+
const transitionList = await jira.spin('Retrieving transitions...', jira.api.listTransitions(id));
|
|
72
|
+
const transitionPos = await Ask.askList('Status:', transitionList.transitions.map(transition => transition.name));
|
|
73
|
+
const transition = {
|
|
74
|
+
transition: {
|
|
75
|
+
id: transitionList.transitions[transitionPos].id
|
|
76
|
+
}
|
|
77
|
+
};
|
|
125
78
|
|
|
126
|
-
|
|
127
|
-
await jira.spin('Updating the issue...', jira.api.updateIssue(id, {
|
|
128
|
-
fields: {
|
|
129
|
-
...data
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
132
|
-
} catch (e) {
|
|
133
|
-
ErrorHandler.showError(jira, e);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
79
|
+
await jira.spin('Updating the issue...', jira.api.transitionIssue(id, transition));
|
|
136
80
|
}
|
|
137
81
|
};
|
|
138
82
|
|