jira_command 0.1.2 → 0.1.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +2 -1
- data/jira_command.gemspec +3 -0
- data/lib/jira_command/cli.rb +7 -0
- data/lib/jira_command/command/assign.rb +12 -24
- data/lib/jira_command/command/config.rb +12 -1
- data/lib/jira_command/command/issue.rb +116 -49
- data/lib/jira_command/command/list.rb +25 -14
- data/lib/jira_command/command/sprint.rb +48 -0
- data/lib/jira_command/command/status.rb +2 -3
- data/lib/jira_command/command/transition.rb +2 -3
- data/lib/jira_command/command/user.rb +3 -4
- data/lib/jira_command/config.rb +1 -1
- data/lib/jira_command/jira/assign.rb +1 -1
- data/lib/jira_command/jira/base.rb +3 -3
- data/lib/jira_command/jira/board.rb +27 -0
- data/lib/jira_command/jira/epic.rb +37 -0
- data/lib/jira_command/jira/issue.rb +19 -7
- data/lib/jira_command/jira/{issuetype.rb → issue_type.rb} +0 -0
- data/lib/jira_command/jira/list.rb +2 -1
- data/lib/jira_command/jira/sprint.rb +54 -0
- data/lib/jira_command/jira/status.rb +3 -3
- data/lib/jira_command/jira/transition.rb +3 -3
- data/lib/jira_command/jira/user.rb +2 -4
- data/lib/jira_command/prompt/base.rb +98 -0
- data/lib/jira_command/version.rb +1 -1
- metadata +50 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f199c7426e8711a45c9a3931eee57c6981ca74ccddfa256c888c22e0638871
|
4
|
+
data.tar.gz: 2d41f767b0c28d654b2e0db0376351c4a063f3b1579ad37559901ae73665efdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd974693885d1bb8d015235bc9f9826f93873c702feaf91bfccce3746ee2e5c6573b3dd3bd50c1f412b748ca0b45d0faa6f0952b0b0df51e4d506d32ec9deb1
|
7
|
+
data.tar.gz: 0406c3ff7c34b80d5aa253b43a34e90a97d849dfd4e1de6a9edbc806c1774e885d57e4832b66b8328037867a10e1a55f1bce1e6c020d77e006f19a5ca9b98792
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -30,16 +30,17 @@ $ jira_command config create
|
|
30
30
|
> Please input your registered email address: <example@xincere.jp>
|
31
31
|
> Please input your token: <token got in jira>
|
32
32
|
|
33
|
-
$ jira_command help
|
34
33
|
Commands:
|
35
34
|
jira_command assign # set or unset assign in issue
|
36
35
|
jira_command config # create or clear configuration
|
37
36
|
jira_command help [COMMAND] # Describe available commands or one specific command
|
38
37
|
jira_command issue # create a issue
|
39
38
|
jira_command list # list up issues
|
39
|
+
jira_command sprint # sprint related features
|
40
40
|
jira_command status # show all status in project
|
41
41
|
jira_command transition # transition issues
|
42
42
|
jira_command user # list all users
|
43
|
+
jira_command version # show version
|
43
44
|
```
|
44
45
|
|
45
46
|
<b>if you want to cache items in your local to reduce api call, you can refer the following commands.</b>
|
data/jira_command.gemspec
CHANGED
@@ -27,5 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
+
spec.add_dependency 'faraday'
|
31
|
+
spec.add_dependency 'terminal-table'
|
30
32
|
spec.add_dependency 'thor'
|
33
|
+
spec.add_dependency 'tty-prompt'
|
31
34
|
end
|
data/lib/jira_command/cli.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative 'command/assign'
|
|
7
7
|
require_relative 'command/status'
|
8
8
|
require_relative 'command/transition'
|
9
9
|
require_relative 'command/issue'
|
10
|
+
require_relative 'command/sprint'
|
10
11
|
|
11
12
|
module JiraCommand
|
12
13
|
class CLI < Thor
|
@@ -17,5 +18,11 @@ module JiraCommand
|
|
17
18
|
register(JiraCommand::Command::Status, 'status', 'status', 'show all status in project')
|
18
19
|
register(JiraCommand::Command::Transition, 'transition', 'transition', 'transition issues')
|
19
20
|
register(JiraCommand::Command::Issue, 'issue', 'issue', 'create a issue')
|
21
|
+
register(JiraCommand::Command::Sprint, 'sprint', 'sprint', 'sprint related features')
|
22
|
+
|
23
|
+
desc 'version', 'show version'
|
24
|
+
def version
|
25
|
+
puts 'You are using: ' + JiraCommand::VERSION
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
@@ -3,45 +3,33 @@ require 'optparse'
|
|
3
3
|
require 'tty-prompt'
|
4
4
|
require_relative '../config'
|
5
5
|
require_relative '../jira/assign'
|
6
|
+
require_relative '../prompt/base'
|
6
7
|
|
7
8
|
module JiraCommand
|
8
9
|
module Command
|
9
10
|
class Assign < Thor
|
10
11
|
desc 'exec', 'assign to user'
|
11
|
-
option '
|
12
|
-
|
13
|
-
def exec
|
12
|
+
option 'refresh-user', aliases: 'u', required: false
|
13
|
+
def exec(issue_key)
|
14
14
|
config = JiraCommand::Config.new.read
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
user_api = JiraCommand::Jira::User.new(config)
|
23
|
-
user_api.all_list(project: project[:key])
|
24
|
-
end
|
25
|
-
|
26
|
-
prompt = TTY::Prompt.new
|
27
|
-
|
28
|
-
assignee = prompt.select('Who do you want to assign?') do |menu|
|
29
|
-
user_list.each do |user|
|
30
|
-
menu.choice name: user[:name], value: user[:account_id]
|
31
|
-
end
|
32
|
-
end
|
16
|
+
prompt_base = JiraCommand::Prompt::Base.new
|
17
|
+
assignee = prompt_base.select_user(
|
18
|
+
message: 'Who do you want to assign?',
|
19
|
+
project_key: issue_key.split('-').first,
|
20
|
+
refresh: !options['refresh-user'].nil?
|
21
|
+
)
|
33
22
|
|
34
23
|
assign = JiraCommand::Jira::Assign.new(config)
|
35
|
-
|
24
|
+
assign.execute(issue_key: issue_key, assignee: assignee)
|
36
25
|
end
|
37
26
|
|
38
27
|
desc 'clear', 'set to unassigned'
|
39
|
-
|
40
|
-
def clear
|
28
|
+
def clear(issue_key)
|
41
29
|
config = JiraCommand::Config.new.read
|
42
30
|
|
43
31
|
assign = JiraCommand::Jira::Assign.new(config)
|
44
|
-
assign.unassigne(issue_key:
|
32
|
+
assign.unassigne(issue_key: issue_key)
|
45
33
|
end
|
46
34
|
end
|
47
35
|
end
|
@@ -3,9 +3,10 @@ require 'thor'
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'tty-prompt'
|
5
5
|
require_relative '../config'
|
6
|
-
require_relative '../jira/
|
6
|
+
require_relative '../jira/issue_type'
|
7
7
|
require_relative '../jira/project'
|
8
8
|
require_relative '../jira/user'
|
9
|
+
require_relative '../jira/board'
|
9
10
|
require 'base64'
|
10
11
|
|
11
12
|
module JiraCommand
|
@@ -62,6 +63,16 @@ module JiraCommand
|
|
62
63
|
JiraCommand::Config.new.write(config)
|
63
64
|
end
|
64
65
|
|
66
|
+
desc 'update_board', 'update default board in config file'
|
67
|
+
def update_board
|
68
|
+
config = JiraCommand::Config.new.read
|
69
|
+
agile_board = JiraCommand::Jira::Board.new(config)
|
70
|
+
config.merge!({
|
71
|
+
boards: agile_board.list
|
72
|
+
})
|
73
|
+
JiraCommand::Config.new.write(config)
|
74
|
+
end
|
75
|
+
|
65
76
|
desc 'clear', 'clear config file'
|
66
77
|
def clear
|
67
78
|
prompt = TTY::Prompt.new
|
@@ -1,79 +1,146 @@
|
|
1
1
|
require 'jira_command'
|
2
2
|
require_relative '../config'
|
3
|
-
require_relative '../
|
4
|
-
require_relative '../jira/
|
3
|
+
require_relative '../prompt/base'
|
4
|
+
require_relative '../jira/epic'
|
5
|
+
require_relative '../jira/board'
|
5
6
|
require_relative '../jira/issue'
|
7
|
+
require_relative '../jira/sprint'
|
6
8
|
|
7
9
|
module JiraCommand
|
8
10
|
module Command
|
9
11
|
class Issue < Thor
|
10
12
|
desc 'create', 'create new issue'
|
11
|
-
option 'refresh-project', aliases: '
|
12
|
-
option 'refresh-issue-type', aliases: '
|
13
|
-
option 'refresh-user', aliases: '
|
13
|
+
option 'refresh-project', aliases: 'p', required: false
|
14
|
+
option 'refresh-issue-type', aliases: 'i', required: false
|
15
|
+
option 'refresh-user', aliases: 'u', required: false
|
16
|
+
option 'refresh-board', aliases: 'b', required: false
|
14
17
|
def create
|
15
18
|
config = JiraCommand::Config.new.read
|
16
19
|
|
17
|
-
|
18
|
-
config['issue_types']
|
19
|
-
else
|
20
|
-
jira_issue_type = JiraCommand::Jira::IssueType.new(config)
|
21
|
-
jira_issue_type.list
|
22
|
-
end
|
20
|
+
prompt_base = JiraCommand::Prompt::Base.new
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
menu.choice name: item['name'], value: item['id']
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
projects = if options['refresh-project'].nil?
|
33
|
-
config['projects']
|
34
|
-
else
|
35
|
-
jira_project = JiraCommand::Jira::Project.new(config)
|
36
|
-
jira_project.list
|
37
|
-
end
|
38
|
-
|
39
|
-
project = prompt.select('Which project does the issue belong to?') do |menu|
|
40
|
-
projects.each do |item|
|
41
|
-
menu.choice name: item['name'], value: { id: item['id'], key: item['key'] }
|
42
|
-
end
|
43
|
-
end
|
22
|
+
issue_type = prompt_base.select_issue_type(
|
23
|
+
message: 'Which issue type do you want to create?',
|
24
|
+
refresh: !options['refresh-issue-type'].nil?
|
25
|
+
)
|
44
26
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
user_api.all_list(project: project[:key])
|
50
|
-
end
|
27
|
+
project = prompt_base.select_project(
|
28
|
+
message: 'Which project does the issue belong to?',
|
29
|
+
refresh: !options['refresh-project'].nil?
|
30
|
+
)
|
51
31
|
|
52
|
-
assignee =
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
32
|
+
assignee = prompt_base.select_user(
|
33
|
+
message: 'Who do you want to assign?',
|
34
|
+
refresh: !options['refresh-user'].nil?,
|
35
|
+
additional: [{ name: 'unassigned', value: nil }]
|
36
|
+
)
|
57
37
|
|
58
|
-
reporter =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
38
|
+
reporter = prompt_base.select_user(
|
39
|
+
message: 'Who are you?',
|
40
|
+
refresh: !options['refresh-user'].nil?
|
41
|
+
)
|
63
42
|
|
43
|
+
prompt = TTY::Prompt.new
|
64
44
|
summary = prompt.ask('Please input issue summary: ')
|
65
45
|
description = prompt.ask('Please input issue description: ')
|
66
46
|
|
67
47
|
jira_issue = JiraCommand::Jira::Issue.new(config)
|
68
48
|
|
69
|
-
|
49
|
+
issue_key = jira_issue.create(
|
70
50
|
summary: summary,
|
71
51
|
description: description,
|
72
52
|
assignee: assignee,
|
73
53
|
reporter: reporter,
|
74
54
|
project_id: project[:id],
|
75
|
-
issuetype_id: issue_type
|
55
|
+
issuetype_id: issue_type[:id]
|
76
56
|
)
|
57
|
+
|
58
|
+
puts 'the created issue url: ' + config[:jira_url] + 'browse/' + issue_key
|
59
|
+
|
60
|
+
return if issue_type[:name] == 'Epic'
|
61
|
+
|
62
|
+
baord_list = if !config[:boards].nil? && options['refresh-board'].nil?
|
63
|
+
config[:boards]
|
64
|
+
else
|
65
|
+
agile_board = JiraCommand::Jira::Board.new(config)
|
66
|
+
agile_board.list
|
67
|
+
end
|
68
|
+
|
69
|
+
target_board = baord_list.find { |item| item[:projectId].to_i == project[:id].to_i }
|
70
|
+
|
71
|
+
agile_epic = JiraCommand::Jira::Epic.new(config)
|
72
|
+
epics = agile_epic.list(board_id: target_board[:id])
|
73
|
+
|
74
|
+
epic_id = prompt.select('Which epic does the created issue belong to?') do |menu|
|
75
|
+
epics.each do |item|
|
76
|
+
menu.choice name: item[:name], value: item[:id]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
agile_epic.move_issue(epic_id: epic_id, issue_key: issue_key)
|
81
|
+
|
82
|
+
exit 0 unless prompt.yes?('Do you want to attach to sprint?')
|
83
|
+
|
84
|
+
sprint_id = prompt_base.select_sprint(board_id: target_board[:id])
|
85
|
+
jira_sprint = JiraCommand::Jira::Sprint.new(config)
|
86
|
+
jira_sprint.move_issue(issue_key: issue_key, sprint_id: sprint_id)
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'comment', 'comment to issue'
|
90
|
+
option 'message', aliases: 'm', required: false
|
91
|
+
def comment(issue_key)
|
92
|
+
config = JiraCommand::Config.new.read
|
93
|
+
jira_comment = JiraCommand::Jira::Issue.new(config)
|
94
|
+
|
95
|
+
jira_comment.comment(issue_key: issue_key, message: options['message'])
|
96
|
+
end
|
97
|
+
|
98
|
+
desc 'attach_epic', 'attach epic to issue'
|
99
|
+
option 'refresh-board', aliases: 'b', required: false
|
100
|
+
def attach_epic(issue_key)
|
101
|
+
config = JiraCommand::Config.new.read
|
102
|
+
|
103
|
+
baord_list = if !config[:boards].nil? && options['refresh-board'].nil?
|
104
|
+
config[:boards]
|
105
|
+
else
|
106
|
+
agile_board = JiraCommand::Jira::Board.new(config)
|
107
|
+
agile_board.list
|
108
|
+
end
|
109
|
+
|
110
|
+
target_board = baord_list.find { |item| item[:projectKey] == issue_key.split('-').first }
|
111
|
+
|
112
|
+
agile_epic = JiraCommand::Jira::Epic.new(config)
|
113
|
+
epics = agile_epic.list(board_id: target_board[:id])
|
114
|
+
|
115
|
+
prompt = TTY::Prompt.new
|
116
|
+
epic_id = prompt.select('Which epic does the created issue belong to?') do |menu|
|
117
|
+
epics.each do |item|
|
118
|
+
menu.choice name: item[:name], value: item[:id]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
agile_epic.move_issue(epic_id: epic_id, issue_key: issue_key)
|
123
|
+
end
|
124
|
+
|
125
|
+
desc 'attach_sprint', 'attach epic to issue'
|
126
|
+
option 'refresh-board', aliases: 'b', required: false
|
127
|
+
def attach_sprint(issue_key)
|
128
|
+
config = JiraCommand::Config.new.read
|
129
|
+
|
130
|
+
baord_list = if !config[:boards].nil? && options['refresh-board'].nil?
|
131
|
+
config[:boards]
|
132
|
+
else
|
133
|
+
agile_board = JiraCommand::Jira::Board.new(config)
|
134
|
+
agile_board.list
|
135
|
+
end
|
136
|
+
|
137
|
+
target_board = baord_list.find { |item| item[:projectKey] == issue_key.split('-').first }
|
138
|
+
|
139
|
+
sprint_id = JiraCommand::Prompt::Base.new.select_sprint(board_id: target_board[:id])
|
140
|
+
|
141
|
+
jira_sprint = JiraCommand::Jira::Sprint.new(config)
|
142
|
+
|
143
|
+
jira_sprint.move_issue(issue_key: issue_key, sprint_id: sprint_id)
|
77
144
|
end
|
78
145
|
end
|
79
146
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'jira_command'
|
2
2
|
require 'thor'
|
3
3
|
require 'optparse'
|
4
|
-
require 'pry'
|
5
4
|
require_relative '../config'
|
6
5
|
require_relative '../jira/list'
|
6
|
+
require_relative '../jira/epic'
|
7
7
|
require 'tty-prompt'
|
8
8
|
require 'base64'
|
9
9
|
require 'terminal-table'
|
@@ -11,24 +11,20 @@ require 'terminal-table'
|
|
11
11
|
module JiraCommand
|
12
12
|
module Command
|
13
13
|
class List < Thor
|
14
|
-
default_command :
|
14
|
+
default_command :all
|
15
15
|
|
16
16
|
desc 'all', 'list issues'
|
17
|
+
option 'current', aliases: 'c', required: false
|
18
|
+
option 'unresolved', aliases: 'u', required: false
|
17
19
|
def all
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
show_in_console(config['jira_url'], issues_list['issues'])
|
22
|
-
end
|
20
|
+
jql = []
|
21
|
+
jql << 'sprint in openSprints()' unless options['current'].nil?
|
22
|
+
jql << 'status not in (resolved)' unless options['unresolved'].nil?
|
23
23
|
|
24
|
-
desc 'unresolved', 'list issues'
|
25
|
-
def unresolved
|
26
24
|
config = JiraCommand::Config.new.read
|
27
25
|
list = JiraCommand::Jira::List.new(config)
|
28
|
-
issues_list = list.list({
|
29
|
-
|
30
|
-
|
31
|
-
show_in_console(config['jira_url'], issues_list['issues'])
|
26
|
+
issues_list = list.list({ jql: jql.join('&') })
|
27
|
+
show_in_console(config[:jira_url], issues_list['issues'])
|
32
28
|
end
|
33
29
|
|
34
30
|
desc 'my', 'list your issues'
|
@@ -44,7 +40,22 @@ module JiraCommand
|
|
44
40
|
issues_list = list.list({ fields: 'id,key,status,issuetype,assignee,summary',
|
45
41
|
jql: jql.join('&') })
|
46
42
|
|
47
|
-
show_in_console(config[
|
43
|
+
show_in_console(config[:jira_url], issues_list['issues'])
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'without_epic', 'list your issues which has not epic'
|
47
|
+
def without_epic
|
48
|
+
config = JiraCommand::Config.new.read
|
49
|
+
agile_epic = JiraCommand::Jira::Epic.new(config)
|
50
|
+
|
51
|
+
jql = ["key in (#{agile_epic.issue_key_without_epic.join(', ')})"]
|
52
|
+
|
53
|
+
list = JiraCommand::Jira::List.new(config)
|
54
|
+
|
55
|
+
issues_list = list.list({ fields: 'id,key,status,issuetype,assignee,summary',
|
56
|
+
jql: jql.join('&') })
|
57
|
+
|
58
|
+
show_in_console(config[:jira_url], issues_list['issues'])
|
48
59
|
end
|
49
60
|
|
50
61
|
private
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'optparse'
|
3
|
+
require 'date'
|
4
|
+
require_relative '../config'
|
5
|
+
require_relative '../jira/sprint'
|
6
|
+
require_relative '../prompt/base'
|
7
|
+
|
8
|
+
module JiraCommand
|
9
|
+
module Command
|
10
|
+
class Sprint < Thor
|
11
|
+
desc 'list', 'list all sprints'
|
12
|
+
option 'future', aliases: 'f', required: false
|
13
|
+
option 'active', aliases: 'a', required: false
|
14
|
+
option 'closed', aliases: 'c', required: false
|
15
|
+
def list
|
16
|
+
config = JiraCommand::Config.new.read
|
17
|
+
|
18
|
+
board_id = JiraCommand::Prompt::Base.new.select_board
|
19
|
+
jira_sprint = JiraCommand::Jira::Sprint.new(config)
|
20
|
+
state = []
|
21
|
+
state << 'future' unless options['future'].nil?
|
22
|
+
state << 'active' unless options['active'].nil?
|
23
|
+
state << 'closed' unless options['closed'].nil?
|
24
|
+
res = jira_sprint.list(board_id: board_id, query: { state: state })
|
25
|
+
|
26
|
+
puts(res.map { |item| item[:name] })
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'create', 'create sprint'
|
30
|
+
option 'start_datetime', aliases: 's', required: true
|
31
|
+
option 'end_datetime', aliases: 'e', required: true
|
32
|
+
def create(name)
|
33
|
+
config = JiraCommand::Config.new.read
|
34
|
+
|
35
|
+
board_id = JiraCommand::Prompt::Base.new.select_board
|
36
|
+
|
37
|
+
jira_sprint = JiraCommand::Jira::Sprint.new(config)
|
38
|
+
|
39
|
+
jira_sprint.create(
|
40
|
+
name: name,
|
41
|
+
board_id: board_id,
|
42
|
+
start_date: DateTime.parse(options['start_datetime']).strftime('%Y-%m-%dT%H:%M:%S.%L+09:00'),
|
43
|
+
end_date: DateTime.parse(options['end_datetime']).strftime('%Y-%m-%dT%H:%M:%S.%L+09:00')
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -7,14 +7,13 @@ module JiraCommand
|
|
7
7
|
module Command
|
8
8
|
class Status < Thor
|
9
9
|
desc 'project', 'list status in specified project'
|
10
|
-
option 'project', aliases: 'p', required: true
|
11
10
|
def project
|
12
11
|
config = JiraCommand::Config.new.read
|
13
12
|
|
14
13
|
jira = JiraCommand::Jira::Status.new(config)
|
15
|
-
res = jira.list
|
14
|
+
res = jira.list
|
16
15
|
|
17
|
-
puts
|
16
|
+
puts(res.map { |item| item[:name] })
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -7,8 +7,6 @@ require_relative '../jira/transition'
|
|
7
7
|
module JiraCommand
|
8
8
|
module Command
|
9
9
|
class Transition < Thor
|
10
|
-
default_command :exec
|
11
|
-
|
12
10
|
desc 'exec', 'transit issue status'
|
13
11
|
option 'issue', aliases: 'i', required: true
|
14
12
|
def exec
|
@@ -60,7 +58,8 @@ module JiraCommand
|
|
60
58
|
menu.choice name: transition[:name], value: transition[:id]
|
61
59
|
end
|
62
60
|
end
|
63
|
-
|
61
|
+
|
62
|
+
jira.transite(issue_key: issue_key, target_transition_id: target_transition_id)
|
64
63
|
end
|
65
64
|
end
|
66
65
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'optparse'
|
3
|
-
|
3
|
+
|
4
4
|
require_relative '../config'
|
5
5
|
require_relative '../jira/user'
|
6
6
|
|
@@ -10,12 +10,11 @@ module JiraCommand
|
|
10
10
|
default_command :project
|
11
11
|
|
12
12
|
desc 'project', 'list issues in specified project'
|
13
|
-
|
14
|
-
def project
|
13
|
+
def project(pro)
|
15
14
|
config = JiraCommand::Config.new.read
|
16
15
|
|
17
16
|
user_api = JiraCommand::Jira::User.new(config)
|
18
|
-
user_api.show_assignable(project:
|
17
|
+
user_api.show_assignable(project: pro)
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
data/lib/jira_command/config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'jira_command'
|
2
2
|
require 'optparse'
|
3
|
-
|
3
|
+
|
4
4
|
require 'pathname'
|
5
5
|
require 'fileutils'
|
6
6
|
require 'json'
|
@@ -13,11 +13,11 @@ module JiraCommand
|
|
13
13
|
|
14
14
|
def initialize(config)
|
15
15
|
@config = config
|
16
|
-
@conn = Faraday.new(url: config[
|
16
|
+
@conn = Faraday.new(url: config[:jira_url]) do |faraday|
|
17
17
|
faraday.request :url_encoded
|
18
18
|
faraday.headers['Accept'] = 'application/json'
|
19
19
|
faraday.headers['Content-Type'] = 'application/json'
|
20
|
-
faraday.headers['Authorization'] = 'Basic ' + @config[
|
20
|
+
faraday.headers['Authorization'] = 'Basic ' + @config[:header_token]
|
21
21
|
faraday.adapter Faraday.default_adapter
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'jira_command'
|
2
|
+
require 'json'
|
3
|
+
require 'faraday'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
module JiraCommand
|
7
|
+
module Jira
|
8
|
+
class Board < JiraCommand::Jira::Base
|
9
|
+
BASE_PATH = 'rest/agile/1.0/board'.freeze
|
10
|
+
|
11
|
+
def list
|
12
|
+
res = @conn.get(BASE_PATH)
|
13
|
+
|
14
|
+
body = JSON.parse(res.body)
|
15
|
+
|
16
|
+
body['values'].map do |item|
|
17
|
+
location = item['location']
|
18
|
+
{ name: item['name'],
|
19
|
+
id: item['id'],
|
20
|
+
projectId: location['projectId'],
|
21
|
+
projectName: location['projectName'],
|
22
|
+
projectKey: location['projectKey'] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'jira_command'
|
2
|
+
require 'json'
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
require_relative 'base'
|
6
|
+
|
7
|
+
module JiraCommand
|
8
|
+
module Jira
|
9
|
+
class Epic < JiraCommand::Jira::Base
|
10
|
+
def list(board_id:)
|
11
|
+
res = @conn.get("rest/agile/1.0/board/#{board_id}/epic")
|
12
|
+
|
13
|
+
body = JSON.parse(res.body)
|
14
|
+
|
15
|
+
body['values'].map { |item| { name: item['name'], id: item['id'] } }
|
16
|
+
end
|
17
|
+
|
18
|
+
def move_issue(issue_key:, epic_id:)
|
19
|
+
@conn.post do |req|
|
20
|
+
req.url "rest/agile/1.0/epic/#{epic_id}/issue"
|
21
|
+
req.body = {
|
22
|
+
issues: [
|
23
|
+
issue_key
|
24
|
+
]
|
25
|
+
}.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def issue_key_without_epic
|
30
|
+
res = @conn.get('rest/agile/1.0/epic/none/issue')
|
31
|
+
body = JSON.parse(res.body)
|
32
|
+
|
33
|
+
body['issues'].map { |item| item['key'] }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -8,8 +8,17 @@ module JiraCommand
|
|
8
8
|
class Issue < JiraCommand::Jira::Base
|
9
9
|
BASE_PATH = 'rest/api/2/issue'.freeze
|
10
10
|
|
11
|
+
def comment(issue_key:, message:)
|
12
|
+
@conn.post do |req|
|
13
|
+
req.url "rest/api/2/issue/#{issue_key}/comment"
|
14
|
+
req.body = {
|
15
|
+
body: message
|
16
|
+
}.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
11
20
|
def create(summary:, description:, assignee:, reporter:, project_id:, issuetype_id:)
|
12
|
-
|
21
|
+
fields = {
|
13
22
|
project: {
|
14
23
|
id: project_id
|
15
24
|
},
|
@@ -17,23 +26,26 @@ module JiraCommand
|
|
17
26
|
issuetype: {
|
18
27
|
id: issuetype_id
|
19
28
|
},
|
20
|
-
assignee: {
|
21
|
-
id: assignee
|
22
|
-
},
|
23
29
|
reporter: {
|
24
30
|
id: reporter
|
25
31
|
},
|
26
32
|
description: description
|
27
|
-
}
|
33
|
+
}
|
34
|
+
|
35
|
+
unless assignee.nil?
|
36
|
+
fields.merge!(assignee: {
|
37
|
+
id: assignee
|
38
|
+
})
|
39
|
+
end
|
28
40
|
|
29
41
|
res = @conn.post do |req|
|
30
42
|
req.url BASE_PATH
|
31
|
-
req.body =
|
43
|
+
req.body = { fields: fields }.to_json
|
32
44
|
end
|
33
45
|
|
34
46
|
body = JSON.parse(res.body)
|
35
47
|
|
36
|
-
|
48
|
+
body['key']
|
37
49
|
end
|
38
50
|
end
|
39
51
|
end
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'jira_command'
|
2
2
|
require 'thor'
|
3
3
|
require 'optparse'
|
4
|
-
|
4
|
+
|
5
5
|
require 'pathname'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'json'
|
@@ -16,6 +16,7 @@ module JiraCommand
|
|
16
16
|
def list(query = {})
|
17
17
|
request_url = BASE_PATH + URI.encode_www_form(query)
|
18
18
|
res = @conn.get(request_url)
|
19
|
+
|
19
20
|
JSON.parse(res.body)
|
20
21
|
end
|
21
22
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'jira_command'
|
2
|
+
require 'faraday'
|
3
|
+
require 'json'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
module JiraCommand
|
7
|
+
module Jira
|
8
|
+
class Sprint < JiraCommand::Jira::Base
|
9
|
+
# https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/board/{boardId}/sprint-getAllSprints
|
10
|
+
def list(board_id:, query: {})
|
11
|
+
res = @conn.get("rest/agile/1.0/board/#{board_id}/sprint?" + URI.encode_www_form(query))
|
12
|
+
|
13
|
+
body = JSON.parse(res.body)
|
14
|
+
|
15
|
+
body['values'].map do |item|
|
16
|
+
{
|
17
|
+
name: item['name'],
|
18
|
+
id: item['id'],
|
19
|
+
state: item['state'],
|
20
|
+
start_date: item['startDate'],
|
21
|
+
end_date: item['endDate']
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def move_issue(issue_key:, sprint_id:)
|
27
|
+
@conn.post do |req|
|
28
|
+
req.url "rest/agile/1.0/sprint/#{sprint_id}/issue"
|
29
|
+
req.body = {
|
30
|
+
issues: [
|
31
|
+
issue_key
|
32
|
+
]
|
33
|
+
}.to_json
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/sprint-createSprint
|
38
|
+
def create(name:, board_id:, start_date:, end_date:)
|
39
|
+
request_body = {
|
40
|
+
name: name,
|
41
|
+
originBoardId: board_id
|
42
|
+
}
|
43
|
+
|
44
|
+
request_body.merge!({ startDate: start_date }) unless start_date.nil?
|
45
|
+
request_body.merge!({ endDate: end_date }) unless end_date.nil?
|
46
|
+
|
47
|
+
@conn.post do |req|
|
48
|
+
req.url 'rest/agile/1.0/sprint'
|
49
|
+
req.body = request_body.to_json
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'jira_command'
|
2
|
-
|
2
|
+
|
3
3
|
require 'json'
|
4
4
|
require 'faraday'
|
5
5
|
require_relative 'base'
|
@@ -12,9 +12,9 @@ module JiraCommand
|
|
12
12
|
def list
|
13
13
|
res = @conn.get(BASE_PATH)
|
14
14
|
|
15
|
-
|
15
|
+
body = JSON.parse(res.body)
|
16
16
|
|
17
|
-
|
17
|
+
body.map { |item| { id: item['id'], name: item['untranslatedName'] } }
|
18
18
|
end
|
19
19
|
|
20
20
|
def transite(issue_key:, target_status_id:)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'jira_command'
|
2
|
-
|
2
|
+
|
3
3
|
require 'json'
|
4
4
|
require 'faraday'
|
5
5
|
require_relative 'base'
|
@@ -11,9 +11,9 @@ module JiraCommand
|
|
11
11
|
request_url = "rest/api/2/issue/#{issue_key}/transitions"
|
12
12
|
res = @conn.get(request_url)
|
13
13
|
|
14
|
-
|
14
|
+
body = JSON.parse(res.body)
|
15
15
|
|
16
|
-
|
16
|
+
body['transitions'].map { |item| { id: item['id'].to_i, name: item['name'] } }
|
17
17
|
end
|
18
18
|
|
19
19
|
def transite(issue_key:, target_transition_id:)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'jira_command'
|
2
2
|
require 'thor'
|
3
3
|
require 'optparse'
|
4
|
-
|
4
|
+
|
5
5
|
require 'pathname'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'json'
|
@@ -15,16 +15,14 @@ module JiraCommand
|
|
15
15
|
|
16
16
|
def all_list(project:)
|
17
17
|
request_url = BASE_PATH + project
|
18
|
-
|
19
18
|
res = @conn.get(request_url)
|
20
|
-
|
21
19
|
body = JSON.parse(res.body)
|
22
20
|
|
23
21
|
body.map { |item| { name: item['displayName'], account_id: item['accountId'] } }
|
24
22
|
end
|
25
23
|
|
26
24
|
def show_assignable(project:)
|
27
|
-
puts
|
25
|
+
puts(all_list(project: project).map { |item| item[:name] })
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require_relative '../config'
|
2
|
+
require_relative '../jira/sprint'
|
3
|
+
require_relative '../jira/user'
|
4
|
+
require_relative '../jira/issue_type'
|
5
|
+
require 'tty-prompt'
|
6
|
+
|
7
|
+
module JiraCommand
|
8
|
+
module Prompt
|
9
|
+
class Base
|
10
|
+
attr_writer :prompt, :config
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@prompt = TTY::Prompt.new
|
14
|
+
@config = JiraCommand::Config.new.read
|
15
|
+
end
|
16
|
+
|
17
|
+
def select_board(message: 'Please select board', refresh: false)
|
18
|
+
baord_list = if @config[:boards].nil? || refresh
|
19
|
+
agile_board = JiraCommand::Jira::Board.new(@config)
|
20
|
+
agile_board.list
|
21
|
+
else
|
22
|
+
@config[:boards]
|
23
|
+
end
|
24
|
+
|
25
|
+
@prompt.select(message) do |menu|
|
26
|
+
baord_list.each do |item|
|
27
|
+
menu.choice name: item[:name], value: item[:id]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def select_issue_type(message:, refresh: false)
|
33
|
+
issue_types = if @config[:issue_types].nil? || refresh
|
34
|
+
jira_issue_type = JiraCommand::Jira::IssueType.new(@config)
|
35
|
+
jira_issue_type.list
|
36
|
+
else
|
37
|
+
@config[:issue_types]
|
38
|
+
end
|
39
|
+
|
40
|
+
@prompt.select(message) do |menu|
|
41
|
+
issue_types.each do |item|
|
42
|
+
menu.choice name: item[:name], value: { id: item[:id], name: item[:name] }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def select_project(message:, refresh: false)
|
48
|
+
projects = if @config[:projects].nil? || refresh
|
49
|
+
jira_project = JiraCommand::Jira::Project.new(@config)
|
50
|
+
jira_project.list
|
51
|
+
else
|
52
|
+
@config[:projects]
|
53
|
+
end
|
54
|
+
|
55
|
+
@prompt.select(message) do |menu|
|
56
|
+
projects.each do |item|
|
57
|
+
menu.choice name: item[:name], value: { id: item[:id], key: item[:key] }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def select_user(message:,
|
63
|
+
project_key: nil,
|
64
|
+
refresh: false,
|
65
|
+
additional: [])
|
66
|
+
user_list = if @config[:users].nil? || refresh
|
67
|
+
user_api = JiraCommand::Jira::User.new(@config)
|
68
|
+
user_api.all_list(project: project_key)
|
69
|
+
else
|
70
|
+
@config[:users]
|
71
|
+
end
|
72
|
+
|
73
|
+
@prompt.select(message) do |menu|
|
74
|
+
additional.each do |item|
|
75
|
+
menu.choice name: item[:name], value: item[:account_id]
|
76
|
+
end
|
77
|
+
user_list.each do |item|
|
78
|
+
menu.choice name: item[:name], value: item[:account_id]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def select_sprint(message: 'Please select sprint:', board_id:, state: 'active,future')
|
84
|
+
jira_sprint = JiraCommand::Jira::Sprint.new(@config)
|
85
|
+
res = jira_sprint.list(
|
86
|
+
board_id: board_id,
|
87
|
+
query: { state: state }
|
88
|
+
)
|
89
|
+
|
90
|
+
@prompt.select(message) do |menu|
|
91
|
+
res.each do |item|
|
92
|
+
menu.choice name: item[:name], value: item[:id]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/jira_command/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira_command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shengbo.xu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: thor
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +52,20 @@ dependencies:
|
|
24
52
|
- - ">="
|
25
53
|
- !ruby/object:Gem::Version
|
26
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-prompt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
27
69
|
description: jira cli tool
|
28
70
|
email:
|
29
71
|
- shengbo.xu@xincere.jp
|
@@ -52,19 +94,24 @@ files:
|
|
52
94
|
- lib/jira_command/command/config.rb
|
53
95
|
- lib/jira_command/command/issue.rb
|
54
96
|
- lib/jira_command/command/list.rb
|
97
|
+
- lib/jira_command/command/sprint.rb
|
55
98
|
- lib/jira_command/command/status.rb
|
56
99
|
- lib/jira_command/command/transition.rb
|
57
100
|
- lib/jira_command/command/user.rb
|
58
101
|
- lib/jira_command/config.rb
|
59
102
|
- lib/jira_command/jira/assign.rb
|
60
103
|
- lib/jira_command/jira/base.rb
|
104
|
+
- lib/jira_command/jira/board.rb
|
105
|
+
- lib/jira_command/jira/epic.rb
|
61
106
|
- lib/jira_command/jira/issue.rb
|
62
|
-
- lib/jira_command/jira/
|
107
|
+
- lib/jira_command/jira/issue_type.rb
|
63
108
|
- lib/jira_command/jira/list.rb
|
64
109
|
- lib/jira_command/jira/project.rb
|
110
|
+
- lib/jira_command/jira/sprint.rb
|
65
111
|
- lib/jira_command/jira/status.rb
|
66
112
|
- lib/jira_command/jira/transition.rb
|
67
113
|
- lib/jira_command/jira/user.rb
|
114
|
+
- lib/jira_command/prompt/base.rb
|
68
115
|
- lib/jira_command/version.rb
|
69
116
|
homepage: https://github.com/xincere-inc/jira_command
|
70
117
|
licenses:
|