bjira 0.0.3 → 0.0.4

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/dist/set.js DELETED
@@ -1,137 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _inquirer = _interopRequireDefault(require("inquirer"));
9
-
10
- var _command = _interopRequireDefault(require("./command.js"));
11
-
12
- var _field = _interopRequireDefault(require("./field.js"));
13
-
14
- var _jira = _interopRequireDefault(require("./jira.js"));
15
-
16
- var _errorhandler = _interopRequireDefault(require("./errorhandler.js"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
-
24
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
- class Set extends _command.default {
27
- addOptions(program) {
28
- const setCmd = program.command('set').description('Update fields in an issue');
29
- setCmd.command('assignee').description('Assign the issue to somebody').argument('<id>', 'The issue ID').action(async id => {
30
- const jira = new _jira.default(program);
31
- const userList = await User.pickUser(jira);
32
- const userNames = [];
33
- const userIds = [];
34
- userList.forEach(user => {
35
- if (user.active) {
36
- userNames.push(user.displayName);
37
- userIds.push(user.accountId);
38
- }
39
- });
40
- const assigneeQuestion = [{
41
- type: 'list',
42
- name: 'assignee',
43
- message: 'Assignee:',
44
- choices: userNames,
45
- filter: name => {
46
- const pos = userNames.indexOf(name);
47
- return {
48
- pos,
49
- name,
50
- id: userIds[pos]
51
- };
52
- }
53
- }];
54
- const assigneeAnswer = await _inquirer.default.prompt(assigneeQuestion);
55
- const issue = {
56
- fields: {
57
- assignee: {
58
- accountId: assigneeAnswer.assignee.id
59
- }
60
- }
61
- };
62
-
63
- try {
64
- await jira.spin('Updating the issue...', jira.api.updateIssue(id, issue));
65
- } catch (e) {
66
- _errorhandler.default.showError(jira, e);
67
- }
68
- });
69
- setCmd.command('status').description('Change the status').argument('<id>', 'The issue ID').action(async id => {
70
- const jira = new _jira.default(program);
71
- const transitionList = await jira.spin('Retrieving transitions...', jira.api.listTransitions(id));
72
- const transitionNames = [];
73
- const transitionIds = [];
74
- transitionList.transitions.forEach(transition => {
75
- transitionNames.push(transition.name);
76
- transitionIds.push(transition.id);
77
- });
78
- const transitionQuestion = [{
79
- type: 'list',
80
- name: 'transition',
81
- message: 'Status:',
82
- choices: transitionNames,
83
- filter: name => {
84
- const pos = transitionNames.indexOf(name);
85
- return {
86
- pos,
87
- name,
88
- id: transitionIds[pos]
89
- };
90
- }
91
- }];
92
- const transitionAnswer = await _inquirer.default.prompt(transitionQuestion);
93
- const transition = {
94
- transition: {
95
- id: transitionAnswer.transition.id
96
- }
97
- };
98
-
99
- try {
100
- await jira.spin('Updating the issue...', jira.api.transitionIssue(id, transition));
101
- } catch (e) {
102
- _errorhandler.default.showError(jira, e);
103
- }
104
- });
105
- setCmd.command('custom').description('Set a custom field').argument('<field>', 'The field name').argument('<id>', 'The issue ID').action(async (fieldName, id) => {
106
- const jira = new _jira.default(program);
107
- const fieldData = await _field.default.getFieldDataIfSupported(jira, fieldName);
108
-
109
- if (!fieldData) {
110
- console.log("Unsupported field type");
111
- return;
112
- }
113
-
114
- const question = [{
115
- type: fieldData.type,
116
- name: 'value',
117
- message: `${fieldName}:`
118
- }];
119
- const answer = await _inquirer.default.prompt(question);
120
- const data = {};
121
- data[fieldData.key] = answer.value;
122
-
123
- try {
124
- await jira.spin('Updating the issue...', jira.api.updateIssue(id, {
125
- fields: _objectSpread({}, data)
126
- }));
127
- } catch (e) {
128
- _errorhandler.default.showError(jira, e);
129
- }
130
- });
131
- }
132
-
133
- }
134
-
135
- ;
136
- var _default = Set;
137
- exports.default = _default;
package/dist/sprint.js DELETED
@@ -1,129 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _inquirer = _interopRequireDefault(require("inquirer"));
9
-
10
- var _cliTable = _interopRequireDefault(require("cli-table3"));
11
-
12
- var _command = _interopRequireDefault(require("./command.js"));
13
-
14
- var _jira = _interopRequireDefault(require("./jira.js"));
15
-
16
- var _errorhandler = _interopRequireDefault(require("./errorhandler.js"));
17
-
18
- var _project = _interopRequireDefault(require("./project.js"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- class Sprint extends _command.default {
23
- addOptions(program) {
24
- const sprintCmd = program.command('sprint').description('Play with sprints');
25
- sprintCmd.command('add').description('Add an issue to a sprint').argument('<id>', 'The issue ID').action(async id => {
26
- const jira = new _jira.default(program);
27
- const sprintId = await Sprint.pickSprint(jira);
28
-
29
- if (sprintId === 0) {
30
- console.log("No active sprints");
31
- return;
32
- }
33
-
34
- try {
35
- await jira.spin('Adding the issue to the sprint...', jira.apiAgileRequest(`/sprint/${sprintId}/issue`, {
36
- method: 'POST',
37
- followAllRedirects: true,
38
- body: {
39
- issues: [id]
40
- }
41
- }));
42
- } catch (e) {
43
- _errorhandler.default.showError(jira, e);
44
- }
45
- });
46
- sprintCmd.command('remove').description('Remove an issue from a sprint').argument('<id>', 'The issue ID').action(async id => {
47
- const jira = new _jira.default(program);
48
-
49
- try {
50
- await jira.spin('Adding the issue to the sprint...', jira.apiAgileRequest("/backlog/issue", {
51
- method: 'POST',
52
- followAllRedirects: true,
53
- body: {
54
- issues: [id]
55
- }
56
- }));
57
- } catch (e) {
58
- _errorhandler.default.showError(jira, e);
59
- }
60
- });
61
- }
62
-
63
- static async pickSprint(jira) {
64
- const project = await _project.default.pickProject(jira);
65
- const boardList = await jira.spin('Retrieving boards...', jira.api.getAllBoards(undefined, undefined, undefined, undefined, project.key));
66
- const boardNames = [];
67
- const boardIds = [];
68
- boardList.values.forEach(board => {
69
- boardNames.push(board.name);
70
- boardIds.push(board.id);
71
- });
72
- const boardQuestion = [{
73
- type: 'list',
74
- name: 'board',
75
- message: 'Board:',
76
- choices: boardNames,
77
- filter: name => {
78
- const pos = boardNames.indexOf(name);
79
- return {
80
- pos,
81
- name,
82
- id: boardIds[pos]
83
- };
84
- }
85
- }];
86
- const boardAnswer = await _inquirer.default.prompt(boardQuestion);
87
- const sprintList = await jira.spin('Retrieving sprints...', jira.api.getAllSprints(boardAnswer.board.id));
88
- const sprintNames = [];
89
- const sprintIds = [];
90
- sprintList.values.forEach(sprint => {
91
- if (sprint.state === 'active' || sprint.state === 'future') {
92
- sprintNames.push(sprint.name);
93
- sprintIds.push(sprint.id);
94
- }
95
- });
96
-
97
- if (sprintNames.length === 0) {
98
- return 0;
99
- }
100
-
101
- let sprintId = sprintIds[0];
102
-
103
- if (sprintNames.length > 1) {
104
- const sprintQuestion = [{
105
- type: 'list',
106
- name: 'sprint',
107
- message: 'Board:',
108
- choices: sprintNames,
109
- filter: name => {
110
- const pos = sprintNames.indexOf(name);
111
- return {
112
- pos,
113
- name,
114
- id: sprintIds[pos]
115
- };
116
- }
117
- }];
118
- const sprintAnswer = await _inquirer.default.prompt(sprintQuestion);
119
- sprintId = sprintAnswer.sprint.id;
120
- }
121
-
122
- return sprintId;
123
- }
124
-
125
- }
126
-
127
- ;
128
- var _default = Sprint;
129
- exports.default = _default;
package/dist/user.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _jira = _interopRequireDefault(require("./jira.js"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- class User {
13
- static async pickUser(jira) {
14
- const currentUser = await jira.spin('Retrieving current user...', jira.api.getCurrentUser());
15
- const userList = await jira.spin('Retrieving users...', jira.api.getUsers(0, 1000));
16
- userList.sort((a, b) => {
17
- if (a.accountId === currentUser.accountId) {
18
- return -1;
19
- }
20
-
21
- if (b.accountId === currentUser.accountId) {
22
- return 1;
23
- }
24
-
25
- return a.displayName > b.displayName;
26
- });
27
- return userList;
28
- }
29
-
30
- }
31
-
32
- ;
33
- var _default = User;
34
- exports.default = _default;