strata-cli 0.1.8 → 0.1.9
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/CHANGELOG.md +17 -0
- data/lib/strata/cli/ai/services/table_generator.rb +35 -20
- data/lib/strata/cli/api/client.rb +23 -63
- data/lib/strata/cli/api/response_error_handler.rb +115 -0
- data/lib/strata/cli/error_reporter.rb +4 -1
- data/lib/strata/cli/generators/datasource.rb +4 -3
- data/lib/strata/cli/generators/group.rb +37 -0
- data/lib/strata/cli/generators/migration.rb +2 -1
- data/lib/strata/cli/generators/project.rb +18 -11
- data/lib/strata/cli/generators/relation.rb +2 -1
- data/lib/strata/cli/generators/table.rb +5 -8
- data/lib/strata/cli/generators/templates/table.table_name.yml +1 -1
- data/lib/strata/cli/generators/test.rb +2 -1
- data/lib/strata/cli/guard.rb +4 -1
- data/lib/strata/cli/helpers/command_context.rb +8 -9
- data/lib/strata/cli/helpers/datasource_helper.rb +1 -1
- data/lib/strata/cli/helpers/description_helper.rb +2 -1
- data/lib/strata/cli/main.rb +15 -3
- data/lib/strata/cli/output.rb +103 -0
- data/lib/strata/cli/sub_commands/audit.rb +4 -3
- data/lib/strata/cli/sub_commands/branch.rb +163 -0
- data/lib/strata/cli/sub_commands/create.rb +1 -2
- data/lib/strata/cli/sub_commands/datasource.rb +2 -0
- data/lib/strata/cli/sub_commands/deploy.rb +14 -13
- data/lib/strata/cli/sub_commands/project.rb +4 -3
- data/lib/strata/cli/sub_commands/table.rb +9 -8
- data/lib/strata/cli/terminal.rb +7 -4
- data/lib/strata/cli/ui/field_editor.rb +21 -27
- data/lib/strata/cli/utils/deployment_monitor.rb +15 -34
- data/lib/strata/cli/utils/git.rb +78 -0
- data/lib/strata/cli/utils/import_manager.rb +4 -1
- data/lib/strata/cli/utils/test_reporter.rb +4 -32
- data/lib/strata/cli/utils/version_checker.rb +4 -8
- data/lib/strata/cli/utils.rb +3 -1
- data/lib/strata/cli/version.rb +1 -1
- data/lib/strata/cli.rb +4 -3
- metadata +4 -2
- data/lib/strata/cli/helpers/color_helper.rb +0 -103
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../helpers/color_helper"
|
|
4
3
|
require_relative "../helpers/prompts"
|
|
5
4
|
require_relative "../helpers/command_context"
|
|
5
|
+
require_relative "../output"
|
|
6
6
|
|
|
7
7
|
module Strata
|
|
8
8
|
module CLI
|
|
@@ -10,6 +10,7 @@ module Strata
|
|
|
10
10
|
class Table < Thor
|
|
11
11
|
include Guard
|
|
12
12
|
include Terminal
|
|
13
|
+
include Output
|
|
13
14
|
include Prompts
|
|
14
15
|
include Thor::Actions
|
|
15
16
|
include Helpers::CommandContext
|
|
@@ -18,24 +19,24 @@ module Strata
|
|
|
18
19
|
desc "list", "List all semantic models in the project"
|
|
19
20
|
def list
|
|
20
21
|
unless Dir.exist?("models")
|
|
21
|
-
|
|
22
|
+
print_warning(MSG_NO_MODELS_DIR)
|
|
22
23
|
return
|
|
23
24
|
end
|
|
24
25
|
|
|
25
|
-
model_files = Dir.glob("models
|
|
26
|
+
model_files = Dir.glob("models/**/tbl[._]*.yml").sort
|
|
26
27
|
|
|
27
28
|
if model_files.empty?
|
|
28
|
-
|
|
29
|
+
print_warning(MSG_NO_MODELS_FOUND)
|
|
29
30
|
return
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
print_info(MSG_MODELS_LIST_HEADER)
|
|
33
34
|
|
|
34
35
|
model_files.each do |file|
|
|
35
36
|
display_model_item(file)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
print_info(MSG_MODELS_COUNT % model_files.length)
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
private
|
|
@@ -47,9 +48,9 @@ module Strata
|
|
|
47
48
|
desc = "#{desc[0..50]}..." if desc.length > 50
|
|
48
49
|
|
|
49
50
|
if desc.empty?
|
|
50
|
-
|
|
51
|
+
print_info(" #{name}")
|
|
51
52
|
else
|
|
52
|
-
|
|
53
|
+
print_info(" #{name.ljust(25)} #{desc}")
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
56
|
end
|
data/lib/strata/cli/terminal.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "tty-spinner"
|
|
|
4
4
|
require "pastel"
|
|
5
5
|
require "tty-table"
|
|
6
6
|
require "io/console"
|
|
7
|
+
require_relative "output"
|
|
7
8
|
|
|
8
9
|
module Strata
|
|
9
10
|
module CLI
|
|
@@ -23,13 +24,15 @@ module Strata
|
|
|
23
24
|
|
|
24
25
|
# Shows a loader while running IO tasks
|
|
25
26
|
# Uses consistent format matching deployment monitor: cyan spinner that transitions to checkmark
|
|
26
|
-
def with_spinner(
|
|
27
|
+
def with_spinner(
|
|
28
|
+
message = "Loading...",
|
|
27
29
|
success_message: "",
|
|
28
30
|
failed_message: "",
|
|
29
31
|
clear: false,
|
|
30
32
|
message_color: :cyan,
|
|
31
33
|
spinner_color: :cyan,
|
|
32
|
-
format: :dots
|
|
34
|
+
format: :dots
|
|
35
|
+
)
|
|
33
36
|
spinner = create_spinner(message,
|
|
34
37
|
message_color: message_color,
|
|
35
38
|
spinner_color: spinner_color,
|
|
@@ -39,10 +42,10 @@ module Strata
|
|
|
39
42
|
|
|
40
43
|
begin
|
|
41
44
|
result = yield
|
|
42
|
-
spinner.success(success_message.empty? ? "" :
|
|
45
|
+
spinner.success(success_message.empty? ? "" : Output.format(:success, success_message))
|
|
43
46
|
result
|
|
44
47
|
rescue => e
|
|
45
|
-
spinner.error(failed_message.empty? ? "" :
|
|
48
|
+
spinner.error(failed_message.empty? ? "" : Output.format(:error, failed_message))
|
|
46
49
|
raise e
|
|
47
50
|
end
|
|
48
51
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require "tty-prompt"
|
|
4
4
|
require "tty-table"
|
|
5
5
|
require "pastel"
|
|
6
|
-
require_relative "../
|
|
6
|
+
require_relative "../output"
|
|
7
7
|
|
|
8
8
|
module Strata
|
|
9
9
|
module CLI
|
|
@@ -77,21 +77,19 @@ module Strata
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def display_table
|
|
80
|
-
|
|
81
|
-
puts colors.highlight("\n Field Editor - Review & Edit Generated Fields\n")
|
|
80
|
+
puts Output.format(:highlight, "\n Field Editor - Review & Edit Generated Fields\n")
|
|
82
81
|
|
|
83
82
|
rows = @fields.each_with_index.map do |field, idx|
|
|
84
|
-
indicator = (idx == @selected_index) ?
|
|
85
|
-
status = field[:skipped] ?
|
|
83
|
+
indicator = (idx == @selected_index) ? Output.format(:selected, "❯") : " "
|
|
84
|
+
status = field[:skipped] ? Output.format(:disabled, "[SKIP]") : ""
|
|
86
85
|
|
|
87
|
-
name_cell = field[:skipped] ?
|
|
86
|
+
name_cell = field[:skipped] ? Output.format(:disabled, field[:name]) : field[:name]
|
|
88
87
|
desc_cell = if field[:skipped]
|
|
89
|
-
|
|
90
|
-
25))
|
|
88
|
+
Output.format(:disabled, truncate(field[:description], 25))
|
|
91
89
|
else
|
|
92
90
|
truncate(field[:description], 25)
|
|
93
91
|
end
|
|
94
|
-
expr_cell = field[:skipped] ?
|
|
92
|
+
expr_cell = field[:skipped] ? Output.format(:disabled, field[:expression]) : field[:expression]
|
|
95
93
|
|
|
96
94
|
[
|
|
97
95
|
"#{indicator} #{status}",
|
|
@@ -112,14 +110,13 @@ module Strata
|
|
|
112
110
|
end
|
|
113
111
|
|
|
114
112
|
def display_help
|
|
115
|
-
colors = ColorHelper
|
|
116
113
|
puts ""
|
|
117
|
-
puts " #{
|
|
118
|
-
"#{
|
|
119
|
-
"#{
|
|
120
|
-
"#{
|
|
121
|
-
"#{
|
|
122
|
-
"#{
|
|
114
|
+
puts " #{Output.format(:info, "↑/↓")} Navigate " \
|
|
115
|
+
"#{Output.format(:success, "[Enter]")} Edit " \
|
|
116
|
+
"#{Output.format(:warning, "[S]")}kip " \
|
|
117
|
+
"#{Output.format(:primary, "[P]")}rompt " \
|
|
118
|
+
"#{Output.format(:secondary, "[C]")}onfirm " \
|
|
119
|
+
"#{Output.format(:error, "[Q/Esc]")}uit"
|
|
123
120
|
puts ""
|
|
124
121
|
end
|
|
125
122
|
|
|
@@ -129,10 +126,9 @@ module Strata
|
|
|
129
126
|
|
|
130
127
|
def edit_current_field
|
|
131
128
|
field = @fields[@selected_index]
|
|
132
|
-
colors = ColorHelper
|
|
133
129
|
|
|
134
|
-
puts
|
|
135
|
-
puts
|
|
130
|
+
puts Output.format(:highlight, "\n Editing: #{field[:name]}\n")
|
|
131
|
+
puts Output.format(:dim, " (Press Ctrl+C or type 'back' to go back without saving)\n")
|
|
136
132
|
|
|
137
133
|
begin
|
|
138
134
|
field[:name] = prompt.ask(" Field Name:", default: field[:name])
|
|
@@ -170,20 +166,18 @@ module Strata
|
|
|
170
166
|
end
|
|
171
167
|
|
|
172
168
|
def handle_prompt_mode
|
|
173
|
-
require_relative "../ai/services/
|
|
169
|
+
require_relative "../ai/services/table_generator"
|
|
174
170
|
require_relative "../terminal"
|
|
175
|
-
generator = AI::Services::
|
|
176
|
-
|
|
177
|
-
colors = ColorHelper
|
|
171
|
+
generator = AI::Services::TableGenerator.new
|
|
178
172
|
|
|
179
173
|
unless generator.ai_available?
|
|
180
|
-
puts
|
|
174
|
+
puts Output.format(:warning, "\n AI is not available. Configure AI in .strata file.")
|
|
181
175
|
sleep 1.5
|
|
182
176
|
return
|
|
183
177
|
end
|
|
184
178
|
|
|
185
179
|
unless @table_context
|
|
186
|
-
puts
|
|
180
|
+
puts Output.format(:warning, "\n Prompt mode requires table context.")
|
|
187
181
|
sleep 1.5
|
|
188
182
|
return
|
|
189
183
|
end
|
|
@@ -208,11 +202,11 @@ module Strata
|
|
|
208
202
|
@selected_index = 0
|
|
209
203
|
# No message needed - table will refresh and show new fields
|
|
210
204
|
else
|
|
211
|
-
puts
|
|
205
|
+
puts Output.format(:warning, " No changes - keeping current fields")
|
|
212
206
|
sleep 1
|
|
213
207
|
end
|
|
214
208
|
rescue => e
|
|
215
|
-
puts
|
|
209
|
+
puts Output.format(:error, "\n Error: #{e.message}")
|
|
216
210
|
sleep 2
|
|
217
211
|
end
|
|
218
212
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../helpers/color_helper"
|
|
4
3
|
require_relative "../terminal"
|
|
4
|
+
require_relative "../output"
|
|
5
5
|
require "tty-spinner"
|
|
6
6
|
require "pastel"
|
|
7
7
|
|
|
@@ -117,8 +117,8 @@ module Strata
|
|
|
117
117
|
|
|
118
118
|
if Time.now - start_time > timeout
|
|
119
119
|
complete_stage(TESTING_STAGE) if @tests_running
|
|
120
|
-
say "\n Monitoring timeout reached (#{timeout}s)",
|
|
121
|
-
say " Deployment may still be in progress. Check server for status.\n",
|
|
120
|
+
say "\n Monitoring timeout reached (#{timeout}s)", :warning
|
|
121
|
+
say " Deployment may still be in progress. Check server for status.\n", :info
|
|
122
122
|
return deployment
|
|
123
123
|
end
|
|
124
124
|
|
|
@@ -126,13 +126,13 @@ module Strata
|
|
|
126
126
|
end
|
|
127
127
|
rescue Interrupt
|
|
128
128
|
stop_all_spinners
|
|
129
|
-
say "\n\n Monitoring interrupted. Deployment continues in background.",
|
|
130
|
-
say " Check server for deployment status with command `strata deploy status`.\n",
|
|
129
|
+
say "\n\n Monitoring interrupted. Deployment continues in background.", :warning
|
|
130
|
+
say " Check server for deployment status with command `strata deploy status`.\n", :info
|
|
131
131
|
nil
|
|
132
132
|
rescue => e
|
|
133
133
|
stop_all_spinners
|
|
134
|
-
say "\n Error monitoring deployment: #{e.message}",
|
|
135
|
-
say " Check server for deployment status.\n",
|
|
134
|
+
say "\n Error monitoring deployment: #{e.message}", :error
|
|
135
|
+
say " Check server for deployment status.\n", :info
|
|
136
136
|
nil
|
|
137
137
|
end
|
|
138
138
|
|
|
@@ -150,11 +150,11 @@ module Strata
|
|
|
150
150
|
deployment
|
|
151
151
|
rescue Interrupt
|
|
152
152
|
stop_all_spinners
|
|
153
|
-
say "\n\n Exiting status view.\n",
|
|
153
|
+
say "\n\n Exiting status view.\n", :info
|
|
154
154
|
nil
|
|
155
155
|
rescue => e
|
|
156
156
|
stop_all_spinners
|
|
157
|
-
say "\n Error fetching deployment status: #{e.message}",
|
|
157
|
+
say "\n Error fetching deployment status: #{e.message}", :error
|
|
158
158
|
nil
|
|
159
159
|
end
|
|
160
160
|
|
|
@@ -169,42 +169,23 @@ module Strata
|
|
|
169
169
|
|
|
170
170
|
private
|
|
171
171
|
|
|
172
|
-
def say(message,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
colored_message = case color_helper_result
|
|
176
|
-
when Array
|
|
177
|
-
ColorHelper.pastel.decorate(message, *color_helper_result)
|
|
178
|
-
when Symbol
|
|
179
|
-
theme = ColorHelper::THEME[color_helper_result]
|
|
180
|
-
if theme
|
|
181
|
-
ColorHelper.pastel.decorate(message, *Array(theme))
|
|
182
|
-
else
|
|
183
|
-
begin
|
|
184
|
-
ColorHelper.pastel.send(color_helper_result, message)
|
|
185
|
-
rescue NoMethodError
|
|
186
|
-
message
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
else
|
|
190
|
-
message
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
$stdout.puts(colored_message)
|
|
172
|
+
def say(message, type = nil)
|
|
173
|
+
shell = Output.shell_for(nil)
|
|
174
|
+
shell.say(type ? Output.format(type, message) : message)
|
|
194
175
|
end
|
|
195
176
|
|
|
196
177
|
def display_initial_status
|
|
197
|
-
say "\n Monitoring deployment progress...\n",
|
|
178
|
+
say "\n Monitoring deployment progress...\n", :title
|
|
198
179
|
end
|
|
199
180
|
|
|
200
181
|
def display_exit_instruction
|
|
201
|
-
say " Press Ctrl+C to exit monitoring.\n",
|
|
182
|
+
say " Press Ctrl+C to exit monitoring.\n", :dim
|
|
202
183
|
end
|
|
203
184
|
|
|
204
185
|
def fetch_deployment_status
|
|
205
186
|
@client.get_deployment(@project_id, @branch_id, @deployment_id)
|
|
206
187
|
rescue Strata::CommandError => e
|
|
207
|
-
say "\n Could not fetch deployment status: #{e.message}",
|
|
188
|
+
say "\n Could not fetch deployment status: #{e.message}", :warning
|
|
208
189
|
nil
|
|
209
190
|
end
|
|
210
191
|
|
data/lib/strata/cli/utils/git.rb
CHANGED
|
@@ -21,6 +21,53 @@ module Strata
|
|
|
21
21
|
run_git_command("rev-parse", "--abbrev-ref", "HEAD")
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def local_branches
|
|
25
|
+
return [] unless git_repo?
|
|
26
|
+
|
|
27
|
+
output = run_git_command("branch", "--format", "%(refname:short)")
|
|
28
|
+
return [] unless output
|
|
29
|
+
|
|
30
|
+
output.lines.map(&:strip).reject(&:empty?)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def create_and_checkout_branch(branch_name)
|
|
34
|
+
ensure_git_repo!
|
|
35
|
+
branch_name = validate_branch_name!(branch_name)
|
|
36
|
+
|
|
37
|
+
_, stderr, status = Open3.capture3("git", "switch", "-c", branch_name)
|
|
38
|
+
raise Strata::CommandError, "Failed to create branch '#{branch_name}': #{stderr.strip}" unless status.success?
|
|
39
|
+
|
|
40
|
+
branch_name
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def checkout_branch(branch_name)
|
|
44
|
+
ensure_git_repo!
|
|
45
|
+
branch_name = validate_branch_name!(branch_name)
|
|
46
|
+
|
|
47
|
+
_, stderr, status = Open3.capture3("git", "switch", branch_name)
|
|
48
|
+
raise Strata::CommandError, "Failed to checkout branch '#{branch_name}': #{stderr.strip}" unless status.success?
|
|
49
|
+
|
|
50
|
+
branch_name
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def delete_local_branch(branch_name, fallback_branches: %w[main master])
|
|
54
|
+
return :not_git_repo unless git_repo?
|
|
55
|
+
|
|
56
|
+
branch_name = branch_name.to_s.strip
|
|
57
|
+
raise Strata::CommandError, "Branch name is required." if branch_name.empty?
|
|
58
|
+
|
|
59
|
+
return :not_found unless local_branch_exists?(branch_name)
|
|
60
|
+
|
|
61
|
+
if current_branch == branch_name
|
|
62
|
+
switch_to_fallback_branch(branch_name, fallback_branches)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
_, stderr, status = Open3.capture3("git", "branch", "-D", branch_name)
|
|
66
|
+
raise Strata::CommandError, "Failed to delete local branch '#{branch_name}': #{stderr.strip}" unless status.success?
|
|
67
|
+
|
|
68
|
+
:deleted
|
|
69
|
+
end
|
|
70
|
+
|
|
24
71
|
def commit_info
|
|
25
72
|
sha = run_git_command("rev-parse", "HEAD")
|
|
26
73
|
message = run_git_command("log", "-1", "--pretty=%B")
|
|
@@ -121,6 +168,21 @@ module Strata
|
|
|
121
168
|
false
|
|
122
169
|
end
|
|
123
170
|
|
|
171
|
+
def local_branch_exists?(branch_name)
|
|
172
|
+
_, _, status = Open3.capture3("git", "show-ref", "--verify", "--quiet", "refs/heads/#{branch_name}")
|
|
173
|
+
status.success?
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def validate_branch_name!(branch_name)
|
|
177
|
+
branch_name = branch_name.to_s.strip
|
|
178
|
+
raise Strata::CommandError, "Branch name is required." if branch_name.empty?
|
|
179
|
+
|
|
180
|
+
_, stderr, status = Open3.capture3("git", "check-ref-format", "--branch", branch_name)
|
|
181
|
+
raise Strata::CommandError, "Invalid branch name '#{branch_name}': #{stderr.strip}" unless status.success?
|
|
182
|
+
|
|
183
|
+
branch_name
|
|
184
|
+
end
|
|
185
|
+
|
|
124
186
|
def check_requirement_and_exit_if_unavailable(args)
|
|
125
187
|
# Allow help and version commands to work without Git
|
|
126
188
|
command = args.first
|
|
@@ -149,6 +211,22 @@ module Strata
|
|
|
149
211
|
stdout&.strip
|
|
150
212
|
end
|
|
151
213
|
|
|
214
|
+
def ensure_git_repo!
|
|
215
|
+
raise Strata::CommandError, "Not a git repository." unless git_repo?
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def switch_to_fallback_branch(branch_name, fallback_branches)
|
|
219
|
+
fallback_branch = fallback_branches.find { |candidate| candidate != branch_name && local_branch_exists?(candidate) }
|
|
220
|
+
|
|
221
|
+
unless fallback_branch
|
|
222
|
+
raise Strata::CommandError,
|
|
223
|
+
"Cannot delete the currently checked out branch '#{branch_name}'. Check out another branch and try again."
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
_, stderr, status = Open3.capture3("git", "switch", fallback_branch)
|
|
227
|
+
raise Strata::CommandError, "Failed to switch to '#{fallback_branch}': #{stderr.strip}" unless status.success?
|
|
228
|
+
end
|
|
229
|
+
|
|
152
230
|
def parse_diff_output(output)
|
|
153
231
|
output.lines.map do |line|
|
|
154
232
|
parse_diff_status(line.strip)
|
|
@@ -135,7 +135,10 @@ module Strata
|
|
|
135
135
|
|
|
136
136
|
YAML.safe_load_file(lock_path, permitted_classes: [Date, Time], aliases: true) || default_lock_data
|
|
137
137
|
rescue => e
|
|
138
|
-
|
|
138
|
+
if ENV["DEBUG"]
|
|
139
|
+
require_relative "../output"
|
|
140
|
+
Output.print_warning("Failed to load lock file: #{e.message}")
|
|
141
|
+
end
|
|
139
142
|
default_lock_data
|
|
140
143
|
end
|
|
141
144
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../helpers/color_helper"
|
|
4
3
|
require_relative "../terminal"
|
|
4
|
+
require_relative "../output"
|
|
5
5
|
|
|
6
6
|
module Strata
|
|
7
7
|
module CLI
|
|
@@ -9,10 +9,6 @@ module Strata
|
|
|
9
9
|
class TestReporter
|
|
10
10
|
include Terminal
|
|
11
11
|
|
|
12
|
-
def initialize(color_helper: ColorHelper)
|
|
13
|
-
@color_helper = color_helper
|
|
14
|
-
end
|
|
15
|
-
|
|
16
12
|
def display(test_results, skip_opening_divider: false)
|
|
17
13
|
return unless test_results.is_a?(Hash) && test_results["tests"].is_a?(Array)
|
|
18
14
|
|
|
@@ -22,33 +18,9 @@ module Strata
|
|
|
22
18
|
|
|
23
19
|
private
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if color_helper_result
|
|
29
|
-
if color_helper_result.is_a?(Array)
|
|
30
|
-
colored_message = ColorHelper.pastel.decorate(message, *color_helper_result)
|
|
31
|
-
$stdout.puts(colored_message)
|
|
32
|
-
elsif color_helper_result.is_a?(Symbol)
|
|
33
|
-
theme = ColorHelper::THEME[color_helper_result]
|
|
34
|
-
if theme
|
|
35
|
-
styles = Array(theme)
|
|
36
|
-
colored_message = ColorHelper.pastel.decorate(message, *styles)
|
|
37
|
-
$stdout.puts(colored_message)
|
|
38
|
-
else
|
|
39
|
-
begin
|
|
40
|
-
colored_message = ColorHelper.pastel.send(color_helper_result, message)
|
|
41
|
-
$stdout.puts(colored_message)
|
|
42
|
-
rescue NoMethodError
|
|
43
|
-
$stdout.puts(message)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
else
|
|
47
|
-
$stdout.puts(message)
|
|
48
|
-
end
|
|
49
|
-
else
|
|
50
|
-
$stdout.puts(message)
|
|
51
|
-
end
|
|
21
|
+
def say(message, type = nil)
|
|
22
|
+
shell = Output.shell_for(nil)
|
|
23
|
+
shell.say(type ? Output.format(type, message) : message)
|
|
52
24
|
end
|
|
53
25
|
|
|
54
26
|
def display_summary(test_results, skip_opening_divider: false)
|
|
@@ -29,7 +29,7 @@ module Strata
|
|
|
29
29
|
update_cache
|
|
30
30
|
rescue
|
|
31
31
|
# Silently fail - version checking should never break the CLI
|
|
32
|
-
# In development, you might want to log this
|
|
32
|
+
# In development, you might want to log this failure.
|
|
33
33
|
nil
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -81,15 +81,11 @@ module Strata
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def display_update_message(version)
|
|
84
|
-
require_relative "../helpers/color_helper"
|
|
85
|
-
colors = ColorHelper
|
|
86
|
-
|
|
87
84
|
message = "💡 Tip: A new version of #{GEM_NAME} (#{version}) is available. " \
|
|
88
|
-
"Update with: #{
|
|
85
|
+
"Update with: #{Output.format(:info, "gem update strata-cli")}"
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
shell.say "\n#{colors.warning(message)}\n"
|
|
87
|
+
require_relative "../output"
|
|
88
|
+
Output.print_warning("\n#{message}\n")
|
|
93
89
|
end
|
|
94
90
|
|
|
95
91
|
def skip_check?
|
data/lib/strata/cli/utils.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "output"
|
|
4
|
+
|
|
3
5
|
module Strata
|
|
4
6
|
module CLI
|
|
5
7
|
module Utils
|
|
@@ -16,7 +18,7 @@ module Strata
|
|
|
16
18
|
def exit_error_if_not_strata!
|
|
17
19
|
return if CLI.config.strata_project?
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Output.print_error("ERROR: This is not a valid strata project")
|
|
20
22
|
exit 1
|
|
21
23
|
end
|
|
22
24
|
|
data/lib/strata/cli/version.rb
CHANGED
data/lib/strata/cli.rb
CHANGED
|
@@ -9,6 +9,7 @@ require_relative "cli/utils"
|
|
|
9
9
|
require_relative "cli/utils/git"
|
|
10
10
|
require_relative "cli/utils/version_checker"
|
|
11
11
|
require_relative "cli/error_reporter"
|
|
12
|
+
require_relative "cli/output"
|
|
12
13
|
|
|
13
14
|
module Strata
|
|
14
15
|
class StrataError < StandardError; end
|
|
@@ -37,12 +38,12 @@ module Strata
|
|
|
37
38
|
begin
|
|
38
39
|
Main.start(args)
|
|
39
40
|
rescue TTY::Reader::InputInterrupt
|
|
40
|
-
|
|
41
|
+
Output.print_warning("\nCancelled.")
|
|
41
42
|
exit(1)
|
|
42
43
|
rescue => e
|
|
43
44
|
ErrorReporter.log_error(e, context: "strata #{args.join(" ")}")
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
Output.print_error("ERROR: #{ErrorReporter.user_message_for(e)}")
|
|
46
|
+
Output.print_hint("Hint: See #{ErrorReporter.log_relative_path} for details.", stderr: true)
|
|
46
47
|
exit(1)
|
|
47
48
|
end
|
|
48
49
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strata-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ajo Abraham
|
|
@@ -247,6 +247,7 @@ files:
|
|
|
247
247
|
- lib/strata/cli/ai/services/table_generator.rb
|
|
248
248
|
- lib/strata/cli/api/client.rb
|
|
249
249
|
- lib/strata/cli/api/connection_error_handler.rb
|
|
250
|
+
- lib/strata/cli/api/response_error_handler.rb
|
|
250
251
|
- lib/strata/cli/configuration.rb
|
|
251
252
|
- lib/strata/cli/credentials.rb
|
|
252
253
|
- lib/strata/cli/descriptions/create/migration.txt
|
|
@@ -288,7 +289,6 @@ files:
|
|
|
288
289
|
- lib/strata/cli/generators/templates/test.yml
|
|
289
290
|
- lib/strata/cli/generators/test.rb
|
|
290
291
|
- lib/strata/cli/guard.rb
|
|
291
|
-
- lib/strata/cli/helpers/color_helper.rb
|
|
292
292
|
- lib/strata/cli/helpers/command_context.rb
|
|
293
293
|
- lib/strata/cli/helpers/datasource_helper.rb
|
|
294
294
|
- lib/strata/cli/helpers/description_helper.rb
|
|
@@ -296,7 +296,9 @@ files:
|
|
|
296
296
|
- lib/strata/cli/helpers/prompts.rb
|
|
297
297
|
- lib/strata/cli/helpers/table_filter.rb
|
|
298
298
|
- lib/strata/cli/main.rb
|
|
299
|
+
- lib/strata/cli/output.rb
|
|
299
300
|
- lib/strata/cli/sub_commands/audit.rb
|
|
301
|
+
- lib/strata/cli/sub_commands/branch.rb
|
|
300
302
|
- lib/strata/cli/sub_commands/create.rb
|
|
301
303
|
- lib/strata/cli/sub_commands/datasource.rb
|
|
302
304
|
- lib/strata/cli/sub_commands/deploy.rb
|