renuo-cli 4.11.1 → 4.12.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/bin/renuo +1 -1
  3. data/lib/renuo/cli/{app → commands}/check_deploio_status.rb +21 -7
  4. data/lib/renuo/cli/{app → commands}/commit_leaderboard_stage.rb +16 -1
  5. data/lib/renuo/cli/{app → commands}/commit_leaderboard_sync.rb +18 -11
  6. data/lib/renuo/cli/{app → commands}/configure_semaphore.rb +15 -14
  7. data/lib/renuo/cli/{app → commands}/configure_sentry.rb +10 -4
  8. data/lib/renuo/cli/{app → commands}/create_aws_project.rb +27 -4
  9. data/lib/renuo/cli/{app → commands}/create_deploio_app.rb +22 -11
  10. data/lib/renuo/cli/{app → commands}/create_heroku_app.rb +10 -4
  11. data/lib/renuo/cli/commands/create_new_logins.rb +41 -0
  12. data/lib/renuo/cli/{app/github_pull_request_creator.rb → commands/create_pr.rb} +15 -6
  13. data/lib/renuo/cli/{app → commands}/create_slidev_presentation.rb +9 -10
  14. data/lib/renuo/cli/{app/name_display.rb → commands/display_name.rb} +20 -10
  15. data/lib/renuo/cli/{app → commands}/fetch_emails.rb +13 -11
  16. data/lib/renuo/cli/{app/secrets_fetcher.rb → commands/fetch_secrets.rb} +22 -6
  17. data/lib/renuo/cli/commands/generate_password.rb +15 -0
  18. data/lib/renuo/cli/{app → commands}/github_replace.rb +18 -1
  19. data/lib/renuo/cli/commands/heroku_users.rb +29 -0
  20. data/lib/renuo/cli/commands/list_large_git_files.rb +19 -0
  21. data/lib/renuo/cli/{app/release_project.rb → commands/release.rb} +11 -5
  22. data/lib/renuo/cli/{app → commands}/setup_uptimerobot.rb +11 -4
  23. data/lib/renuo/cli/{app/upgrade_laptop/upgrade_mac_os.rb → commands/upgrade_laptop.rb} +33 -6
  24. data/lib/renuo/cli/{app/services → services}/cloudfront_config_service.rb +1 -1
  25. data/lib/renuo/cli/{app/services → services}/markdown_parser_service.rb +1 -1
  26. data/lib/renuo/cli/{app/services → services}/renuo_cli_config.rb +1 -3
  27. data/lib/renuo/cli/{app/templates → templates}/semaphore/semaphore.yml.erb +0 -2
  28. data/lib/renuo/cli/version.rb +2 -2
  29. data/lib/renuo/cli.rb +32 -321
  30. metadata +36 -42
  31. data/lib/renuo/cli/app/create_new_logins.rb +0 -33
  32. data/lib/renuo/cli/app/generate_password.rb +0 -9
  33. data/lib/renuo/cli/app/heroku_apps.rb +0 -13
  34. data/lib/renuo/cli/app/heroku_users.rb +0 -15
  35. data/lib/renuo/cli/app/list_large_git_files.rb +0 -9
  36. data/lib/renuo/cli/app/local_storage.rb +0 -32
  37. data/lib/renuo/cli/app/package.json +0 -14
  38. data/lib/renuo/cli/app/secrets_initializer.rb +0 -17
  39. data/lib/renuo/cli/app/upgrade_laptop/upgrade_laptop_execution.rb +0 -40
  40. data/lib/renuo/cli/app/upgrade_laptop.rb +0 -22
  41. /data/lib/renuo/cli/{app → helpers}/command_helper.rb +0 -0
  42. /data/lib/renuo/cli/{app → helpers}/environments.rb +0 -0
  43. /data/lib/renuo/cli/{app → helpers}/renuo_version.rb +0 -0
  44. /data/lib/renuo/cli/{app/templates → templates}/semaphore/bin/cache_restore.erb +0 -0
  45. /data/lib/renuo/cli/{app/templates → templates}/semaphore/bin/cache_store.erb +0 -0
  46. /data/lib/renuo/cli/{app/templates → templates}/semaphore/notification.yml.erb +0 -0
  47. /data/lib/renuo/cli/{app/templates → templates}/semaphore/semaphore-deploy.yml.erb +0 -0
  48. /data/lib/renuo/cli/{app/templates → templates}/slidev/README.md.erb +0 -0
  49. /data/lib/renuo/cli/{app/templates → templates}/slidev/package.json.erb +0 -0
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Renuo::Cli::Commands::HerokuUsers
4
+ command "heroku-users" do |c|
5
+ c.syntax = "renuo heroku-users add/remove emailaddress"
6
+ c.summary = "Prints a list of commands to add or remove an email address from all Heroku projects"
7
+ c.description = "Useful when a new person is hired or a person quits."
8
+ c.example "renuo heroku-users add alessandro.rodi@renuo.ch",
9
+ "Adds the user alessandro.rodi@renuo.ch to all the Heroku projects"
10
+ c.example "renuo heroku-users remove alessandro.rodi@renuo.ch",
11
+ "Removes the user alessandro.rodi@renuo.ch from all the Heroku projects"
12
+ c.action { |args| new.run(args) }
13
+ end
14
+
15
+ def run(args)
16
+ action, email_address = args
17
+ abort(">> action is either add or remove") unless %w[add remove].include? action
18
+ abort(">> specify an email address") unless email_address
19
+ heroku_apps.each do |app|
20
+ say "heroku access:#{action} #{email_address} --app #{app}"
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def heroku_apps
27
+ JSON.parse(`heroku apps --json`).pluck("name")
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Renuo::Cli::Commands::ListLargeGitFiles
4
+ command "list-large-git-files" do |c|
5
+ c.syntax = "renuo list-large-git-files"
6
+ c.summary = "Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!"
7
+ c.description = "Lists the 5 largest files in a git repository.\nWarning: must be a bare checkout of the repo!"
8
+ c.example "list the 5 largest git files of github.com/renuo/renuo-cli",
9
+ "git clone --bare git@github.com:renuo/renuo-cli.git && " \
10
+ "cd renuo-cli.git && renuo list-large-git-files"
11
+ c.action { new.run }
12
+ end
13
+
14
+ def run
15
+ cmd = 'bash -c "join -o \'1.1 1.2 2.3\' <(git rev-list --objects --all | sort) ' \
16
+ '<(git verify-pack -v objects/pack/*.idx | sort -k3 -n | tail -5 | sort) | sort -k3 -n"'
17
+ puts `#{cmd}`
18
+ end
19
+ end
@@ -1,15 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "command_helper"
4
-
5
- # rubocop:disable Metrics/ClassLength
6
- class ReleaseProject
3
+ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
7
4
  include CommandHelper
8
5
 
9
6
  UPDATE_TYPES = %w[major minor patch custom].freeze
10
7
  TMP_FOLDER_NAME = "_RENUO_RELEASE_TEMP_#{rand(100_000_000)}".freeze
11
8
  MOVE_TO_TMP_FOLDER = "mkdir -p #{TMP_FOLDER_NAME} && cd #{TMP_FOLDER_NAME}".freeze
12
9
 
10
+ command "release" do |c|
11
+ c.syntax = "renuo release"
12
+ c.summary = "Release a projects state of develop (on github) to main in one command."
13
+ c.description = "Creates a new release version of a project on main as either a Major, Minor, " \
14
+ "Patch or Custom release based on the current state of develop on Github"
15
+ c.example "renuo release my-project minor", "release a minor release of my-project"
16
+ c.example "renuo release my-project custom 2.5.0", "release my-project as release 2.5.0"
17
+ c.action { |args| new.run(args) }
18
+ end
19
+
13
20
  def run(args)
14
21
  @project_name, @update_type, @version = args
15
22
  validate_args
@@ -204,4 +211,3 @@ class ReleaseProject
204
211
  "develop"
205
212
  end
206
213
  end
207
- # rubocop:enable Metrics/ClassLength
@@ -1,13 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "json"
5
-
6
- class SetupUptimerobot
3
+ class Renuo::Cli::Commands::SetupUptimerobot
7
4
  CONTACT_GROUP_IDS = "2811620_0_0-2806053_0_0"
8
5
  HTTPS_MONITORING = 1
9
6
  STATUS_PAUSED = 0
10
7
 
8
+ command "setup-uptimerobot" do |c|
9
+ c.syntax = "renuo setup-uptimerobot"
10
+ c.summary = "Sets up uptimerobot for the given project"
11
+ c.description = "The uptimerobot configuration is mandatory for most projects. " \
12
+ "This command sets everything up and pauses the monitoring directly. Once the app is ready, " \
13
+ "the monitoring should get started."
14
+ c.example "renuo setup-uptimerobot https://redmine.ch", "Configures redmine monitoring on uptimerobot"
15
+ c.action { |args| new(args).run }
16
+ end
17
+
11
18
  def initialize(args)
12
19
  abort("No project name given.") if args.nil?
13
20
  @api_key = ask_for_api_key
@@ -1,23 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class UpgradeMacOS
4
- include CommandHelper
3
+ class Renuo::Cli::Commands::UpgradeLaptop
4
+ command "upgrade-laptop" do |c|
5
+ c.syntax = "renuo upgrade-laptop"
6
+ c.summary = "Upgrades the installed apps from the app store, macOS and homebrew"
7
+ c.description = "Upgrades the installed apps from the app store, macOS and homebrew"
8
+ c.example "renuo upgrade-laptop", "upgrades your laptop"
9
+ c.action { new.run }
10
+ end
5
11
 
6
12
  def run
13
+ say "Start Update"
14
+ upgrade_apps
15
+ upgrade_macos
16
+ upgrade_brew unless reboot_required?
17
+ end
18
+
19
+ private
20
+
21
+ def upgrade_apps
22
+ setup_mas
23
+ run_command "mas upgrade"
24
+ end
25
+
26
+ def setup_mas
27
+ `which mas || brew install mas`
28
+ end
29
+
30
+ def upgrade_macos
7
31
  find_software_upgrades
8
32
  return unless upgrade_available?
9
-
10
33
  return if reboot_required_and_not_agreed_to?
11
34
 
12
35
  execute_upgrade
13
36
  end
14
37
 
38
+ def upgrade_brew
39
+ run_command "brew update"
40
+ run_command "brew upgrade"
41
+ run_command "brew cleanup"
42
+ end
43
+
15
44
  def reboot_required?
16
45
  @output.downcase.include? "restart"
17
46
  end
18
47
 
19
- private
20
-
21
48
  def find_software_upgrades
22
49
  say "\nUpdating  macOS.\nFinding available software (this may take a while)".yellow
23
50
 
@@ -38,7 +65,7 @@ class UpgradeMacOS
38
65
  end
39
66
 
40
67
  def execute_upgrade
41
- run_command "softwareupdate --install --all"
68
+ puts `softwareupdate --install --all`
42
69
  reboot if reboot_required?
43
70
  end
44
71
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CloudfrontConfigService
3
+ class Renuo::Cli::Services::CloudfrontConfigService
4
4
  def initialize(bucket, tags = [])
5
5
  @bucket = bucket
6
6
  @tags = tags
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "redcarpet"
4
4
 
5
- class MarkdownParserService
5
+ class Renuo::Cli::Services::MarkdownParserService
6
6
  class ListExtractor < Redcarpet::Render::Base
7
7
  attr_reader :files
8
8
 
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "yaml"
4
-
5
- class RenuoCliConfig
3
+ class Renuo::Cli::Services::RenuoCliConfig
6
4
  CONFIG_FILE_PATH = "#{File.expand_path("~")}/.renuo_cli".freeze
7
5
 
8
6
  class << self
@@ -25,8 +25,6 @@ global_job_config:
25
25
  - bundle config set deployment 'true'
26
26
  - bundle config set path 'vendor/bundle'
27
27
  - bundle install -j 4
28
- - nvm install
29
- - bin/yarn install --cache-folder ~/.cache/yarn
30
28
 
31
29
  blocks:
32
30
  - name: cache
@@ -2,8 +2,8 @@
2
2
 
3
3
  # :nocov:
4
4
  module Renuo
5
- module Cli
6
- VERSION = "4.11.1"
5
+ class Cli
6
+ VERSION = "4.12.1"
7
7
  NAME = "renuo-cli"
8
8
  end
9
9
  end
data/lib/renuo/cli.rb CHANGED
@@ -1,350 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "renuo/cli/version"
4
3
  require "active_support"
5
4
  require "active_support/core_ext"
6
- require "rubygems"
7
- require "gems"
8
5
  require "colorize"
9
- require "tmpdir"
10
- require "net/http"
11
- require "renuo/cli/app/services/renuo_cli_config"
12
- require "renuo/cli/app/name_display"
13
- require "renuo/cli/app/local_storage"
14
- require "renuo/cli/app/list_large_git_files"
15
- require "renuo/cli/app/generate_password"
16
- require "renuo/cli/app/upgrade_laptop"
17
- require "renuo/cli/app/create_aws_project"
18
- require "renuo/cli/app/create_heroku_app"
19
- require "renuo/cli/app/create_deploio_app"
20
- require "renuo/cli/app/configure_sentry"
21
- require "renuo/cli/app/create_new_logins"
22
- require "renuo/cli/app/release_project"
23
- require "renuo/cli/app/fetch_emails"
24
- require "renuo/cli/app/heroku_users"
25
- require "renuo/cli/app/setup_uptimerobot"
26
- require "renuo/cli/app/configure_semaphore"
27
- require "renuo/cli/app/renuo_version"
28
- require "renuo/cli/app/create_slidev_presentation"
29
- require "renuo/cli/app/commit_leaderboard_stage"
30
- require "renuo/cli/app/commit_leaderboard_sync"
31
- require "renuo/cli/app/github_replace"
32
- require "renuo/cli/app/github_pull_request_creator"
33
- require "renuo/cli/app/secrets_initializer"
34
- require "renuo/cli/app/secrets_fetcher"
35
- require "renuo/cli/app/check_deploio_status"
6
+ require "fileutils"
7
+ require "gems"
36
8
  require "highline"
9
+ require "json"
10
+ require "net/http"
11
+ require "open3"
12
+ require "psych"
13
+ require "rubygems"
14
+ require "securerandom"
15
+ require "tmpdir"
16
+ require "uri"
17
+ require "renuo/cli/version"
18
+
19
+ Dir[File.expand_path("cli/helpers/*.rb", __dir__)].each { |f| require f }
37
20
 
38
21
  def agree(question)
39
22
  question += " [y/n]" if question
40
23
  super
41
24
  end
42
25
 
43
- # rubocop:disable Metrics/AbcSize, Metrics/ClassLength, Metrics/MethodLength
44
26
  # :nocov:
45
27
  module Renuo
46
- class CLI
28
+ class Cli
29
+ module Commands; end
30
+ module Services; end
31
+
32
+ # include CommandHelper
33
+
47
34
  def start
48
35
  require "commander/import"
36
+
49
37
  program :version, Renuo::Cli::VERSION
50
38
  program :description, "Renuo CLI"
39
+ update
51
40
 
52
- info = Gems.info Renuo::Cli::NAME
53
-
54
- if Gem::Version.new(Renuo::Cli::VERSION) < Gem::Version.new(info["version"])
55
- say "You are running the version #{Renuo::Cli::VERSION} but the brand new #{info["version"]} is available. 🎉"
56
- if agree("Why don't you update with `gem update renuo-cli`? I can run it for you. 💪")
57
- system("gem update #{Renuo::Cli::NAME}")
58
- abort "Nice! I updated myself. 🤩 Now you can run the command again."
59
- end
60
- abort("Good. Just do it yourself then...😒")
61
- end
62
-
63
- command :"display-name" do |c|
64
- c.syntax = "renuo display-name [options]"
65
- c.summary = "Sets the name of a customer on the Renuo dashboard"
66
- c.description = "Sets the name of a customer on the Renuo dashboard"
67
- c.example 'Display "Peter Muster" on the dashboard', 'renuo display-name "Peter Muster"'
68
- c.example "Remove the current name from the dashboard", "renuo display-name --delete"
69
- c.example "Override the current message on the dashboard", "renuo display-name Happy friday 🍻 --override"
70
- c.option "--delete", "Deletes the current name"
71
- c.option "--override", "Overrides the entire message"
72
- c.option "--monitor", "Open the Google slides"
73
- c.action do |args, options|
74
- NameDisplay.new.run(args, options)
75
- end
76
- end
77
-
78
- command "list-large-git-files" do |c|
79
- c.syntax = "renuo list-large-git-files"
80
- c.summary = "Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!"
81
- c.description = "Lists the 5 largest files in a git repository.\nWarning: must be a bare checkout of the repo!"
82
- c.example "list the 5 largest git files of github.com/renuo/renuo-cli",
83
- "git clone --bare git@github.com:renuo/renuo-cli.git && " \
84
- "cd renuo-cli.git && renuo list-large-git-files"
85
- c.action do
86
- ListLargeGitFiles.new.run
87
- end
88
- end
89
-
90
- command "generate-password" do |c|
91
- c.syntax = "renuo generate-password"
92
- c.summary = "Generates a phrase of random 0-9a-zA-Z characters. Choose a substring of it as a new password."
93
- c.description = "Generates a phrase of random 0-9a-zA-Z characters. Choose a substring of it as a new password."
94
- c.example "renuo generate-password", "generates a random password"
95
- c.action do
96
- GeneratePassword.new.run
97
- end
98
- end
99
-
100
- command "upgrade-laptop" do |c|
101
- c.syntax = "renuo upgrade-laptop"
102
- c.summary = "Upgrades the installed apps from the app store, macOS and homebrew"
103
- c.description = "Upgrades the installed apps from the app store, macOS and homebrew"
104
- c.example "renuo upgrade-laptop", "upgrades your laptop"
105
- c.action do
106
- UpgradeLaptop.new.run
107
- end
108
- end
109
-
110
- command "create-new-logins" do |c|
111
- c.syntax = "renuo create-new-logins"
112
- c.summary = "Guides you through the sign up pages for Sentry, NewRelic and Gemnasium"
113
- c.description = "Guides you through the sign up pages for Sentry, NewRelic and Gemnasium"
114
- c.example "renuo create-new-logins", "creates new logins"
115
- c.action do
116
- CreateNewLogins.new.run
117
- end
118
- end
119
-
120
- command "create-aws-project" do |c|
121
- c.syntax = "renuo create-aws-project"
122
- c.summary = "Generates necessary commands for our project setup on AWS incl. necessary installations."
123
- c.description = <<~DESCRIPTION
124
- This creates commands for creating AWS users, buckets an versioning policies and CloudFront.
125
- It also guides you to set up the necessary environment.
126
-
127
- You will be asked for:
128
- (- installation of aws-cli, if not yet done)
129
- (- setting up aws user `renuo-app-setup`, if not yet done)
130
- - project name and suffix so that the script can respect our naming conventions
131
- - the Redmine project name to tag buckets for AWS billing references
132
- - whether you want to setup CloudFront to deliver assets via S3
133
-
134
- The generated commands do the following:
135
- - create an IAM user for each environment (main, develop) and add it to the renuo apps group.
136
- - create S3 buckets for each user who owns it
137
- - tag the buckets
138
- - enable versioning for main buckets
139
- (- set up a CloudFront distribution for each environment with the default config or plus alias if configured)
140
- DESCRIPTION
141
- c.example "Setup a project (you will be asked for details)", "renuo create-aws-project"
142
- c.action do |_args, _options|
143
- CreateAwsProject.new.run
144
- end
145
- end
146
-
147
- command "release" do |c|
148
- c.syntax = "renuo release"
149
- c.summary = "Release a projects state of develop (on github) to main in one command."
150
- c.description = "Creates a new release version of a project on main as either a Major, Minor, " \
151
- "Patch or Custom release based on the current state of develop on Github"
152
- c.example "renuo release my-project minor", "release a minor release of my-project"
153
- c.example "renuo release my-project custom 2.5.0", "release my-project as release 2.5.0"
154
- c.action do |args|
155
- ReleaseProject.new.run(args)
156
- end
157
- end
158
-
159
- command "create-heroku-app" do |c|
160
- c.syntax = "renuo create-heroku-app [application-name]"
161
- c.summary = "Generates the script necessary to setup an application on Heroku."
162
- c.description = "Generates the script necessary to setup an application on Heroku."
163
- c.example "renuo create-heroku-app hello", "generates the command to create hello on Heroku"
164
- c.action do |args|
165
- CreateHerokuApp.new.run(args)
166
- end
167
- end
168
-
169
- command "create-deploio-app" do |c|
170
- c.syntax = "renuo create-deploio-app"
171
- c.summary = "Generates the script necessary to setup an application on Deploio."
172
- c.description = <<~DESC
173
- Generates the script necessary to setup an application on Deploio.
174
- This command will:
175
- - Prompt for the application name, Git URL, PostgreSQL version, and 1Password vault name.
176
- - Validate the provided inputs.
177
- - Generate the necessary commands to create a project on Deploio.
178
- - Configure repository access by generating SSH keys and adding them to 1Password.
179
- - Create the application and database for each specified environment.
180
- DESC
181
- c.example "renuo create-deploio-app",
182
- "Prompts the user for the necessary information and generates the commands " \
183
- "to create the project, databases, and apps on Deploio."
184
- c.action do |args|
185
- CreateDeploioApp.new.run(args)
186
- end
187
- end
188
-
189
- command "configure-sentry" do |c|
190
- c.syntax = "renuo configure-sentry [project-name] [SENTRY_DSN]"
191
- c.summary = "Generates the script necessary to setup sentry on Heroku."
192
- c.description = c.summary
193
- c.example "renuo configure-sentry myproject https://randomkey@sentry.io/11223344",
194
- "generates the command to configure sentry for myproject on Heroku"
195
- c.action do |args|
196
- ConfigureSentry.new.run(args)
197
- end
198
- end
199
-
200
- command "fetch-emails" do |c|
201
- c.syntax = "renuo fetch-emails"
202
- c.summary = "Retrieves all renuo employees email addresses"
203
- c.description = "Retrieves all renuo employees email addresses. One per line."
204
- c.action do |args|
205
- FetchEmails.new.run(args)
206
- end
207
- end
208
-
209
- command "heroku-users" do |c|
210
- c.syntax = "renuo heroku-users add/remove emailaddress"
211
- c.summary = "Prints a list of commands to add or remove an email address from all Heroku projects"
212
- c.description = "Useful when a new person is hired or a person quits."
213
- c.example "renuo heroku-users add alessandro.rodi@renuo.ch",
214
- "Adds the user alessandro.rodi@renuo.ch to all the Heroku projects"
215
- c.example "renuo heroku-users remove alessandro.rodi@renuo.ch",
216
- "Removes the user alessandro.rodi@renuo.ch from all the Heroku projects"
217
- c.action do |args|
218
- HerokuUsers.new.run(args)
219
- end
220
- end
221
-
222
- command "setup-uptimerobot" do |c|
223
- c.syntax = "renuo setup-uptimerobot"
224
- c.summary = "Sets up uptimerobot for the given project"
225
- c.description = "The uptimerobot configuration is mandatory for most projects. " \
226
- "This command sets everything up and pauses the monitoring directly. Once the app is ready, " \
227
- "the monitoring should get started."
228
- c.example "renuo setup-uptimerobot https://redmine.ch", "Configures redmine monitoring on uptimerobot"
229
- c.action do |args|
230
- SetupUptimerobot.new(args).run
231
- end
232
- end
233
-
234
- command "configure-semaphore" do |c|
235
- c.syntax = "renuo configure-semaphore"
236
- c.summary = "Adds standard semaphore configuration files to a project and creates the notifications"
237
- c.description = "Run this command with a project, to add the semaphore configuration files " \
238
- "and create notifications."
239
- c.action do |_args|
240
- ConfigureSemaphore.new.call
241
- end
242
- end
243
-
244
- command "create-slidev-presentation" do |c|
245
- c.syntax = "renuo create-slidev-presentation [presentation-name]"
246
- c.summary = "Creates a new Slidev presentation with the Renuo theme"
247
- c.description = "Creates a new Slidev presentation with the Renuo theme"
248
- c.action do |args|
249
- CreateSlidevPresentation.new.run(args)
250
- end
251
- end
252
-
253
- command "commit-leaderboard-stage" do |c|
254
- c.syntax = "renuo commit-leaderboard-stage [username] [avatar-url] [queue-path]"
255
- c.summary = "Adds local commits to a local queue for the commit leaderboard"
256
- c.option "--verbose", "Prints the latest commit"
257
- c.description = <<~DESCRIPTION
258
- Add post-commit hook to `git config core.hookspath` with the following contents:
259
-
260
- #!/usr/bin/env sh
261
- renuo commit-leaderboard-stage CuddlyBunion341 "https://avatars.githubusercontent.com/u/53896675?v=4" ~/.renuo-commit-leaderboard.json
262
-
263
- # You can get the GitHub avatar url using `gh api user | jq .avatar_url`
264
- DESCRIPTION
265
-
266
- c.action do |args, options|
267
- CommitLeaderboardStage.new.run(args, options)
268
- end
269
- end
270
-
271
- command "commit-leaderboard-sync" do |c|
272
- c.syntax = "renuo commit-leaderboard-sync [api-secret] [queue-path] [api-url]"
273
- c.summary = "Sends commits from the queue to the commit leaderboard"
274
- c.description = <<~DESCRIPTION
275
- Sends commits from the queue to the commit leaderboard
276
- Add pre-push hook to `git config core.hookspath` with the following contents:
41
+ Dir[File.expand_path("cli/{commands,services}/*.rb", __dir__)].each { |f| require f }
42
+ end
277
43
 
278
- #/usr/bin/env sh
279
- renuo commit-leaderboard-sync {SECRET} ~/.renuo-commit-leaderboard.json https://dashboard.renuo.ch/api/v1/commit_leaderboard
280
- DESCRIPTION
281
- c.option "--verbose", "Prints the configuration, request body and response"
282
- c.action do |args, options|
283
- CommitLeaderboardSync.new.run(args, options)
284
- end
285
- end
44
+ private
286
45
 
287
- command "github-replace" do |c|
288
- c.syntax = "renuo github-replace"
289
- c.summary = "Replaces text in multiple GitHub projects and automatically creates a pull request"
290
- c.description = "Finds and replaces the contents of specific files in Renuo GitHub projects and " \
291
- "automatically creates a pull request"
292
- c.option "--projects <name,name,..>", String, "The github project to clone and edit"
293
- c.option "--branch <name>", String, "The branch to create"
294
- c.option "--title <name>", String, "The title of the pull request"
295
- c.option "--body <text>", String, "The body of the pull request"
296
- c.option "--files <files,files,..>", String, "The files to check"
297
- c.example "Update Semaphore Ubuntu version",
298
- "renuo github-replace ubuntu1804 ubuntu2204 --projects=renuo-cli,renuo-website-v3 " \
299
- '--branch=feature/1234-update-ubuntu --title="Update os_image version" --body=TICKET-1234 ' \
300
- "--files=.semaphore/semaphore.yml"
301
- c.action do |args, opts|
302
- GithubReplace.new.run(args, opts)
303
- end
304
- end
46
+ def update
47
+ info = Gems.info Renuo::Cli::NAME
48
+ return unless Gem::Version.new(Renuo::Cli::VERSION) < Gem::Version.new(info["version"])
305
49
 
306
- command "create-pr" do |c|
307
- c.syntax = "renuo create-pr"
308
- c.summary = "Creates a PR for the current branch"
309
- c.description = "Creates a PR, assigns it to you and automatically inserts the Redmine ticket number into " \
310
- "the PR body"
311
- c.option "--title <title>", String, "The title of the pull request (optional)"
312
- c.option "--redmine-ticket <number>", Integer, "The redmine ticket number (optional)"
313
- c.option "--draft", "Mark the PR as draft"
314
- c.example "Create a PR with the title 'Implement XYZ'",
315
- "renuo create-pr --title 'Implement XYZ'"
316
- c.action do |_, opts|
317
- GithubPullRequestCreator.new.run(opts)
318
- end
319
- end
50
+ say "You are running the version #{Renuo::Cli::VERSION} but the brand new #{info["version"]} is available. 🎉"
320
51
 
321
- command "fetch-secrets" do |c|
322
- c.syntax = "renuo fetch-secrets"
323
- c.summary = "Fetches the needed secrets in a project from the renuo secrets store"
324
- c.option "--init <private_vault_link>", String, "Initializes the renuo secrets store"
325
- c.description = <<~DESCRIPTION
326
- Run the command within a project folder to fetch the secrets from the renuo secrets store.
327
- The bin/setup of the project might run this command for you.
328
- DESCRIPTION
329
- c.action do |_, opts|
330
- if opts.init
331
- SecretsInitializer.run(opts.init)
332
- else
333
- SecretsFetcher.new.run
334
- end
335
- end
52
+ if agree("Why don't you update with `gem update renuo-cli`? I can run it for you. 💪")
53
+ system("gem update #{Renuo::Cli::NAME}")
54
+ abort "Nice! I updated myself. 🤩 Now you can run the command again."
336
55
  end
337
56
 
338
- command "check-deploio-status" do |c|
339
- c.syntax = "renuo check-deploio-status"
340
- c.summary = "Checks the build and release status of the deployment."
341
- c.option "--git-revision <revision>", String, "The git revision to check"
342
- c.action do |_, opts|
343
- CheckDeploioStatus.new(opts).run
344
- end
345
- end
57
+ abort("Good. Just do it yourself then...😒")
346
58
  end
347
59
  end
348
60
  end
349
61
  # :nocov:
350
- # rubocop:enable Metrics/AbcSize, Metrics/ClassLength, Metrics/MethodLength