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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Toggl
|
|
4
4
|
class User < ActiveResource::Base
|
|
5
|
-
self.site =
|
|
5
|
+
self.site = "https://www.toggl.com/api/v8/"
|
|
6
6
|
self.include_root_in_json = true
|
|
7
7
|
self.include_format_in_path = false
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ module Toggl
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def self.password
|
|
14
|
-
|
|
14
|
+
"api_token"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def self.custom_method_collection_url(method_name, options)
|
|
@@ -20,7 +20,7 @@ module Toggl
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def self.me
|
|
23
|
-
new(get(:me)[
|
|
23
|
+
new(get(:me)["data"])
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "active_resource"
|
|
4
4
|
|
|
5
5
|
module Toggl
|
|
6
6
|
class Workspace < ActiveResource::Base
|
|
7
|
-
self.site =
|
|
7
|
+
self.site = "https://www.toggl.com/api/v8/"
|
|
8
8
|
self.include_root_in_json = true
|
|
9
9
|
self.include_format_in_path = false
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ module Toggl
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.password
|
|
16
|
-
|
|
16
|
+
"api_token"
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
11
|
-
require
|
|
12
|
-
require
|
|
3
|
+
require "commander"
|
|
4
|
+
require "csv"
|
|
5
|
+
require_relative "environments"
|
|
6
|
+
require_relative "fetch_emails"
|
|
7
|
+
require "renuo/cli/app/toggl/workspace"
|
|
8
|
+
require "renuo/cli/app/toggl/detail"
|
|
9
|
+
require "renuo/cli/app/toggl/user"
|
|
10
|
+
require "terminal-table"
|
|
11
|
+
require "colorize"
|
|
12
|
+
require "active_support/core_ext/numeric/time"
|
|
13
13
|
|
|
14
14
|
# rubocop:disable Metrics/ClassLength
|
|
15
15
|
class TogglRedmineComparator
|
|
16
16
|
class << self
|
|
17
17
|
def call(days_behind = 7)
|
|
18
18
|
report = {}
|
|
19
|
-
since_date = days_behind.days.before(Date.yesterday).strftime(
|
|
20
|
-
until_date = Date.yesterday.strftime(
|
|
19
|
+
since_date = days_behind.days.before(Date.yesterday).strftime("%F")
|
|
20
|
+
until_date = Date.yesterday.strftime("%F")
|
|
21
21
|
extract_redmine(report, since_date, until_date)
|
|
22
22
|
extract_toggl(report, since_date, until_date)
|
|
23
23
|
report = report.sort.reverse.to_h
|
|
@@ -36,12 +36,12 @@ class TogglRedmineComparator
|
|
|
36
36
|
rows.pop
|
|
37
37
|
table = Terminal::Table.new headings: %w[Day Redmine Toggl].map(&:cyan), rows:,
|
|
38
38
|
style: { padding_left: 2, padding_right: 2,
|
|
39
|
-
border_x:
|
|
39
|
+
border_x: "-".blue, border_y: "|".blue, border_i: "+".blue }
|
|
40
40
|
puts table
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def colorize_table_row(date, value)
|
|
44
|
-
printed_day = date.strftime(
|
|
44
|
+
printed_day = date.strftime("%F %a")
|
|
45
45
|
printed_redmine = to_time(value[:redmine])
|
|
46
46
|
printed_toggl = to_time(value[:toggl])
|
|
47
47
|
colorize_method = colorization_for_value(value)
|
|
@@ -68,7 +68,7 @@ class TogglRedmineComparator
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def convert_redmine_csv(encoded_body)
|
|
71
|
-
separated_csv_entries = CSV.parse(encoded_body, col_sep:
|
|
71
|
+
separated_csv_entries = CSV.parse(encoded_body, col_sep: ",")
|
|
72
72
|
keys = separated_csv_entries.shift[1..-2]
|
|
73
73
|
entries = separated_csv_entries.shift[1..-2]
|
|
74
74
|
keys.zip(entries)
|
|
@@ -78,20 +78,20 @@ class TogglRedmineComparator
|
|
|
78
78
|
query = generate_redmine_query(since_date)
|
|
79
79
|
url = URI("https://redmine.renuo.ch/time_entries/report.csv?#{query}")
|
|
80
80
|
req = Net::HTTP::Get.new(url)
|
|
81
|
-
req[
|
|
81
|
+
req["X-Redmine-API-Key"] = RenuoCliConfig.redmine_api_key
|
|
82
82
|
response = Net::HTTP.start(url.hostname, url.port, use_ssl: true) { |http| http.request(req) }
|
|
83
|
-
response.body.force_encoding(
|
|
83
|
+
response.body.force_encoding("ISO-8859-1").encode("UTF-8")
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def generate_redmine_query(since_date)
|
|
87
87
|
URI.encode_www_form(
|
|
88
|
-
[[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
88
|
+
[["utf8", "✓"], ["criteria[]", "user"],
|
|
89
|
+
["f[]", "spent_on"], ["f[]", "user_id"],
|
|
90
|
+
["op[spent_on]", ">="], ["op[user_id]", "="],
|
|
91
|
+
["v[spent_on][]", since_date], ["v[user_id][]", "me"],
|
|
92
|
+
["f[]", ""],
|
|
93
|
+
["c[]", "project"], ["c[]", "spent_on"], ["c[]", "user"], ["c[]", "activity"], ["c[]", "issue"],
|
|
94
|
+
["c[]", "comments"], ["c[]", "hours"], %w[columns day], ["criteria[]", ""]]
|
|
95
95
|
)
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -101,7 +101,7 @@ class TogglRedmineComparator
|
|
|
101
101
|
|
|
102
102
|
workspace_ids.each do |workspace_id|
|
|
103
103
|
time_entries = Toggl::Detail.where(since: since_date, until: until_date,
|
|
104
|
-
user_agent:
|
|
104
|
+
user_agent: "renuo-cli", workspace_id:, user_ids: user_id)
|
|
105
105
|
parse_toggl_entries(report, time_entries)
|
|
106
106
|
end
|
|
107
107
|
end
|
|
@@ -124,7 +124,7 @@ class TogglRedmineComparator
|
|
|
124
124
|
sec = value / 1000.0
|
|
125
125
|
min, _sec = sec.divmod(60.0)
|
|
126
126
|
hour, min = min.divmod(60.0)
|
|
127
|
-
format(
|
|
127
|
+
format("%<hour>02d:%<min>02d", hour:, min:)
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def to_seconds(value)
|
|
@@ -17,7 +17,7 @@ class UpgradeLaptopExecution
|
|
|
17
17
|
|
|
18
18
|
def upgrade_apps
|
|
19
19
|
setup_mas
|
|
20
|
-
run_command
|
|
20
|
+
run_command "mas upgrade"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def setup_mas
|
|
@@ -33,8 +33,8 @@ class UpgradeLaptopExecution
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def upgrade_brew
|
|
36
|
-
run_command
|
|
37
|
-
run_command
|
|
38
|
-
run_command
|
|
36
|
+
run_command "brew update"
|
|
37
|
+
run_command "brew upgrade"
|
|
38
|
+
run_command "brew cleanup"
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -13,7 +13,7 @@ class UpgradeMacOS
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def reboot_required?
|
|
16
|
-
@output.downcase.include?
|
|
16
|
+
@output.downcase.include? "restart"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
private
|
|
@@ -26,7 +26,7 @@ class UpgradeMacOS
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def upgrade_available?
|
|
29
|
-
@output.include?
|
|
29
|
+
@output.include? "Software Update found"
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def reboot_required_and_not_agreed_to?
|
|
@@ -38,12 +38,12 @@ class UpgradeMacOS
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def execute_upgrade
|
|
41
|
-
run_command
|
|
41
|
+
run_command "softwareupdate --install --all"
|
|
42
42
|
reboot if reboot_required?
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def reboot
|
|
46
|
-
say
|
|
46
|
+
say "Rebooting Now".white.on_red
|
|
47
47
|
say `osascript -e 'tell app "System Events" to restart'`
|
|
48
48
|
end
|
|
49
49
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
3
|
+
require_relative "command_helper"
|
|
4
|
+
require_relative "upgrade_laptop/upgrade_laptop_execution"
|
|
5
|
+
require_relative "upgrade_laptop/upgrade_mac_os"
|
|
6
6
|
|
|
7
7
|
class UpgradeLaptop
|
|
8
8
|
def run
|
|
@@ -13,7 +13,7 @@ class UpgradeLaptop
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
15
|
def say_hi
|
|
16
|
-
say
|
|
16
|
+
say "Start Update"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def run_upgrade
|
data/lib/renuo/cli/app/work.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "renuo/cli/app/redmine/issue"
|
|
5
|
+
require "renuo/cli/app/toggl/time_entry"
|
|
6
6
|
|
|
7
7
|
class Work
|
|
8
8
|
ACTIONS = %w[start].freeze
|
|
@@ -22,21 +22,21 @@ class Work
|
|
|
22
22
|
|
|
23
23
|
# TODO: I want to implement also the stop action.
|
|
24
24
|
def validate_action
|
|
25
|
-
abort(
|
|
25
|
+
abort(">> No action given. It must be start") unless ACTIONS.include? @action
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def validate_project_name
|
|
29
|
-
abort(
|
|
29
|
+
abort(">> No project name given.") unless @project_name
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def validate_ticket_number
|
|
33
|
-
abort(
|
|
33
|
+
abort(">> No ticket number given.") unless @ticket_number
|
|
34
34
|
issue = Redmine::Issue.find(@ticket_number)
|
|
35
35
|
open_statuses = Redmine::Issue::STATUSES.values_at(:to_start, :planned, :in_progress, :qa)
|
|
36
36
|
return if open_statuses.include?(issue.status.id)
|
|
37
37
|
|
|
38
38
|
system("open #{issue.html_url}")
|
|
39
|
-
abort(
|
|
39
|
+
abort(">> Ticket should be in an open status")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def start_feature_branch
|
|
@@ -66,28 +66,28 @@ class Work
|
|
|
66
66
|
def existing_toggl(current_time_entry)
|
|
67
67
|
say("A timer '#{current_time_entry.description}' was already running.")
|
|
68
68
|
if current_time_entry.description.to_i == @ticket_number.to_i
|
|
69
|
-
say(
|
|
69
|
+
say("I will keep using it")
|
|
70
70
|
else
|
|
71
|
-
say(
|
|
71
|
+
say("I stopped it and started a new time entry.")
|
|
72
72
|
stop_toggl_time_entry(current_time_entry.id)
|
|
73
73
|
create_toggl_time_entry
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def update_toggl_time_entry(time_entry_id)
|
|
78
|
-
say(
|
|
78
|
+
say("A timer was already running but without a project assigned. I updated the current time entry.")
|
|
79
79
|
|
|
80
80
|
time_entry = Toggl::TimeEntry.find(time_entry_id)
|
|
81
81
|
time_entry.description = @ticket_number.to_s
|
|
82
82
|
time_entry.tags = [@project_name.to_s]
|
|
83
|
-
time_entry.created_with =
|
|
83
|
+
time_entry.created_with = "curl"
|
|
84
84
|
time_entry.save
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
def create_toggl_time_entry
|
|
88
88
|
Toggl::TimeEntry.start(time_entry: { description: @ticket_number.to_s,
|
|
89
89
|
tags: [@project_name.to_s],
|
|
90
|
-
created_with:
|
|
90
|
+
created_with: "curl" })
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def stop_toggl_time_entry(time_entry_id)
|