console_kit 1.0.0 → 1.2.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/console_kit/configuration.rb +18 -15
- data/lib/console_kit/connections/base_connection_handler.rb +47 -1
- data/lib/console_kit/connections/connection_manager.rb +4 -0
- data/lib/console_kit/connections/dashboard.rb +28 -0
- data/lib/console_kit/connections/diagnostic_helpers.rb +22 -0
- data/lib/console_kit/connections/elasticsearch_connection_handler.rb +62 -0
- data/lib/console_kit/connections/mongo_connection_handler.rb +36 -8
- data/lib/console_kit/connections/redis_connection_handler.rb +76 -0
- data/lib/console_kit/connections/sql_connection_handler.rb +45 -10
- data/lib/console_kit/connections/table_formatter.rb +37 -0
- data/lib/console_kit/connections/table_renderer.rb +49 -0
- data/lib/console_kit/console_helpers.rb +47 -0
- data/lib/console_kit/output.rb +11 -13
- data/lib/console_kit/prompt.rb +52 -0
- data/lib/console_kit/railtie.rb +9 -1
- data/lib/console_kit/setup.rb +31 -24
- data/lib/console_kit/setup_ui.rb +37 -0
- data/lib/console_kit/tenant_configurator.rb +33 -15
- data/lib/console_kit/tenant_selector.rb +22 -17
- data/lib/console_kit/version.rb +1 -1
- data/lib/console_kit.rb +9 -1
- data/lib/generators/console_kit/templates/console_kit.rb +12 -2
- metadata +30 -12
- data/CHANGELOG.md +0 -92
- data/CODE_OF_CONDUCT.md +0 -132
- data/README.md +0 -116
- data/SECURITY.md +0 -30
- data/sig/console_kit.rbs +0 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConsoleKit
|
|
4
|
+
# Sets the console prompt to show the current tenant
|
|
5
|
+
module Prompt
|
|
6
|
+
class << self
|
|
7
|
+
def apply
|
|
8
|
+
apply_irb_prompt if defined?(IRB)
|
|
9
|
+
apply_pry_prompt if defined?(Pry)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def tenant_label
|
|
15
|
+
tenant = ConsoleKit::Setup.current_tenant
|
|
16
|
+
tenant ? "[#{tenant}]" : '[no-tenant]'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def apply_irb_prompt
|
|
20
|
+
conf = IRB.conf
|
|
21
|
+
prompt = conf[:PROMPT] ||= {}
|
|
22
|
+
prompt[:CONSOLE_KIT] = {
|
|
23
|
+
PROMPT_I: "#{tenant_label} %N(%m):%03n> ",
|
|
24
|
+
PROMPT_S: "#{tenant_label} %N(%m):%03n%l ",
|
|
25
|
+
PROMPT_C: "#{tenant_label} %N(%m):%03n* ",
|
|
26
|
+
RETURN: "=> %s\n"
|
|
27
|
+
}
|
|
28
|
+
conf[:PROMPT_MODE] = :CONSOLE_KIT
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def apply_pry_prompt
|
|
32
|
+
procs = pry_prompt_procs(tenant_label)
|
|
33
|
+
Pry.config.prompt = build_pry_prompt(procs)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def pry_prompt_procs(label)
|
|
37
|
+
[
|
|
38
|
+
proc { |obj, nest, _| "#{label} (#{obj}):#{nest}> " },
|
|
39
|
+
proc { |obj, nest, _| "#{label} (#{obj}):#{nest}* " }
|
|
40
|
+
]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def build_pry_prompt(procs)
|
|
44
|
+
if defined?(Pry::Prompt) && Pry::Prompt.respond_to?(:new)
|
|
45
|
+
Pry::Prompt.new('console_kit', 'ConsoleKit tenant prompt', procs)
|
|
46
|
+
else
|
|
47
|
+
procs
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/console_kit/railtie.rb
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
module ConsoleKit
|
|
4
4
|
# Railtie for integrating ConsoleKit with Rails console.
|
|
5
5
|
class Railtie < Rails::Railtie
|
|
6
|
-
console
|
|
6
|
+
console do
|
|
7
|
+
ConsoleKit::Setup.setup
|
|
8
|
+
ConsoleKit::Prompt.apply
|
|
9
|
+
if defined?(IRB::ExtendCommandBundle) && !defined?(Pry)
|
|
10
|
+
IRB::ExtendCommandBundle.include(ConsoleKit::ConsoleHelpers)
|
|
11
|
+
else
|
|
12
|
+
TOPLEVEL_BINDING.receiver.extend(ConsoleKit::ConsoleHelpers)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
7
15
|
|
|
8
16
|
config.to_prepare { ConsoleKit::Setup.reapply if defined?(Rails::Console) }
|
|
9
17
|
end
|
data/lib/console_kit/setup.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative 'tenant_selector'
|
|
4
4
|
require_relative 'tenant_configurator'
|
|
5
5
|
require_relative 'output'
|
|
6
|
+
require_relative 'setup_ui'
|
|
6
7
|
|
|
7
8
|
# Core Logic for initial Setup
|
|
8
9
|
module ConsoleKit
|
|
@@ -27,20 +28,26 @@ module ConsoleKit
|
|
|
27
28
|
def reset_current_tenant
|
|
28
29
|
return warn_no_tenants unless tenants?
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
TenantConfigurator.clear if current_tenant
|
|
32
|
-
|
|
33
|
-
self.current_tenant = nil
|
|
34
|
-
setup
|
|
31
|
+
perform_tenant_reset
|
|
35
32
|
end
|
|
36
33
|
|
|
37
34
|
private
|
|
38
35
|
|
|
36
|
+
def perform_tenant_reset
|
|
37
|
+
key = select_tenant_key
|
|
38
|
+
return cancel_switch if key == :abort || key.blank?
|
|
39
|
+
|
|
40
|
+
clear_current_tenant
|
|
41
|
+
return skip_tenant_message if %i[exit none].include?(key)
|
|
42
|
+
|
|
43
|
+
configure(key)
|
|
44
|
+
end
|
|
45
|
+
|
|
39
46
|
def run_setup
|
|
40
47
|
return if tenant_setup_successful?
|
|
41
48
|
|
|
42
|
-
ConsoleKit.configuration
|
|
43
|
-
|
|
49
|
+
config = ConsoleKit.configuration
|
|
50
|
+
config.validate!
|
|
44
51
|
select_and_configure
|
|
45
52
|
rescue StandardError => e
|
|
46
53
|
handle_error(e)
|
|
@@ -54,19 +61,13 @@ module ConsoleKit
|
|
|
54
61
|
end
|
|
55
62
|
|
|
56
63
|
def handle_selection_result(key)
|
|
57
|
-
exit_on_key
|
|
64
|
+
exit_on_key if %i[exit abort].include?(key)
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Output.print_info('No tenant selected. Loading without tenant configuration.')
|
|
62
|
-
when nil, ''
|
|
63
|
-
Output.print_error('Tenant selection failed. Loading without tenant configuration.')
|
|
64
|
-
end
|
|
66
|
+
skip_tenant_message if key == :none
|
|
67
|
+
Output.print_error('Tenant selection failed. Loading without tenant configuration.') if key.blank?
|
|
65
68
|
end
|
|
66
69
|
|
|
67
|
-
def exit_on_key
|
|
68
|
-
return unless key == :exit
|
|
69
|
-
|
|
70
|
+
def exit_on_key
|
|
70
71
|
Output.print_info('Exiting console...')
|
|
71
72
|
Kernel.exit
|
|
72
73
|
end
|
|
@@ -76,19 +77,25 @@ module ConsoleKit
|
|
|
76
77
|
return unless TenantConfigurator.configuration_success
|
|
77
78
|
|
|
78
79
|
self.current_tenant = key
|
|
79
|
-
|
|
80
|
+
Prompt.apply
|
|
81
|
+
SetupUI.print_tenant_banner(key, ConsoleKit.configuration)
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
def tenants = ConsoleKit.configuration.tenants
|
|
83
|
-
def context_class = ConsoleKit.configuration.context_class
|
|
84
85
|
def tenants? = tenants&.any?
|
|
85
|
-
def no_tenants? = !tenants?
|
|
86
86
|
def select_tenant_key = auto_select? ? tenants.keys.first : TenantSelector.select
|
|
87
|
-
def auto_select? =
|
|
88
|
-
def single_tenant? = tenants.size == 1
|
|
89
|
-
def non_interactive? = !$stdin.tty?
|
|
87
|
+
def auto_select? = (tenants.size == 1) || !$stdin.tty?
|
|
90
88
|
def warn_no_tenants = Output.print_warning('Cannot reset tenant: No tenants configured.')
|
|
91
|
-
def
|
|
89
|
+
def cancel_switch = Output.print_warning('Tenant switch cancelled.')
|
|
90
|
+
def skip_tenant_message = Output.print_info('No tenant selected. Loading without tenant configuration.')
|
|
91
|
+
|
|
92
|
+
def clear_current_tenant
|
|
93
|
+
if current_tenant
|
|
94
|
+
Output.print_warning("Resetting tenant: #{current_tenant}")
|
|
95
|
+
TenantConfigurator.clear
|
|
96
|
+
end
|
|
97
|
+
self.current_tenant = nil
|
|
98
|
+
end
|
|
92
99
|
|
|
93
100
|
def handle_error(error)
|
|
94
101
|
Output.print_error("Error setting up tenant: #{error.message}")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConsoleKit
|
|
4
|
+
# UI helpers for Setup
|
|
5
|
+
module SetupUI
|
|
6
|
+
ENVIRONMENT_WARNINGS = {
|
|
7
|
+
'production' => -> { Output.print_error('!!! CAUTION: YOU ARE IN PRODUCTION ENVIRONMENT !!!') },
|
|
8
|
+
'staging' => -> { Output.print_warning('CAUTION: You are in staging environment.') }
|
|
9
|
+
}.freeze
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
def print_tenant_banner(key, config)
|
|
13
|
+
Output.print_success("Tenant initialized: #{key}")
|
|
14
|
+
print_env_warning(key, config)
|
|
15
|
+
print_active_connections
|
|
16
|
+
ConsoleKit::Connections::Dashboard.display if config.show_dashboard
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def print_env_warning(key, config)
|
|
22
|
+
constants = config.tenants[key]&.[](:constants) || {}
|
|
23
|
+
env = constants[:environment]&.to_s&.downcase
|
|
24
|
+
ENVIRONMENT_WARNINGS[env]&.call if env
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def print_active_connections
|
|
28
|
+
ctx = ConsoleKit.configuration.context_class
|
|
29
|
+
active = Connections::ConnectionManager.available_handlers(ctx).map do |handler|
|
|
30
|
+
handler.class.name.demodulize.delete_suffix('ConnectionHandler')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Output.print_info("Active connections: #{active.join(', ')}") if active.any?
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'output'
|
|
4
4
|
require_relative 'connections/connection_manager'
|
|
5
|
+
require_relative 'connections/dashboard'
|
|
5
6
|
|
|
6
7
|
module ConsoleKit
|
|
7
8
|
# For tenant configuration
|
|
8
9
|
module TenantConfigurator
|
|
9
10
|
class << self
|
|
11
|
+
HANDLER_ATTRIBUTES = {
|
|
12
|
+
Connections::SqlConnectionHandler => :tenant_shard,
|
|
13
|
+
Connections::MongoConnectionHandler => :tenant_mongo_db,
|
|
14
|
+
Connections::RedisConnectionHandler => :tenant_redis_db,
|
|
15
|
+
Connections::ElasticsearchConnectionHandler => :tenant_elasticsearch_prefix
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
10
18
|
def configuration_success = Thread.current[:console_kit_configuration_success]
|
|
11
19
|
|
|
12
20
|
def configuration_success=(val)
|
|
@@ -39,7 +47,7 @@ module ConsoleKit
|
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
def reset_context_attributes(ctx)
|
|
42
|
-
|
|
50
|
+
available_context_attributes(ctx).each do |attr|
|
|
43
51
|
ctx.public_send("#{attr}=", nil)
|
|
44
52
|
end
|
|
45
53
|
end
|
|
@@ -60,31 +68,41 @@ module ConsoleKit
|
|
|
60
68
|
configure_success(key)
|
|
61
69
|
end
|
|
62
70
|
|
|
63
|
-
def
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
raise Error, "Context class #{ctx} does not implement the required interface. " \
|
|
68
|
-
"Missing methods: #{missing.join(', ')}"
|
|
71
|
+
def handler_available?(handler_class)
|
|
72
|
+
handler_class.new(nil).available?
|
|
73
|
+
rescue NotImplementedError, StandardError
|
|
74
|
+
false
|
|
69
75
|
end
|
|
70
76
|
|
|
71
|
-
def
|
|
72
|
-
attributes =
|
|
73
|
-
|
|
77
|
+
def available_context_attributes(ctx)
|
|
78
|
+
attributes = ctx.respond_to?(:partner_identifier=) ? [:partner_identifier] : []
|
|
79
|
+
|
|
80
|
+
HANDLER_ATTRIBUTES.each_with_object(attributes) do |(handler, attr), list|
|
|
81
|
+
next unless ctx.respond_to?("#{attr}=")
|
|
82
|
+
next unless handler_available?(handler)
|
|
83
|
+
|
|
84
|
+
list << attr
|
|
85
|
+
end
|
|
74
86
|
end
|
|
75
87
|
|
|
76
88
|
def apply_context(constant)
|
|
77
89
|
ctx = ConsoleKit.configuration.context_class
|
|
78
|
-
validate_context_interface!(ctx)
|
|
79
|
-
|
|
80
90
|
assign_context_attributes(ctx, constant)
|
|
81
91
|
setup_connections(ctx)
|
|
82
92
|
end
|
|
83
93
|
|
|
84
94
|
def assign_context_attributes(ctx, constant)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
attribute_to_constant = {
|
|
96
|
+
partner_identifier: :partner_code,
|
|
97
|
+
tenant_shard: :shard,
|
|
98
|
+
tenant_mongo_db: :mongo_db,
|
|
99
|
+
tenant_redis_db: :redis_db,
|
|
100
|
+
tenant_elasticsearch_prefix: :elasticsearch_prefix
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
available_context_attributes(ctx).each do |attr|
|
|
104
|
+
ctx.public_send("#{attr}=", constant[attribute_to_constant[attr]])
|
|
105
|
+
end
|
|
88
106
|
end
|
|
89
107
|
|
|
90
108
|
def setup_connections(context)
|
|
@@ -9,36 +9,40 @@ module ConsoleKit
|
|
|
9
9
|
DEFAULT_SELECTION = '1'
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
|
-
def select
|
|
12
|
+
def select
|
|
13
|
+
RETRY_LIMIT.times do
|
|
14
|
+
result = attempt_selection
|
|
15
|
+
return result unless result == :retry
|
|
16
|
+
end
|
|
17
|
+
nil
|
|
18
|
+
end
|
|
13
19
|
|
|
14
20
|
private
|
|
15
21
|
|
|
16
|
-
def attempt_selection
|
|
17
|
-
return nil if retries_left.zero?
|
|
18
|
-
|
|
22
|
+
def attempt_selection
|
|
19
23
|
print_tenant_selection_menu
|
|
20
|
-
process_selection(
|
|
24
|
+
process_selection(parse_user_selection)
|
|
21
25
|
end
|
|
22
26
|
|
|
23
|
-
def process_selection(
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
return attempt_selection(retries_left - 1) unless selection
|
|
27
|
+
def process_selection(selection)
|
|
28
|
+
return :retry unless selection
|
|
29
|
+
return selection if selection == :abort
|
|
27
30
|
|
|
28
31
|
selection.is_a?(Integer) ? resolve_selection(selection) : selection
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
def print_tenant_selection_menu
|
|
32
35
|
Output.print_header('Multiple tenants detected. Please choose one:')
|
|
36
|
+
Output.print_list(menu_items)
|
|
37
|
+
end
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
def menu_items
|
|
40
|
+
tenants = ConsoleKit.tenants.keys
|
|
41
|
+
items = ['0. Skip (load without tenant configuration)']
|
|
42
|
+
tenants.each_with_index.map do |key, index|
|
|
38
43
|
items << "#{index + 1}. #{key} (partner: #{tenant_partner(key)})"
|
|
39
44
|
end
|
|
40
|
-
|
|
41
|
-
Output.print_list(items)
|
|
45
|
+
items
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
def tenant_partner(key) = ConsoleKit.tenants.dig(key, :constants, :partner_code) || 'N/A'
|
|
@@ -53,7 +57,7 @@ module ConsoleKit
|
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
def find_tenant_by_name(input)
|
|
56
|
-
match = ConsoleKit.tenants.keys.find { |
|
|
60
|
+
match = ConsoleKit.tenants.keys.find { |key| key.to_s.casecmp(input).zero? }
|
|
57
61
|
return match if match
|
|
58
62
|
|
|
59
63
|
handle_invalid_input("Invalid selection: '#{input}'. Please enter a number or tenant name.")
|
|
@@ -69,9 +73,10 @@ module ConsoleKit
|
|
|
69
73
|
|
|
70
74
|
def read_input_with_default
|
|
71
75
|
Output.print_prompt("Selection (number or name) [#{DEFAULT_SELECTION}]: ")
|
|
72
|
-
|
|
73
76
|
raw_input = $stdin.gets
|
|
74
77
|
raw_input ? normalize_input(raw_input) : :abort
|
|
78
|
+
rescue Interrupt
|
|
79
|
+
:abort
|
|
75
80
|
end
|
|
76
81
|
|
|
77
82
|
def normalize_input(raw_input)
|
data/lib/console_kit/version.rb
CHANGED
data/lib/console_kit.rb
CHANGED
|
@@ -7,6 +7,8 @@ require 'active_support/core_ext/string/inflections'
|
|
|
7
7
|
require_relative 'console_kit/version'
|
|
8
8
|
require_relative 'console_kit/configuration'
|
|
9
9
|
require_relative 'console_kit/setup'
|
|
10
|
+
require_relative 'console_kit/console_helpers'
|
|
11
|
+
require_relative 'console_kit/prompt'
|
|
10
12
|
require_relative 'console_kit/railtie' if defined?(Rails::Railtie)
|
|
11
13
|
|
|
12
14
|
# Main module for ConsoleKit
|
|
@@ -21,7 +23,7 @@ module ConsoleKit
|
|
|
21
23
|
def reset_configuration!
|
|
22
24
|
@configuration = nil
|
|
23
25
|
Setup.current_tenant = nil
|
|
24
|
-
TenantConfigurator.configuration_success = false
|
|
26
|
+
TenantConfigurator.configuration_success = false if defined?(TenantConfigurator)
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def pretty_output = configuration.pretty_output
|
|
@@ -42,6 +44,12 @@ module ConsoleKit
|
|
|
42
44
|
configuration.context_class = val
|
|
43
45
|
end
|
|
44
46
|
|
|
47
|
+
def show_dashboard = configuration.show_dashboard
|
|
48
|
+
|
|
49
|
+
def show_dashboard=(val)
|
|
50
|
+
configuration.show_dashboard = val
|
|
51
|
+
end
|
|
52
|
+
|
|
45
53
|
def current_tenant = Setup.current_tenant
|
|
46
54
|
def reset_current_tenant = Setup.reset_current_tenant
|
|
47
55
|
def enable_pretty_output = configuration.pretty_output = true
|
|
@@ -11,14 +11,20 @@ Rails.application.config.after_initialize do
|
|
|
11
11
|
# constants: {
|
|
12
12
|
# shard: :shard_1,
|
|
13
13
|
# mongo_db: 'mongo_db_1',
|
|
14
|
-
# partner_code: 'partner_a'
|
|
14
|
+
# partner_code: 'partner_a',
|
|
15
|
+
# redis_db: 1,
|
|
16
|
+
# elasticsearch_prefix: 'tenant_a',
|
|
17
|
+
# environment: 'production'
|
|
15
18
|
# }
|
|
16
19
|
# },
|
|
17
20
|
# tenant_b: {
|
|
18
21
|
# constants: {
|
|
19
22
|
# shard: :shard_2,
|
|
20
23
|
# mongo_db: 'mongo_db_2',
|
|
21
|
-
# partner_code: 'partner_b'
|
|
24
|
+
# partner_code: 'partner_b',
|
|
25
|
+
# redis_db: 2,
|
|
26
|
+
# elasticsearch_prefix: 'tenant_b',
|
|
27
|
+
# environment: 'staging'
|
|
22
28
|
# }
|
|
23
29
|
# }
|
|
24
30
|
# }
|
|
@@ -31,6 +37,10 @@ Rails.application.config.after_initialize do
|
|
|
31
37
|
# Toggle pretty output on/off (default: true)
|
|
32
38
|
config.pretty_output = true
|
|
33
39
|
|
|
40
|
+
# Show connection dashboard on tenant switch (default: false)
|
|
41
|
+
# When false, use the `dashboard` command in the console to display on-demand
|
|
42
|
+
# config.show_dashboard = true
|
|
43
|
+
|
|
34
44
|
if config.tenants.nil?
|
|
35
45
|
warn '[ConsoleKit] Warning: `tenants` is not configured. ' \
|
|
36
46
|
'Please set it in config/initializers/console_kit.rb'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: console_kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Soumyadeep Pal
|
|
@@ -10,33 +10,47 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: activerecord
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '
|
|
18
|
+
version: '6.1'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '
|
|
25
|
+
version: '6.1'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: activesupport
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
32
|
+
version: '6.1'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
39
|
+
version: '6.1'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: railties
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '6.1'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '6.1'
|
|
40
54
|
description: Adds tenant selection to Rails consoles
|
|
41
55
|
email:
|
|
42
56
|
- soumyadeeppal2001@gmail.com
|
|
@@ -44,26 +58,30 @@ executables: []
|
|
|
44
58
|
extensions: []
|
|
45
59
|
extra_rdoc_files: []
|
|
46
60
|
files:
|
|
47
|
-
- CHANGELOG.md
|
|
48
|
-
- CODE_OF_CONDUCT.md
|
|
49
61
|
- LICENSE.txt
|
|
50
|
-
- README.md
|
|
51
|
-
- SECURITY.md
|
|
52
62
|
- lib/console_kit.rb
|
|
53
63
|
- lib/console_kit/configuration.rb
|
|
54
64
|
- lib/console_kit/connections/base_connection_handler.rb
|
|
55
65
|
- lib/console_kit/connections/connection_manager.rb
|
|
66
|
+
- lib/console_kit/connections/dashboard.rb
|
|
67
|
+
- lib/console_kit/connections/diagnostic_helpers.rb
|
|
68
|
+
- lib/console_kit/connections/elasticsearch_connection_handler.rb
|
|
56
69
|
- lib/console_kit/connections/mongo_connection_handler.rb
|
|
70
|
+
- lib/console_kit/connections/redis_connection_handler.rb
|
|
57
71
|
- lib/console_kit/connections/sql_connection_handler.rb
|
|
72
|
+
- lib/console_kit/connections/table_formatter.rb
|
|
73
|
+
- lib/console_kit/connections/table_renderer.rb
|
|
74
|
+
- lib/console_kit/console_helpers.rb
|
|
58
75
|
- lib/console_kit/output.rb
|
|
76
|
+
- lib/console_kit/prompt.rb
|
|
59
77
|
- lib/console_kit/railtie.rb
|
|
60
78
|
- lib/console_kit/setup.rb
|
|
79
|
+
- lib/console_kit/setup_ui.rb
|
|
61
80
|
- lib/console_kit/tenant_configurator.rb
|
|
62
81
|
- lib/console_kit/tenant_selector.rb
|
|
63
82
|
- lib/console_kit/version.rb
|
|
64
83
|
- lib/generators/console_kit/install_generator.rb
|
|
65
84
|
- lib/generators/console_kit/templates/console_kit.rb
|
|
66
|
-
- sig/console_kit.rbs
|
|
67
85
|
homepage: https://github.com/Soumyadeep-ai/console_kit
|
|
68
86
|
licenses:
|
|
69
87
|
- MIT
|
data/CHANGELOG.md
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## [1.0.0] - 2026-03-01
|
|
10
|
-
### Added
|
|
11
|
-
- **Global Configuration Persistence:** ConsoleKit settings now persist across the entire session and across multiple threads.
|
|
12
|
-
- **Isolated Tenant Selection:** Each thread maintains its own tenant selection for safety, while sharing the global configuration.
|
|
13
|
-
- **Seamless Rails Reloading:** Full support for Rails `reload!`; your selected tenant and context are now automatically preserved after code reloads.
|
|
14
|
-
- **Reliable Tenant Switching:** Switching or clearing tenants now correctly resets all database connections (SQL and MongoDB) to their default state.
|
|
15
|
-
- **Flexible Tenant Selection:** Users can now select tenants by typing their names (case-insensitive) in addition to index numbers.
|
|
16
|
-
- **Session Control:** Added support for `exit` or `quit` commands directly at the selection prompt to terminate the console session.
|
|
17
|
-
- **Safe Mode:** Added a "Skip" option (0) to load the console without any tenant configuration.
|
|
18
|
-
- **Improved Configuration Validation:** Enhanced startup checks to provide clearer feedback if the configuration or context class is incorrectly defined.
|
|
19
|
-
- **Custom SQL Base Class:** New configuration option to specify a custom base class for SQL connections.
|
|
20
|
-
|
|
21
|
-
### Changed
|
|
22
|
-
- **Modernized CLI Interface:** Redesigned the tenant selection menu and prompts for a cleaner, more intuitive user experience.
|
|
23
|
-
- **Enhanced Error Feedback:** Improved messaging for invalid selections and missing configurations.
|
|
24
|
-
- **Optimized Performance:** Refactored internal discovery and configuration logic for better reliability in large applications.
|
|
25
|
-
|
|
26
|
-
### Fixed
|
|
27
|
-
- Fixed a bug where tenant context was lost after running `reload!` in the Rails console.
|
|
28
|
-
- Fixed an issue where database connections could remain tied to a previous tenant after the context was cleared.
|
|
29
|
-
- Resolved all stability and code quality warnings.
|
|
30
|
-
- Fixed timestamp formatting in console output.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## [0.1.5] - 2025-10-12
|
|
35
|
-
### Added
|
|
36
|
-
- Minor Bug Fixes
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## [0.1.4] - 2025-09-30
|
|
41
|
-
### Added
|
|
42
|
-
- Minor Fixes and Improvements
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## [0.1.3] - 2025-08-12
|
|
47
|
-
### Added
|
|
48
|
-
- `ConsoleKit.current_tenant` method to retrieve the current tenant at runtime.
|
|
49
|
-
- `ConsoleKit.reset_current_tenant` to reset tenant selection.
|
|
50
|
-
- `pretty_output` configuration added with ability to manually toggle CLI verbosity.
|
|
51
|
-
|
|
52
|
-
### Changed
|
|
53
|
-
- Refactored internal logic for improved maintainability and future extensibility.
|
|
54
|
-
- Enhanced test coverage for better reliability and edge case handling.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## [0.1.2] - 2025-07-23
|
|
59
|
-
### Added
|
|
60
|
-
- Changelog added.
|
|
61
|
-
- Readme and installation instructions added.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## [0.1.1] - 2025-07-21
|
|
66
|
-
### Added
|
|
67
|
-
- Initial generator: `console_kit:install` to scaffold configuration.
|
|
68
|
-
- RSpec test suite to support core features.
|
|
69
|
-
|
|
70
|
-
### Changed
|
|
71
|
-
- Applied RuboCop fixes for code consistency and style.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## [0.1.0] - 2025-07-09
|
|
76
|
-
|
|
77
|
-
- Initial release
|
|
78
|
-
|
|
79
|
-
### Added
|
|
80
|
-
- Core setup logic for ConsoleKit:
|
|
81
|
-
- `ConsoleKit.setup`
|
|
82
|
-
- Tenant selection via CLI.
|
|
83
|
-
- Tenant-specific database configuration.
|
|
84
|
-
- Colorized console output for improved UX.
|
|
85
|
-
|
|
86
|
-
[1.0.0]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v1.0.0
|
|
87
|
-
[0.1.5]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v0.1.5
|
|
88
|
-
[0.1.4]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v0.1.4
|
|
89
|
-
[0.1.3]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v0.1.3
|
|
90
|
-
[0.1.2]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v0.1.2
|
|
91
|
-
[0.1.1]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v0.1.1
|
|
92
|
-
[0.1.0]: https://github.com/Soumyadeep-ai/console_kit/releases/tag/v0.1.0
|