renuo-cli 4.5.0 → 4.5.1
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 +1 -1
- data/Rakefile +3 -3
- data/lib/renuo/cli/app/command_helper.rb +4 -4
- data/lib/renuo/cli/app/commit_leaderboard_stage.rb +109 -0
- data/lib/renuo/cli/app/commit_leaderboard_sync.rb +20 -20
- data/lib/renuo/cli/app/configure_semaphore.rb +8 -8
- data/lib/renuo/cli/app/configure_sentry.rb +5 -5
- data/lib/renuo/cli/app/create_aws_project.rb +23 -23
- data/lib/renuo/cli/app/create_heroku_app.rb +2 -3
- data/lib/renuo/cli/app/create_new_logins.rb +5 -5
- data/lib/renuo/cli/app/create_slidev_presentation.rb +11 -11
- data/lib/renuo/cli/app/environments.rb +3 -3
- data/lib/renuo/cli/app/fetch_emails.rb +6 -6
- data/lib/renuo/cli/app/generate_password.rb +2 -2
- data/lib/renuo/cli/app/heroku_apps.rb +1 -1
- data/lib/renuo/cli/app/heroku_users.rb +3 -3
- data/lib/renuo/cli/app/local_storage.rb +5 -5
- data/lib/renuo/cli/app/name_display.rb +11 -11
- data/lib/renuo/cli/app/redmine/csv_base_service.rb +5 -5
- data/lib/renuo/cli/app/redmine/issue.rb +3 -3
- data/lib/renuo/cli/app/release_project.rb +25 -25
- data/lib/renuo/cli/app/release_xing.rb +5 -5
- data/lib/renuo/cli/app/renuo_version.rb +2 -2
- data/lib/renuo/cli/app/secrets_fetcher.rb +18 -18
- data/lib/renuo/cli/app/services/cloudfront_config_service.rb +13 -13
- data/lib/renuo/cli/app/services/markdown_parser_service.rb +3 -3
- data/lib/renuo/cli/app/services/renuo_cli_config.rb +4 -4
- data/lib/renuo/cli/app/setup_uptimerobot.rb +17 -17
- data/lib/renuo/cli/app/toggl/detail.rb +4 -4
- data/lib/renuo/cli/app/toggl/time_entry.rb +4 -4
- data/lib/renuo/cli/app/toggl/user.rb +3 -3
- data/lib/renuo/cli/app/toggl/workspace.rb +3 -3
- data/lib/renuo/cli/app/toggl_redmine_comparator.rb +26 -26
- data/lib/renuo/cli/app/upgrade_laptop/upgrade_laptop_execution.rb +4 -4
- data/lib/renuo/cli/app/upgrade_laptop/upgrade_mac_os.rb +4 -4
- data/lib/renuo/cli/app/upgrade_laptop.rb +4 -4
- data/lib/renuo/cli/app/work.rb +12 -12
- data/lib/renuo/cli/version.rb +2 -2
- data/lib/renuo/cli.rb +148 -146
- data/renuo-cli.gemspec +33 -33
- metadata +3 -3
- data/lib/renuo/cli/app/commit_leaderboard.rb +0 -130
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CommitLeaderboard
|
|
4
|
-
attr_accessor :queue_file_path, :author_username, :auhor_avatar_url
|
|
5
|
-
|
|
6
|
-
def run(args)
|
|
7
|
-
abort 'No author username given.' if args[0].nil?
|
|
8
|
-
abort 'No author avatar url given.' if args[1].nil?
|
|
9
|
-
|
|
10
|
-
@author_username = args[0]
|
|
11
|
-
@author_avatar_url = args[1]
|
|
12
|
-
|
|
13
|
-
@queue_file_path = args[2] || '~/.renuo-commit-leaderboard.json'
|
|
14
|
-
@queue_file_path = File.expand_path(@queue_file_path)
|
|
15
|
-
|
|
16
|
-
check_required_tools
|
|
17
|
-
check_if_repository_is_present
|
|
18
|
-
check_if_commit_is_present
|
|
19
|
-
|
|
20
|
-
append_to_queue(build_commit_payload)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def check_required_tools
|
|
26
|
-
return if system('git --version', out: File::NULL)
|
|
27
|
-
|
|
28
|
-
abort('>> Git is not installed. Please install it first.')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def check_if_repository_is_present
|
|
32
|
-
return if system('git rev-parse --is-inside-work-tree', out: File::NULL)
|
|
33
|
-
|
|
34
|
-
abort('>> Not a git repository. Please run this command in a git repository.')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def check_if_commit_is_present
|
|
38
|
-
return if system('git rev-parse --verify HEAD', out: File::NULL)
|
|
39
|
-
|
|
40
|
-
abort('>> No commits found. Please commit your changes first.')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def build_commit_payload
|
|
44
|
-
{
|
|
45
|
-
sha: `git rev-parse HEAD`.strip,
|
|
46
|
-
message: `git log -1 --pretty=%B`.strip,
|
|
47
|
-
repository: `basename $(git rev-parse --show-toplevel)`.strip,
|
|
48
|
-
branch: `git rev-parse --abbrev-ref HEAD`.strip,
|
|
49
|
-
author: {
|
|
50
|
-
username: @author_username,
|
|
51
|
-
avatar_url: @author_avatar_url
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def append_to_queue(payload)
|
|
57
|
-
`echo [] > #{@queue_file_path}` unless File.exist?(@queue_file_path)
|
|
58
|
-
|
|
59
|
-
commits = read_commits_from_queue(payload)
|
|
60
|
-
|
|
61
|
-
puts '>> Adding commit to the queue:'
|
|
62
|
-
|
|
63
|
-
print_queue_item(payload)
|
|
64
|
-
File.open(@queue_file_path, 'w') do |file|
|
|
65
|
-
commits << payload
|
|
66
|
-
file.write(JSON.generate(commits))
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def read_commits_from_queue(payload)
|
|
71
|
-
commits = nil
|
|
72
|
-
|
|
73
|
-
File.open(@queue_file_path, 'r') do |file|
|
|
74
|
-
commits = JSON.parse(file.read)
|
|
75
|
-
|
|
76
|
-
if commits.any? { |commit| commit['sha'] == payload[:sha] }
|
|
77
|
-
abort('>> Commit has already been added to the queue')
|
|
78
|
-
end
|
|
79
|
-
rescue JSON::ParserError
|
|
80
|
-
abort('>> Invalid JSON format in the queue file.')
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
commits
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# rubocop:disable Metrics/AbcSize
|
|
87
|
-
def print_queue_item(payload)
|
|
88
|
-
sha = format_text_truncate(payload[:sha], COLOR_CODES[:green], 6)
|
|
89
|
-
repository = format_text("#{payload[:repository]}##{payload[:branch]}", COLOR_CODES[:blue])
|
|
90
|
-
message = format_text_elipsis(payload[:message], COLOR_CODES[:yellow], 50)
|
|
91
|
-
username = format_text(payload[:author][:username], COLOR_CODES[:magenta])
|
|
92
|
-
avatar_url = format_text(payload[:author][:avatar_url], COLOR_CODES[:cyan])
|
|
93
|
-
|
|
94
|
-
puts "#{sha} #{repository} - #{username} (#{avatar_url}) - #{message}"
|
|
95
|
-
end
|
|
96
|
-
# rubocop:enable Metrics/AbcSize
|
|
97
|
-
|
|
98
|
-
def format_text(text, color)
|
|
99
|
-
"\e[#{color}m#{text}\e[0m"
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def wrap_in_color(text, color)
|
|
103
|
-
"\e[#{color}m#{text}\e[0m"
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def format_text_truncate(text, color, truncate_length)
|
|
107
|
-
format_text(text[0..truncate_length], color)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def format_text_elipsis(text, color, truncate_length)
|
|
111
|
-
if text.length > truncate_length
|
|
112
|
-
format_text("#{truncate_text(text, truncate_length)}...", color)
|
|
113
|
-
else
|
|
114
|
-
format_text(text, color)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def truncate_text(text, truncate_length)
|
|
119
|
-
text[0..truncate_length]
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
COLOR_CODES = {
|
|
124
|
-
red: 31,
|
|
125
|
-
green: 32,
|
|
126
|
-
yellow: 33,
|
|
127
|
-
blue: 34,
|
|
128
|
-
magenta: 35,
|
|
129
|
-
cyan: 36
|
|
130
|
-
}.freeze
|