renuo-cli 4.12.6 → 4.13.0
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/lib/renuo/cli/commands/create_deploio_app.rb +4 -2
- data/lib/renuo/cli/commands/debug.rb +108 -0
- data/lib/renuo/cli/services/cache.rb +27 -0
- data/lib/renuo/cli/services/deploio.rb +19 -0
- data/lib/renuo/cli/services/heroku.rb +35 -0
- data/lib/renuo/cli/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57fc12b5a4094d854e4c1286323f5ba2a2f14186e4848a8e0d22e8e170588fb
|
4
|
+
data.tar.gz: f612852d8349bfd0a5961c058b8cd6196dd60056544a72e81cfc0be862e9ba28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30791f47ca4ac90b0d1ea21af197c1f2ff4d8bfc763a3b8869848b2042bd68c33cd4fb33ab7ed04e63595f92f8e56631c41ce64a05a002fceb969222279f9bbf
|
7
|
+
data.tar.gz: ec909b93570706e37b446064b1306c261912e35e8aa166990aa23cc5b70cad02a4efa9e21f5af8954c4748a0786d706bf6f91c366bdfb2a5cad907088bc20587
|
@@ -115,7 +115,8 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
|
|
115
115
|
say <<~OUTPUT
|
116
116
|
nctl create postgres #{environment} \\
|
117
117
|
--project=#{@project_name} \\
|
118
|
-
--postgres-version=#{@postgres_version}
|
118
|
+
--postgres-version=#{@postgres_version} \\
|
119
|
+
--machine-type=nine-db-xs
|
119
120
|
OUTPUT
|
120
121
|
end
|
121
122
|
|
@@ -129,7 +130,8 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
|
|
129
130
|
--git-revision="#{environment}" \\
|
130
131
|
--basic-auth=false \\ # Disabling Deploio basic auth as Rails app handles authentication
|
131
132
|
--build-env=SECRET_KEY_BASE='rails secret' \\ # Don't forget to generate the secret key
|
132
|
-
--language=ruby
|
133
|
+
--language=ruby \\
|
134
|
+
--size=mini
|
133
135
|
OUTPUT
|
134
136
|
end
|
135
137
|
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../services/cache"
|
4
|
+
require_relative "../services/deploio"
|
5
|
+
require_relative "../services/heroku"
|
6
|
+
|
7
|
+
class Renuo::Cli::Commands::Debug
|
8
|
+
Cache = Renuo::Cli::Services::Cache
|
9
|
+
Deploio = Renuo::Cli::Services::Deploio
|
10
|
+
Heroku = Renuo::Cli::Services::Heroku
|
11
|
+
|
12
|
+
command "debug" do |c|
|
13
|
+
c.syntax = "renuo debug <app-name or domain>"
|
14
|
+
c.summary = "Shortcut to debug apps"
|
15
|
+
c.description = <<~DESC
|
16
|
+
Enter the container or show logs of the available apps on Heroku or Deploio.
|
17
|
+
The command will show a menu with all found targets.
|
18
|
+
It will only use a cache. You must manually update the cache with option 1).
|
19
|
+
DESC
|
20
|
+
c.option "--heroku", "Show only Heroku apps"
|
21
|
+
c.option "--deploio", "Show only Deploio apps"
|
22
|
+
c.action do |args, options|
|
23
|
+
new.run(args, options)
|
24
|
+
rescue Interrupt
|
25
|
+
abort("\nAborted by user.")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# rubocop:todo Metrics/PerceivedComplexity
|
30
|
+
# rubocop:todo Metrics/MethodLength
|
31
|
+
# rubocop:todo Metrics/AbcSize
|
32
|
+
def run(args, options) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
33
|
+
query = args[0]
|
34
|
+
abort(">> Please provide an app name or domain.") if query.blank?
|
35
|
+
|
36
|
+
cloud_unspecified = !options.heroku && !options.deploio
|
37
|
+
should_scan_heroku = options.heroku || cloud_unspecified
|
38
|
+
should_scan_deploio = options.deploio || cloud_unspecified
|
39
|
+
|
40
|
+
choose do |menu| # rubocop:todo Metrics/BlockLength
|
41
|
+
deploio_cache_info = "Deploio: #{Cache.stored_at("deploio_apps") || "never"}"
|
42
|
+
heroku_cache_info = "Heroku: #{Cache.stored_at("heroku_apps") || "never"}"
|
43
|
+
|
44
|
+
menu.choice "Update caches (#{deploio_cache_info}, #{heroku_cache_info})" do
|
45
|
+
if should_scan_deploio
|
46
|
+
say "Updating Deploio cache"
|
47
|
+
Cache.store("deploio_apps", Deploio.fetch_apps)
|
48
|
+
end
|
49
|
+
if should_scan_heroku
|
50
|
+
say "Updating Heroku cache..."
|
51
|
+
Cache.store("heroku_apps", Heroku.fetch_apps)
|
52
|
+
end
|
53
|
+
say "Caches updated"
|
54
|
+
end
|
55
|
+
|
56
|
+
open_cmds = []
|
57
|
+
|
58
|
+
if should_scan_deploio && Cache.stored_at("deploio_apps")
|
59
|
+
select_deploio_targets(query).each do |app|
|
60
|
+
exec_cmd = "nctl exec app #{app[:name]} bash --project #{app[:namespace]}"
|
61
|
+
menu.choice(exec_cmd) { exec exec_cmd.squish }
|
62
|
+
|
63
|
+
log_cmd = "nctl logs app #{app[:name]} -f --project #{app[:namespace]}"
|
64
|
+
menu.choice(log_cmd) { exec log_cmd.squish }
|
65
|
+
|
66
|
+
app[:hosts].each do |host|
|
67
|
+
open_cmds << "open https://#{host}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if should_scan_heroku && Cache.stored_at("heroku_apps")
|
73
|
+
select_heroku_targets(query).each do |app|
|
74
|
+
exec_cmd = "heroku run bash --app #{app[:name]}"
|
75
|
+
menu.choice(exec_cmd) { exec exec_cmd.squish }
|
76
|
+
|
77
|
+
log_cmd = "heroku logs -t --app #{app[:name]}"
|
78
|
+
menu.choice(log_cmd) { exec log_cmd.squish }
|
79
|
+
|
80
|
+
app[:domains].each do |host|
|
81
|
+
open_cmds << "open https://#{host}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
open_cmds.uniq.each do |cmd|
|
87
|
+
menu.choice(cmd) { exec cmd.squish }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
# rubocop:enable Metrics/AbcSize
|
92
|
+
# rubocop:enable Metrics/MethodLength
|
93
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def select_deploio_targets(query)
|
98
|
+
Cache.restore("deploio_apps").select do |app|
|
99
|
+
app[:name].include?(query) || app[:namespace].include?(query) || app[:hosts].any? { |host| host.include?(query) }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def select_heroku_targets(query)
|
104
|
+
Cache.restore("heroku_apps").select do |app|
|
105
|
+
app[:name].include?(query) || app[:domains].any? { |domain| domain.include?(query) }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Renuo::Cli::Services::Cache
|
4
|
+
CACHE_DIR = "#{Dir.home}/.renuo-cli/cache".freeze
|
5
|
+
FileUtils.mkdir_p(CACHE_DIR)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def store(file_name, object)
|
9
|
+
file_path = File.join(CACHE_DIR, "#{file_name}.yml")
|
10
|
+
File.write(file_path, YAML.dump(object))
|
11
|
+
end
|
12
|
+
|
13
|
+
def restore(file_name)
|
14
|
+
file_path = File.join(CACHE_DIR, "#{file_name}.yml")
|
15
|
+
return nil unless File.exist?(file_path)
|
16
|
+
|
17
|
+
YAML.load_file(file_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def stored_at(file_name)
|
21
|
+
file_path = File.join(CACHE_DIR, "#{file_name}.yml")
|
22
|
+
return nil unless File.exist?(file_path)
|
23
|
+
|
24
|
+
File.mtime(file_path).localtime.strftime("%Y-%m-%d %H:%M")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Renuo::Cli::Services::Deploio
|
4
|
+
class << self
|
5
|
+
def fetch_apps
|
6
|
+
fetch_apps_cmd = %(nctl get apps -A -o yaml)
|
7
|
+
stdout, stderr, status = Open3.capture3 fetch_apps_cmd
|
8
|
+
raise "Error fetching Deploio app list: #{stderr}" unless status.success?
|
9
|
+
|
10
|
+
YAML.load_stream(stdout).map do |app|
|
11
|
+
name = app.dig("metadata", "name")
|
12
|
+
namespace = app.dig("metadata", "namespace")
|
13
|
+
spec_hosts = app.dig("spec", "forProvider", "hosts") || []
|
14
|
+
|
15
|
+
{ name: name, namespace: namespace, hosts: spec_hosts }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Renuo::Cli::Services::Heroku
|
4
|
+
class << self
|
5
|
+
TEAMS = %w[staff renuo-legacy].freeze
|
6
|
+
|
7
|
+
def fetch_apps
|
8
|
+
all_app_names = TEAMS.flat_map { |team| fetch_app_names(team) }
|
9
|
+
all_app_names += fetch_app_names # fetch apps from personal account (e.g. as collaborator)
|
10
|
+
|
11
|
+
apps = []
|
12
|
+
iterator = respond_to?(:progress) ? progress(all_app_names) : all_app_names
|
13
|
+
iterator.each do |app_name|
|
14
|
+
apps << { name: app_name, domains: fetch_domains(app_name) }
|
15
|
+
end
|
16
|
+
apps
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch_app_names(team = nil)
|
20
|
+
fetch_app_names_cmd = %(heroku apps --json #{team ? "--team=#{team}" : ""} | jq -r '.[] | "\\(.name)"')
|
21
|
+
stdout, stderr, status = Open3.capture3 fetch_app_names_cmd
|
22
|
+
raise "Error fetching Heroku app list: #{stderr}" unless status.success?
|
23
|
+
|
24
|
+
stdout.force_encoding("UTF-8").split("\n").map(&:strip)
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch_domains(app_name)
|
28
|
+
fetch_domains_cmd = %(heroku domains --app #{app_name} --json | jq -r '.[] | "\\(.hostname)"')
|
29
|
+
stdout, stderr, status = Open3.capture3 fetch_domains_cmd
|
30
|
+
raise "Error fetching Heroku domains information: #{stderr}" unless status.success?
|
31
|
+
|
32
|
+
stdout.force_encoding("UTF-8").split("\n").map(&:strip)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/renuo/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: renuo-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/renuo/cli/commands/create_new_logins.rb
|
90
90
|
- lib/renuo/cli/commands/create_pr.rb
|
91
91
|
- lib/renuo/cli/commands/create_slidev_presentation.rb
|
92
|
+
- lib/renuo/cli/commands/debug.rb
|
92
93
|
- lib/renuo/cli/commands/display_name.rb
|
93
94
|
- lib/renuo/cli/commands/fetch_emails.rb
|
94
95
|
- lib/renuo/cli/commands/fetch_secrets.rb
|
@@ -102,7 +103,10 @@ files:
|
|
102
103
|
- lib/renuo/cli/helpers/command_helper.rb
|
103
104
|
- lib/renuo/cli/helpers/environments.rb
|
104
105
|
- lib/renuo/cli/helpers/renuo_version.rb
|
106
|
+
- lib/renuo/cli/services/cache.rb
|
105
107
|
- lib/renuo/cli/services/cloudfront_config_service.rb
|
108
|
+
- lib/renuo/cli/services/deploio.rb
|
109
|
+
- lib/renuo/cli/services/heroku.rb
|
106
110
|
- lib/renuo/cli/services/renuo_cli_config.rb
|
107
111
|
- lib/renuo/cli/templates/semaphore/bin/cache_restore.erb
|
108
112
|
- lib/renuo/cli/templates/semaphore/bin/cache_store.erb
|