dude-cli 2.1.0.alpha2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/verify.yml +2 -2
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +29 -9
- data/README.md +44 -44
- data/dude.gemspec +3 -2
- data/lib/dude.rb +11 -1
- data/lib/dude/code_management/github/client.rb +7 -3
- data/lib/dude/code_management/github/create_pull_request.rb +16 -8
- data/lib/dude/commands.rb +4 -0
- data/lib/dude/commands/commit.rb +23 -0
- data/lib/dude/commands/health_check.rb +15 -0
- data/lib/dude/commands/install.rb +63 -53
- data/lib/dude/commands/pr/remove.rb +1 -1
- data/lib/dude/commands/start.rb +6 -8
- data/lib/dude/commands/stop.rb +0 -2
- data/lib/dude/commands/tasks.rb +0 -2
- data/lib/dude/commands/track.rb +2 -4
- data/lib/dude/config.rb +18 -0
- data/lib/dude/git.rb +1 -0
- data/lib/dude/git/commit.rb +20 -0
- data/lib/dude/health_check.rb +39 -0
- data/lib/dude/project_management/client.rb +1 -3
- data/lib/dude/project_management/jira/client.rb +16 -8
- data/lib/dude/project_management/jira/fetch_current_task.rb +3 -3
- data/lib/dude/project_management/jira/fetch_current_tasks.rb +2 -4
- data/lib/dude/project_management/jira/get_task_name_by_id.rb +0 -2
- data/lib/dude/project_management/jira/move_task_to_list.rb +0 -2
- data/lib/dude/project_management/trello/client.rb +9 -5
- data/lib/dude/project_management/trello/fetch_current_task.rb +2 -4
- data/lib/dude/project_management/trello/fetch_current_tasks.rb +0 -2
- data/lib/dude/project_management/trello/fetch_lists.rb +1 -3
- data/lib/dude/project_management/trello/get_task_name_by_id.rb +1 -3
- data/lib/dude/project_management/trello/move_task_to_list.rb +1 -3
- data/lib/dude/setup/github.rb +35 -0
- data/lib/dude/setup/jira.rb +64 -0
- data/lib/dude/setup/toggl.rb +47 -0
- data/lib/dude/setup/trello.rb +58 -0
- data/lib/dude/templates/duderc_template +32 -0
- data/lib/dude/time_trackers/toggl/base.rb +2 -4
- data/lib/dude/version.rb +1 -1
- metadata +29 -6
- data/lib/dude/templates/pull_request_template +0 -7
@@ -12,13 +12,11 @@ module Dude
|
|
12
12
|
module ProjectManagement
|
13
13
|
module Trello
|
14
14
|
class Client
|
15
|
-
include Settings
|
16
|
-
|
17
15
|
def client
|
18
16
|
@client ||= Faraday.new('https://api.trello.com/', {
|
19
17
|
params: {
|
20
|
-
key:
|
21
|
-
token:
|
18
|
+
key: Dude::SETTINGS.dig(:trello, :key),
|
19
|
+
token: Dude::SETTINGS.dig(:trello, :token)
|
22
20
|
}
|
23
21
|
})
|
24
22
|
end
|
@@ -28,7 +26,7 @@ module Dude
|
|
28
26
|
end
|
29
27
|
|
30
28
|
def respond_to_missing?(method_name, include_private = false)
|
31
|
-
client.
|
29
|
+
client.respond_to?(method_name, include_private)
|
32
30
|
end
|
33
31
|
|
34
32
|
def fetch_current_tasks
|
@@ -46,6 +44,12 @@ module Dude
|
|
46
44
|
def get_task_name_by_id(id)
|
47
45
|
GetTaskNameById.new(client, id: id).call
|
48
46
|
end
|
47
|
+
|
48
|
+
def health_check
|
49
|
+
client.get("/1/tokens/#{Dude::SETTINGS.dig(:trello, :token)}").status == 200
|
50
|
+
rescue StandardError
|
51
|
+
false
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -4,15 +4,13 @@ module Dude
|
|
4
4
|
module ProjectManagement
|
5
5
|
module Trello
|
6
6
|
class FetchCurrentTask
|
7
|
-
include Settings
|
8
|
-
|
9
7
|
def initialize(client, id:)
|
10
8
|
@client = client
|
11
9
|
@id = id
|
12
10
|
end
|
13
11
|
|
14
12
|
def call
|
15
|
-
response = client.get("/1/boards/#{
|
13
|
+
response = client.get("/1/boards/#{Dude::SETTINGS.dig(:jira, :board_id)}/cards/#{id}")
|
16
14
|
create_issue JSON.parse(response.body)
|
17
15
|
end
|
18
16
|
|
@@ -25,7 +23,7 @@ module Dude
|
|
25
23
|
id: issue['idShort'],
|
26
24
|
title: issue['name'],
|
27
25
|
description: issue['desc'],
|
28
|
-
status:
|
26
|
+
status: Dude::SETTINGS[:in_progress_list_name], # OMG, let's fix this later
|
29
27
|
assignee: members(issue),
|
30
28
|
url: issue['shortUrl']
|
31
29
|
)
|
@@ -4,14 +4,12 @@ module Dude
|
|
4
4
|
module ProjectManagement
|
5
5
|
module Trello
|
6
6
|
class FetchLists
|
7
|
-
include Settings
|
8
|
-
|
9
7
|
def initialize(client)
|
10
8
|
@client = client
|
11
9
|
end
|
12
10
|
|
13
11
|
def call
|
14
|
-
response = client.get("/1/board/#{
|
12
|
+
response = client.get("/1/board/#{Dude::SETTINGS.dig(:jira, :board_id)}/lists", { fields: 'name' })
|
15
13
|
JSON.parse(response.body)
|
16
14
|
end
|
17
15
|
|
@@ -4,15 +4,13 @@ module Dude
|
|
4
4
|
module ProjectManagement
|
5
5
|
module Trello
|
6
6
|
class GetTaskNameById
|
7
|
-
include Settings
|
8
|
-
|
9
7
|
def initialize(client, id:)
|
10
8
|
@client = client
|
11
9
|
@id = id
|
12
10
|
end
|
13
11
|
|
14
12
|
def call
|
15
|
-
response = client.get("/1/boards/#{
|
13
|
+
response = client.get("/1/boards/#{Dude::SETTINGS.dig(:jira, :board_id)}/cards/#{id}")
|
16
14
|
JSON.parse(response.body)['name']
|
17
15
|
end
|
18
16
|
|
@@ -6,8 +6,6 @@ module Dude
|
|
6
6
|
module ProjectManagement
|
7
7
|
module Trello
|
8
8
|
class MoveTaskToList
|
9
|
-
include Settings
|
10
|
-
|
11
9
|
def initialize(client, id:, list_name:)
|
12
10
|
@client = client
|
13
11
|
@id = id
|
@@ -15,7 +13,7 @@ module Dude
|
|
15
13
|
end
|
16
14
|
|
17
15
|
def call
|
18
|
-
response = client.get("/1/boards/#{
|
16
|
+
response = client.get("/1/boards/#{Dude::SETTINGS.dig(:jira, :board_id)}/cards/#{id}", { fields: 'id' })
|
19
17
|
card_id = JSON.parse(response.body)['id']
|
20
18
|
client.put("/1/cards/#{card_id}", { idList: list_id })
|
21
19
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dude
|
4
|
+
module Setup
|
5
|
+
class Github
|
6
|
+
def initialize(prompt)
|
7
|
+
@prompt = prompt
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(settings:)
|
11
|
+
settings[:github][:token] = setup_token
|
12
|
+
settings
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :prompt
|
18
|
+
|
19
|
+
def setup_token
|
20
|
+
puts <<~HEREDOC
|
21
|
+
You need to create personal token
|
22
|
+
|
23
|
+
#{'1.'.bold} Log in to https://github.com/settings/tokens
|
24
|
+
#{'2.'.bold} Copy the token and paste it below
|
25
|
+
HEREDOC
|
26
|
+
|
27
|
+
if prompt.yes?(Dude::Config.style_prompt('Open Github token creation page in your browser?'))
|
28
|
+
`open https://github.com/settings/tokens`
|
29
|
+
end
|
30
|
+
|
31
|
+
prompt.ask(Dude::Config.style_prompt('Github token:'), required: true)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dude
|
4
|
+
module Setup
|
5
|
+
class Jira
|
6
|
+
def initialize(prompt)
|
7
|
+
@prompt = prompt
|
8
|
+
end
|
9
|
+
|
10
|
+
# rubocop:disable Metrics/AbcSize
|
11
|
+
def call(settings:)
|
12
|
+
settings[:jira][:email] = setup_email
|
13
|
+
settings[:jira][:token] = setup_token
|
14
|
+
settings[:jira][:project][:url] = setup_project_url
|
15
|
+
settings[:jira][:project][:key] = setup_project_key
|
16
|
+
settings[:jira][:board_id] = setup_board_id
|
17
|
+
settings
|
18
|
+
end
|
19
|
+
# rubocop:enable Metrics/AbcSize
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :prompt
|
24
|
+
|
25
|
+
def setup_email
|
26
|
+
prompt.ask(Dude::Config.style_prompt('Jira user email:'), required: true)
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_token
|
30
|
+
puts <<~HEREDOC
|
31
|
+
You need to create personal token
|
32
|
+
|
33
|
+
#{'1.'.bold} Log in to https://id.atlassian.com/manage/api-tokens
|
34
|
+
#{'2.'.bold} Click 'Create API token.'
|
35
|
+
#{'3.'.bold} From the dialog that appears, enter a memorable and concise 'Label' for your token and click 'Create.'
|
36
|
+
#{'4.'.bold} Use 'Copy to clipboard' and paste the token below
|
37
|
+
HEREDOC
|
38
|
+
|
39
|
+
if prompt.yes?(Dude::Config.style_prompt('Open Atlassian token creation page in your browser?'))
|
40
|
+
`open https://id.atlassian.com/manage-profile/security/api-tokens`
|
41
|
+
end
|
42
|
+
|
43
|
+
prompt.ask(Dude::Config.style_prompt('Jira token:'), required: true)
|
44
|
+
end
|
45
|
+
|
46
|
+
def setup_project_url
|
47
|
+
prompt.ask(Dude::Config.style_prompt('URL of your project (Example: https://example.atlassian.net):'), {
|
48
|
+
required: true
|
49
|
+
})
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup_project_key
|
53
|
+
prompt.ask(Dude::Config.style_prompt('KEY of your project (If your issues have id BT-123 - BT is the key):'), {
|
54
|
+
required: true
|
55
|
+
})
|
56
|
+
end
|
57
|
+
|
58
|
+
def setup_board_id
|
59
|
+
puts 'Just open your atlassian main board and copy id from the url after rapidView=ID part.'
|
60
|
+
prompt.ask(Dude::Config.style_prompt('Board ID:'), required: true)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dude
|
4
|
+
module Setup
|
5
|
+
class Toggl
|
6
|
+
def initialize(prompt)
|
7
|
+
@prompt = prompt
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(settings:)
|
11
|
+
settings[:toggl][:token] = setup_token
|
12
|
+
settings[:toggl][:project_name] = setup_project_name
|
13
|
+
settings[:toggl][:workspace_id] = setup_workspace_id
|
14
|
+
settings
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :prompt
|
20
|
+
|
21
|
+
def setup_token
|
22
|
+
puts <<~HEREDOC
|
23
|
+
You need to create personal token
|
24
|
+
|
25
|
+
#{'1.'.bold} Log in to https://trello.com/app-key
|
26
|
+
#{'2.'.bold} Your Toggl API token can be found at the bottom of the page
|
27
|
+
#{'3.'.bold} Press --Click to Reveal-- and paste token below
|
28
|
+
HEREDOC
|
29
|
+
|
30
|
+
if prompt.yes?(Dude::Config.style_prompt('Open Toggl profile page in your browser?'))
|
31
|
+
`open https://track.toggl.com/profile`
|
32
|
+
end
|
33
|
+
|
34
|
+
prompt.ask(Dude::Config.style_prompt('Toggl token:'), required: true)
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_project_name
|
38
|
+
prompt.ask(Dude::Config.style_prompt('Your Toggl project name:'), required: true)
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_workspace_id
|
42
|
+
puts 'Can be copied from url here: https://toggl.com/app/projects/ (Example: 123456)'
|
43
|
+
prompt.ask(Dude::Config.style_prompt('Workspace ID:'), required: true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dude
|
4
|
+
module Setup
|
5
|
+
class Trello
|
6
|
+
def initialize(prompt)
|
7
|
+
@prompt = prompt
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(settings:)
|
11
|
+
settings[:trello][:key] = setup_key
|
12
|
+
settings[:trello][:token] = setup_token
|
13
|
+
settings[:trello][:board_id] = setup_board_id
|
14
|
+
settings
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :prompt
|
20
|
+
|
21
|
+
def setup_email
|
22
|
+
prompt.ask(Dude::Config.style_prompt('Jira user email:'), required: true)
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_key
|
26
|
+
puts <<~HEREDOC
|
27
|
+
You need to create personal token
|
28
|
+
|
29
|
+
#{'1.'.bold} Log in to https://trello.com/app-key
|
30
|
+
#{'2.'.bold} Copy KEY and paste it below
|
31
|
+
HEREDOC
|
32
|
+
|
33
|
+
if prompt.yes?(Dude::Config.style_prompt('Open Trello token creation page in your browser?'))
|
34
|
+
`open https://trello.com/app-key`
|
35
|
+
end
|
36
|
+
|
37
|
+
prompt.ask(Dude::Config.style_prompt('Trello key:'), required: true)
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup_token
|
41
|
+
puts <<~HEREDOC
|
42
|
+
You need to create personal token
|
43
|
+
|
44
|
+
#{'1.'.bold} Log in to https://trello.com/app-key
|
45
|
+
#{'2.'.bold} From the dialog that appears click 'Allow'
|
46
|
+
#{'3.'.bold} Copy created token to clipboard and paste the it below
|
47
|
+
HEREDOC
|
48
|
+
|
49
|
+
prompt.ask(Dude::Config.style_prompt('Trello token:'), required: true)
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup_board_id
|
53
|
+
puts 'Just open your Trello main board and copy id from the url (Example: 123aBcdE)'
|
54
|
+
prompt.ask(Dude::Config.style_prompt('Board ID:'), required: true)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
:project_management_tool: jira
|
3
|
+
:jira:
|
4
|
+
:email:
|
5
|
+
:token:
|
6
|
+
:project:
|
7
|
+
:url:
|
8
|
+
:key:
|
9
|
+
:board_id:
|
10
|
+
:trello:
|
11
|
+
:board_id:
|
12
|
+
:key:
|
13
|
+
:token:
|
14
|
+
:todo_list_name: To Do
|
15
|
+
:in_progress_list_name: In Progress
|
16
|
+
:code_review_list_name: Code Review
|
17
|
+
:testing_list_name: TESTABLE
|
18
|
+
:done_list_name: Done
|
19
|
+
:toggl:
|
20
|
+
:project_name:
|
21
|
+
:token:
|
22
|
+
:workspace_id:
|
23
|
+
:task_format: "[{issue_id}] {issue_title}"
|
24
|
+
:github:
|
25
|
+
:token:
|
26
|
+
:pr_template:
|
27
|
+
:title: "[{issue_id}] {issue_title}\n"
|
28
|
+
:body: |
|
29
|
+
## Story
|
30
|
+
[**\[{issue_id}\] {issue_title}**]({issue_url})
|
31
|
+
## Description
|
32
|
+
Example description of the issue
|
@@ -5,17 +5,15 @@ require 'faraday'
|
|
5
5
|
module Dude
|
6
6
|
module Toggl
|
7
7
|
class Base
|
8
|
-
include Settings
|
9
|
-
|
10
8
|
def toggl_api
|
11
9
|
Faraday.new('https://api.track.toggl.com') do |conn|
|
12
|
-
conn.basic_auth
|
10
|
+
conn.basic_auth Dude::SETTINGS.dig(:toggl, :token), 'api_token'
|
13
11
|
conn.headers['Content-Type'] = 'application/json'
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
15
|
def projects_response
|
18
|
-
toggl_api.get("/api/v8/workspaces/#{
|
16
|
+
toggl_api.get("/api/v8/workspaces/#{Dude::SETTINGS.dig(:toggl, :workspace_id)}/projects")
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
data/lib/dude/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dude-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Pupko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-prompt
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.23.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.23.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +197,8 @@ files:
|
|
183
197
|
- lib/dude/code_management/github/create_pull_request.rb
|
184
198
|
- lib/dude/commands.rb
|
185
199
|
- lib/dude/commands/checkout.rb
|
200
|
+
- lib/dude/commands/commit.rb
|
201
|
+
- lib/dude/commands/health_check.rb
|
186
202
|
- lib/dude/commands/install.rb
|
187
203
|
- lib/dude/commands/move.rb
|
188
204
|
- lib/dude/commands/pr.rb
|
@@ -193,10 +209,13 @@ files:
|
|
193
209
|
- lib/dude/commands/tasks.rb
|
194
210
|
- lib/dude/commands/track.rb
|
195
211
|
- lib/dude/commands/version.rb
|
212
|
+
- lib/dude/config.rb
|
196
213
|
- lib/dude/git.rb
|
197
214
|
- lib/dude/git/checkout.rb
|
215
|
+
- lib/dude/git/commit.rb
|
198
216
|
- lib/dude/git/current_branch_name.rb
|
199
217
|
- lib/dude/git/remote_name.rb
|
218
|
+
- lib/dude/health_check.rb
|
200
219
|
- lib/dude/project_management/client.rb
|
201
220
|
- lib/dude/project_management/entities/issue.rb
|
202
221
|
- lib/dude/project_management/jira.rb
|
@@ -213,7 +232,11 @@ files:
|
|
213
232
|
- lib/dude/project_management/trello/get_task_name_by_id.rb
|
214
233
|
- lib/dude/project_management/trello/move_task_to_list.rb
|
215
234
|
- lib/dude/settings.rb
|
216
|
-
- lib/dude/
|
235
|
+
- lib/dude/setup/github.rb
|
236
|
+
- lib/dude/setup/jira.rb
|
237
|
+
- lib/dude/setup/toggl.rb
|
238
|
+
- lib/dude/setup/trello.rb
|
239
|
+
- lib/dude/templates/duderc_template
|
217
240
|
- lib/dude/time_trackers/toggl.rb
|
218
241
|
- lib/dude/time_trackers/toggl/base.rb
|
219
242
|
- lib/dude/time_trackers/toggl/start_time_entry.rb
|
@@ -234,12 +257,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
234
257
|
requirements:
|
235
258
|
- - ">="
|
236
259
|
- !ruby/object:Gem::Version
|
237
|
-
version: 2.
|
260
|
+
version: 2.7.0
|
238
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
262
|
requirements:
|
240
|
-
- - "
|
263
|
+
- - ">="
|
241
264
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
265
|
+
version: '0'
|
243
266
|
requirements: []
|
244
267
|
rubygems_version: 3.1.4
|
245
268
|
signing_key:
|