solidstats 2.0.0 ā 3.0.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/CHANGELOG.md +12 -63
- data/README.md +27 -0
- data/Rakefile +3 -3
- data/app/assets/javascripts/solidstats/dashboard.js +0 -46
- data/app/assets/stylesheets/solidstats/dashboard.css +48 -0
- data/app/controllers/solidstats/dashboard_controller.rb +73 -61
- data/app/controllers/solidstats/logs_controller.rb +72 -0
- data/app/controllers/solidstats/performance_controller.rb +25 -0
- data/app/controllers/solidstats/productivity_controller.rb +39 -0
- data/app/controllers/solidstats/quality_controller.rb +152 -0
- data/app/controllers/solidstats/securities_controller.rb +30 -0
- data/app/helpers/solidstats/application_helper.rb +124 -11
- data/app/helpers/solidstats/performance_helper.rb +87 -0
- data/app/helpers/solidstats/productivity_helper.rb +38 -0
- data/app/services/solidstats/bundler_audit_service.rb +206 -0
- data/app/services/solidstats/coverage_compass_service.rb +335 -0
- data/app/services/solidstats/load_lens_service.rb +474 -0
- data/app/services/solidstats/log_size_monitor_service.rb +197 -66
- data/app/services/solidstats/my_todo_service.rb +242 -0
- data/app/services/solidstats/style_patrol_service.rb +319 -0
- data/app/views/layouts/solidstats/application.html.erb +8 -2
- data/app/views/layouts/solidstats/dashboard.html.erb +84 -0
- data/app/views/solidstats/dashboard/dashboard.html.erb +39 -0
- data/app/views/solidstats/logs/logs_size.html.erb +409 -0
- data/app/views/solidstats/performance/load_lens.html.erb +158 -0
- data/app/views/solidstats/productivity/_todo_list.html.erb +49 -0
- data/app/views/solidstats/productivity/my_todos.html.erb +84 -0
- data/app/views/solidstats/quality/coverage_compass.html.erb +420 -0
- data/app/views/solidstats/quality/style_patrol.html.erb +463 -0
- data/app/views/solidstats/securities/bundler_audit.html.erb +345 -0
- data/app/views/solidstats/shared/_dashboard_card.html.erb +160 -0
- data/app/views/solidstats/shared/_quick_actions.html.erb +26 -0
- data/config/routes.rb +31 -6
- data/lib/generators/solidstats/clean/clean_generator.rb +24 -0
- data/lib/generators/solidstats/clean/templates/README +8 -0
- data/lib/generators/solidstats/install/install_generator.rb +51 -10
- data/lib/generators/solidstats/install/templates/README +7 -0
- data/lib/solidstats/engine.rb +6 -71
- data/lib/solidstats/version.rb +1 -1
- data/lib/solidstats.rb +19 -303
- data/lib/tasks/solidstats.rake +67 -0
- data/lib/tasks/solidstats_performance.rake +61 -0
- data/lib/tasks/solidstats_tasks.rake +16 -4
- metadata +33 -95
- data/app/assets/javascripts/solidstats/gem_metadata.js +0 -554
- data/app/assets/stylesheets/solidstats/components/action_button.css +0 -99
- data/app/assets/stylesheets/solidstats/components/dashboard.css +0 -151
- data/app/assets/stylesheets/solidstats/components/dashboard_header.css +0 -93
- data/app/assets/stylesheets/solidstats/components/dashboard_layout.css +0 -97
- data/app/assets/stylesheets/solidstats/components/gem_metadata.css +0 -1403
- data/app/assets/stylesheets/solidstats/components/navigation.css +0 -80
- data/app/assets/stylesheets/solidstats/components/quick_navigation.css +0 -54
- data/app/assets/stylesheets/solidstats/components/security.css +0 -332
- data/app/assets/stylesheets/solidstats/components/status_badge.css +0 -58
- data/app/assets/stylesheets/solidstats/components/summary_card.css +0 -66
- data/app/assets/stylesheets/solidstats/components/tab_navigation.css +0 -95
- data/app/components/solidstats/base_component.rb +0 -88
- data/app/components/solidstats/code_quality/code_quality_section_component.html.erb +0 -0
- data/app/components/solidstats/code_quality/code_quality_section_component.rb +0 -0
- data/app/components/solidstats/code_quality/section_component.html.erb +0 -45
- data/app/components/solidstats/code_quality/section_component.rb +0 -34
- data/app/components/solidstats/dashboard_header_component.html.erb +0 -39
- data/app/components/solidstats/dashboard_header_component.rb +0 -33
- data/app/components/solidstats/previews/action_button_component_preview/button_vs_link.html.erb +0 -6
- data/app/components/solidstats/previews/action_button_component_preview/sizes.html.erb +0 -6
- data/app/components/solidstats/previews/action_button_component_preview/variants.html.erb +0 -6
- data/app/components/solidstats/previews/action_button_component_preview/with_icons.html.erb +0 -6
- data/app/components/solidstats/previews/action_button_component_preview.rb +0 -64
- data/app/components/solidstats/previews/navigation_component_preview.rb +0 -74
- data/app/components/solidstats/previews/stats_overview_component_preview.rb +0 -100
- data/app/components/solidstats/previews/status_badge_component_preview/sizes.html.erb +0 -6
- data/app/components/solidstats/previews/status_badge_component_preview/statuses.html.erb +0 -6
- data/app/components/solidstats/previews/status_badge_component_preview/with_icons.html.erb +0 -6
- data/app/components/solidstats/previews/status_badge_component_preview.rb +0 -49
- data/app/components/solidstats/previews/summary_card_component_preview/clickable.html.erb +0 -9
- data/app/components/solidstats/previews/summary_card_component_preview/dashboard_layout.html.erb +0 -9
- data/app/components/solidstats/previews/summary_card_component_preview/statuses.html.erb +0 -6
- data/app/components/solidstats/previews/summary_card_component_preview/value_formats.html.erb +0 -6
- data/app/components/solidstats/previews/summary_card_component_preview.rb +0 -67
- data/app/components/solidstats/quick_navigation_component.html.erb +0 -8
- data/app/components/solidstats/quick_navigation_component.rb +0 -21
- data/app/components/solidstats/security/gem_impact_analysis_component.html.erb +0 -44
- data/app/components/solidstats/security/gem_impact_analysis_component.rb +0 -45
- data/app/components/solidstats/security/overview_component.html.erb +0 -21
- data/app/components/solidstats/security/overview_component.rb +0 -104
- data/app/components/solidstats/security/section_component.html.erb +0 -26
- data/app/components/solidstats/security/section_component.rb +0 -52
- data/app/components/solidstats/security/timeline_component.html.erb +0 -39
- data/app/components/solidstats/security/timeline_component.rb +0 -43
- data/app/components/solidstats/tasks_section_component.html.erb +0 -17
- data/app/components/solidstats/tasks_section_component.rb +0 -22
- data/app/components/solidstats/ui/action_button_component.html.erb +0 -6
- data/app/components/solidstats/ui/action_button_component.rb +0 -71
- data/app/components/solidstats/ui/dashboard_layout_component.html.erb +0 -19
- data/app/components/solidstats/ui/dashboard_layout_component.rb +0 -85
- data/app/components/solidstats/ui/navigation_component.html.erb +0 -34
- data/app/components/solidstats/ui/navigation_component.rb +0 -72
- data/app/components/solidstats/ui/stats_overview_component.html.erb +0 -14
- data/app/components/solidstats/ui/stats_overview_component.rb +0 -78
- data/app/components/solidstats/ui/status_badge_component.html.erb +0 -6
- data/app/components/solidstats/ui/status_badge_component.rb +0 -42
- data/app/components/solidstats/ui/summary_card_component.html.erb +0 -12
- data/app/components/solidstats/ui/summary_card_component.rb +0 -63
- data/app/components/solidstats/ui/tab_navigation_component.html.erb +0 -22
- data/app/components/solidstats/ui/tab_navigation_component.rb +0 -79
- data/app/services/solidstats/audit_service.rb +0 -56
- data/app/services/solidstats/data_collector_service.rb +0 -83
- data/app/services/solidstats/gem_metadata/fetcher_service.rb +0 -136
- data/app/services/solidstats/todo_service.rb +0 -114
- data/app/views/solidstats/dashboard/_log_monitor.html.erb +0 -759
- data/app/views/solidstats/dashboard/_todos.html.erb +0 -151
- data/app/views/solidstats/dashboard/audit/_additional_styles.css +0 -22
- data/app/views/solidstats/dashboard/audit/_audit_badge.html.erb +0 -5
- data/app/views/solidstats/dashboard/audit/_audit_details.html.erb +0 -495
- data/app/views/solidstats/dashboard/audit/_audit_summary.html.erb +0 -26
- data/app/views/solidstats/dashboard/audit/_no_vulnerabilities.html.erb +0 -3
- data/app/views/solidstats/dashboard/audit/_security_audit.html.erb +0 -14
- data/app/views/solidstats/dashboard/audit/_vulnerabilities_table.html.erb +0 -1120
- data/app/views/solidstats/dashboard/audit/_vulnerability_details.html.erb +0 -63
- data/app/views/solidstats/dashboard/index.html.erb +0 -81
- data/app/views/solidstats/gem_metadata/_panel.html.erb +0 -419
- data/lib/generators/solidstats/feature/feature_generator.rb +0 -170
- data/lib/generators/solidstats/feature/templates/component.html.erb +0 -84
- data/lib/generators/solidstats/feature/templates/component.rb.erb +0 -103
- data/lib/generators/solidstats/feature/templates/component.scss +0 -243
- data/lib/generators/solidstats/feature/templates/component_test.rb.erb +0 -183
- data/lib/generators/solidstats/feature/templates/controller.rb.erb +0 -44
- data/lib/generators/solidstats/feature/templates/controller_test.rb.erb +0 -111
- data/lib/generators/solidstats/feature/templates/detail_view.html.erb +0 -755
- data/lib/generators/solidstats/feature/templates/preview.rb.erb +0 -107
- data/lib/generators/solidstats/feature/templates/service.rb.erb +0 -132
- data/lib/generators/solidstats/feature/templates/service_test.rb.erb +0 -109
- data/lib/generators/solidstats/install_generator.rb +0 -109
- data/lib/tasks/solidstats_install.rake +0 -133
@@ -1,107 +0,0 @@
|
|
1
|
-
module Solidstats
|
2
|
-
module Previews
|
3
|
-
class <%= class_name %>ComponentPreview < ViewComponent::Preview
|
4
|
-
# Preview for dashboard summary component
|
5
|
-
# @label Summary View
|
6
|
-
def default
|
7
|
-
render Solidstats::<%= class_name %>Component.new(
|
8
|
-
data: sample_data
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Preview with warning status
|
13
|
-
# @label Warning State
|
14
|
-
def warning_state
|
15
|
-
render Solidstats::<%= class_name %>Component.new(
|
16
|
-
data: sample_data.merge(
|
17
|
-
status: :warning,
|
18
|
-
value: 75
|
19
|
-
)
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Preview with danger status
|
24
|
-
# @label Danger State
|
25
|
-
def danger_state
|
26
|
-
render Solidstats::<%= class_name %>Component.new(
|
27
|
-
data: sample_data.merge(
|
28
|
-
status: :danger,
|
29
|
-
value: 150
|
30
|
-
)
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Preview with error state
|
35
|
-
# @label Error State
|
36
|
-
def error_state
|
37
|
-
render Solidstats::<%= class_name %>Component.new(
|
38
|
-
data: {
|
39
|
-
value: 0,
|
40
|
-
count: 0,
|
41
|
-
items: [],
|
42
|
-
status: :error,
|
43
|
-
error: "Unable to collect data",
|
44
|
-
last_updated: 2.hours.ago
|
45
|
-
}
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Preview with no data
|
50
|
-
# @label Empty State
|
51
|
-
def empty_state
|
52
|
-
render Solidstats::<%= class_name %>Component.new(
|
53
|
-
data: {
|
54
|
-
value: 0,
|
55
|
-
count: 0,
|
56
|
-
items: [],
|
57
|
-
status: :ok,
|
58
|
-
last_updated: Time.current
|
59
|
-
}
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def sample_data
|
66
|
-
{
|
67
|
-
value: 42,
|
68
|
-
count: 8,
|
69
|
-
status: :ok,
|
70
|
-
last_updated: 30.minutes.ago,
|
71
|
-
items: [
|
72
|
-
{
|
73
|
-
name: "Sample Item 1",
|
74
|
-
value: 15,
|
75
|
-
category: "important",
|
76
|
-
description: "This is a sample item for preview"
|
77
|
-
},
|
78
|
-
{
|
79
|
-
name: "Sample Item 2",
|
80
|
-
value: 8,
|
81
|
-
category: "normal",
|
82
|
-
description: "Another sample item"
|
83
|
-
},
|
84
|
-
{
|
85
|
-
name: "Sample Item 3",
|
86
|
-
value: 12,
|
87
|
-
category: "important",
|
88
|
-
description: "Third sample item"
|
89
|
-
},
|
90
|
-
{
|
91
|
-
name: "Sample Item 4",
|
92
|
-
value: 3,
|
93
|
-
category: "low",
|
94
|
-
description: "Fourth sample item"
|
95
|
-
},
|
96
|
-
{
|
97
|
-
name: "Sample Item 5",
|
98
|
-
value: 7,
|
99
|
-
category: "normal",
|
100
|
-
description: "Fifth sample item"
|
101
|
-
}
|
102
|
-
]
|
103
|
-
}
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
module Solidstats
|
2
|
-
class <%= class_name %>Service
|
3
|
-
CACHE_KEY = "solidstats_<%= file_name %>".freeze
|
4
|
-
CACHE_HOURS = <%= options[:cache_hours] %>
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@cache_file = Rails.root.join("tmp", "#{CACHE_KEY}.json")
|
8
|
-
end
|
9
|
-
|
10
|
-
# Fetch cached data or collect fresh data
|
11
|
-
def fetch(force_refresh = false)
|
12
|
-
if force_refresh || cache_expired?
|
13
|
-
data = collect_data
|
14
|
-
cache_data(data)
|
15
|
-
data
|
16
|
-
else
|
17
|
-
cached_data
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Get summary data for dashboard cards
|
22
|
-
def summary
|
23
|
-
data = fetch
|
24
|
-
{
|
25
|
-
value: calculate_summary_value(data),
|
26
|
-
status: determine_status(data),
|
27
|
-
last_updated: data[:last_updated] || Time.current,
|
28
|
-
count: data[:count] || 0
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
# Collect detailed data for full view
|
33
|
-
def detailed_data
|
34
|
-
fetch.merge(
|
35
|
-
breakdown: calculate_breakdown(fetch),
|
36
|
-
trends: calculate_trends(fetch)
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def collect_data
|
43
|
-
# TODO: Implement your data collection logic here
|
44
|
-
# This is where you'd gather metrics, run system commands,
|
45
|
-
# analyze files, or call external APIs
|
46
|
-
|
47
|
-
{
|
48
|
-
value: sample_value,
|
49
|
-
count: sample_count,
|
50
|
-
items: sample_items,
|
51
|
-
last_updated: Time.current,
|
52
|
-
status: :ok
|
53
|
-
}
|
54
|
-
rescue StandardError => e
|
55
|
-
Rails.logger.error "Error collecting <%= file_name %> data: #{e.message}"
|
56
|
-
{
|
57
|
-
value: 0,
|
58
|
-
count: 0,
|
59
|
-
items: [],
|
60
|
-
last_updated: Time.current,
|
61
|
-
status: :error,
|
62
|
-
error: e.message
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
def calculate_summary_value(data)
|
67
|
-
# TODO: Customize how the main metric is calculated
|
68
|
-
data[:value] || 0
|
69
|
-
end
|
70
|
-
|
71
|
-
def determine_status(data)
|
72
|
-
# TODO: Implement your status logic
|
73
|
-
# Return :ok, :warning, or :danger based on your metrics
|
74
|
-
|
75
|
-
return :error if data[:error]
|
76
|
-
return :ok if data[:value].to_i < 50
|
77
|
-
return :warning if data[:value].to_i < 100
|
78
|
-
:danger
|
79
|
-
end
|
80
|
-
|
81
|
-
def calculate_breakdown(data)
|
82
|
-
# TODO: Implement breakdown analysis for detailed view
|
83
|
-
data[:items]&.group_by { |item| item[:category] } || {}
|
84
|
-
end
|
85
|
-
|
86
|
-
def calculate_trends(data)
|
87
|
-
# TODO: Implement trend analysis
|
88
|
-
# This could compare with historical data
|
89
|
-
[]
|
90
|
-
end
|
91
|
-
|
92
|
-
# Sample data methods - replace with your actual logic
|
93
|
-
def sample_value
|
94
|
-
rand(1..100)
|
95
|
-
end
|
96
|
-
|
97
|
-
def sample_count
|
98
|
-
rand(1..20)
|
99
|
-
end
|
100
|
-
|
101
|
-
def sample_items
|
102
|
-
(1..sample_count).map do |i|
|
103
|
-
{
|
104
|
-
name: "Item #{i}",
|
105
|
-
value: rand(1..10),
|
106
|
-
category: ["category_a", "category_b", "category_c"].sample,
|
107
|
-
created_at: Time.current - rand(24).hours
|
108
|
-
}
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# Cache management
|
113
|
-
def cache_expired?
|
114
|
-
return true unless @cache_file.exist?
|
115
|
-
|
116
|
-
File.mtime(@cache_file) < CACHE_HOURS.hours.ago
|
117
|
-
end
|
118
|
-
|
119
|
-
def cached_data
|
120
|
-
return {} unless @cache_file.exist?
|
121
|
-
|
122
|
-
JSON.parse(File.read(@cache_file)).deep_symbolize_keys
|
123
|
-
rescue JSON::ParserError
|
124
|
-
{}
|
125
|
-
end
|
126
|
-
|
127
|
-
def cache_data(data)
|
128
|
-
FileUtils.mkdir_p(@cache_file.dirname)
|
129
|
-
File.write(@cache_file, data.to_json)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module Solidstats
|
4
|
-
class <%= class_name %>ServiceTest < ActiveSupport::TestCase
|
5
|
-
def setup
|
6
|
-
@service = <%= class_name %>Service.new
|
7
|
-
end
|
8
|
-
|
9
|
-
test "should initialize properly" do
|
10
|
-
assert_not_nil @service
|
11
|
-
end
|
12
|
-
|
13
|
-
test "should fetch data without errors" do
|
14
|
-
data = @service.fetch
|
15
|
-
|
16
|
-
assert_not_nil data
|
17
|
-
assert_kind_of Hash, data
|
18
|
-
assert data.key?(:value)
|
19
|
-
assert data.key?(:count)
|
20
|
-
assert data.key?(:items)
|
21
|
-
assert data.key?(:last_updated)
|
22
|
-
assert data.key?(:status)
|
23
|
-
end
|
24
|
-
|
25
|
-
test "should return summary data" do
|
26
|
-
summary = @service.summary
|
27
|
-
|
28
|
-
assert_not_nil summary
|
29
|
-
assert_kind_of Hash, summary
|
30
|
-
assert summary.key?(:value)
|
31
|
-
assert summary.key?(:status)
|
32
|
-
assert summary.key?(:last_updated)
|
33
|
-
assert summary.key?(:count)
|
34
|
-
end
|
35
|
-
|
36
|
-
test "should return detailed data" do
|
37
|
-
detailed = @service.detailed_data
|
38
|
-
|
39
|
-
assert_not_nil detailed
|
40
|
-
assert_kind_of Hash, detailed
|
41
|
-
assert detailed.key?(:value)
|
42
|
-
assert detailed.key?(:items)
|
43
|
-
assert detailed.key?(:breakdown)
|
44
|
-
assert detailed.key?(:trends)
|
45
|
-
end
|
46
|
-
|
47
|
-
test "should handle force refresh" do
|
48
|
-
# Test that force refresh bypasses cache
|
49
|
-
data1 = @service.fetch(false)
|
50
|
-
data2 = @service.fetch(true)
|
51
|
-
|
52
|
-
assert_not_nil data1
|
53
|
-
assert_not_nil data2
|
54
|
-
assert_kind_of Hash, data1
|
55
|
-
assert_kind_of Hash, data2
|
56
|
-
end
|
57
|
-
|
58
|
-
test "should determine status correctly" do
|
59
|
-
summary = @service.summary
|
60
|
-
|
61
|
-
assert_includes [:ok, :warning, :danger, :error], summary[:status]
|
62
|
-
end
|
63
|
-
|
64
|
-
test "should handle errors gracefully" do
|
65
|
-
# Mock an error condition
|
66
|
-
@service.stub(:collect_data, -> { raise StandardError.new("Test error") }) do
|
67
|
-
data = @service.fetch
|
68
|
-
|
69
|
-
assert_equal :error, data[:status]
|
70
|
-
assert_equal "Test error", data[:error]
|
71
|
-
assert_equal 0, data[:value]
|
72
|
-
assert_equal 0, data[:count]
|
73
|
-
assert_empty data[:items]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
test "should cache data properly" do
|
78
|
-
# Test caching behavior
|
79
|
-
first_fetch = @service.fetch
|
80
|
-
|
81
|
-
# Mock cache file existence
|
82
|
-
cache_file = @service.instance_variable_get(:@cache_file)
|
83
|
-
assert_not_nil cache_file
|
84
|
-
|
85
|
-
# Subsequent fetch should use cache if not expired
|
86
|
-
second_fetch = @service.fetch
|
87
|
-
assert_equal first_fetch[:last_updated], second_fetch[:last_updated]
|
88
|
-
end
|
89
|
-
|
90
|
-
test "should validate data structure" do
|
91
|
-
data = @service.fetch
|
92
|
-
|
93
|
-
# Validate required fields
|
94
|
-
assert_respond_to data[:value], :to_i
|
95
|
-
assert_respond_to data[:count], :to_i
|
96
|
-
assert_kind_of Array, data[:items]
|
97
|
-
assert_kind_of Time, data[:last_updated]
|
98
|
-
|
99
|
-
# Validate items structure if present
|
100
|
-
if data[:items].any?
|
101
|
-
data[:items].each do |item|
|
102
|
-
assert_kind_of Hash, item
|
103
|
-
assert item.key?(:name)
|
104
|
-
assert item.key?(:value)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators/base"
|
4
|
-
|
5
|
-
module Solidstats
|
6
|
-
module Generators
|
7
|
-
class InstallGenerator < Rails::Generators::Base
|
8
|
-
desc "Install Solidstats in your Rails application"
|
9
|
-
|
10
|
-
source_root File.expand_path("templates", __dir__)
|
11
|
-
|
12
|
-
class_option :css_framework, type: :string, default: "none",
|
13
|
-
desc: "CSS framework integration (none, bootstrap, tailwind)"
|
14
|
-
class_option :skip_assets, type: :boolean, default: false,
|
15
|
-
desc: "Skip asset configuration"
|
16
|
-
class_option :skip_routes, type: :boolean, default: false,
|
17
|
-
desc: "Skip route mounting"
|
18
|
-
|
19
|
-
def check_environment
|
20
|
-
unless Rails.env.development?
|
21
|
-
say "ā ļø Warning: Solidstats is designed for development environments only.", :yellow
|
22
|
-
say "Current environment: #{Rails.env}", :yellow
|
23
|
-
|
24
|
-
unless yes? "Continue installation anyway? (y/n)"
|
25
|
-
say "Installation cancelled.", :red
|
26
|
-
exit 1
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def check_dependencies
|
32
|
-
say "š Checking dependencies...", :green
|
33
|
-
|
34
|
-
# Check Rails version
|
35
|
-
rails_version = Rails::VERSION::STRING
|
36
|
-
if Gem::Version.new(rails_version) < Gem::Version.new("6.1.0")
|
37
|
-
say "ā Rails #{rails_version} is not supported. Minimum version: 6.1.0", :red
|
38
|
-
exit 1
|
39
|
-
end
|
40
|
-
say "ā
Rails #{rails_version} supported", :green
|
41
|
-
|
42
|
-
# Check ViewComponent
|
43
|
-
begin
|
44
|
-
require "view_component"
|
45
|
-
say "ā
ViewComponent #{ViewComponent::VERSION} detected", :green
|
46
|
-
rescue LoadError
|
47
|
-
say "ā ViewComponent not found. Please add it to your Gemfile:", :red
|
48
|
-
say "gem 'view_component'", :yellow
|
49
|
-
exit 1
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def mount_engine
|
54
|
-
return if options[:skip_routes]
|
55
|
-
|
56
|
-
say "š¤ļø Mounting Solidstats engine...", :green
|
57
|
-
|
58
|
-
route_content = " mount Solidstats::Engine => '/solidstats' if Rails.env.development?"
|
59
|
-
|
60
|
-
if File.read("config/routes.rb").include?("Solidstats::Engine")
|
61
|
-
say "ā ļø Solidstats engine already mounted in routes.rb", :yellow
|
62
|
-
else
|
63
|
-
route route_content
|
64
|
-
say "ā
Engine mounted at /solidstats (development only)", :green
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def configure_assets
|
69
|
-
say "š¦ Configuring assets...", :green
|
70
|
-
|
71
|
-
say " ā
Using inline asset delivery (no configuration needed)", :blue
|
72
|
-
say " š Assets are automatically included via helper methods", :blue
|
73
|
-
|
74
|
-
say "ā
Asset configuration complete", :green
|
75
|
-
end
|
76
|
-
|
77
|
-
def create_initializer
|
78
|
-
say "āļø Creating initializer...", :green
|
79
|
-
|
80
|
-
template "initializer.rb", "config/initializers/solidstats.rb"
|
81
|
-
say "ā
Created config/initializers/solidstats.rb", :green
|
82
|
-
end
|
83
|
-
|
84
|
-
def show_installation_complete
|
85
|
-
say "\nš Solidstats installation complete!", :green
|
86
|
-
say "ā" * 50, :green
|
87
|
-
|
88
|
-
say "\nš Next steps:", :cyan
|
89
|
-
say "1. Start your Rails server: rails server", :white
|
90
|
-
say "2. Visit: http://localhost:3000/solidstats", :white
|
91
|
-
say "3. Customize settings in config/initializers/solidstats.rb", :white
|
92
|
-
|
93
|
-
say "\nš” Asset Delivery:", :cyan
|
94
|
-
say " ⢠CSS and JavaScript are automatically inlined", :white
|
95
|
-
say " ⢠No asset pipeline configuration needed", :white
|
96
|
-
say " ⢠Works with any Rails asset setup", :white
|
97
|
-
|
98
|
-
say "\nš Documentation: https://github.com/your-org/solidstats", :cyan
|
99
|
-
say "ā" * 50, :green
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def css_framework_integration_available?
|
105
|
-
%w[bootstrap tailwind].include?(options[:css_framework])
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
namespace :solidstats do
|
5
|
-
desc "Install Solidstats in the current Rails application"
|
6
|
-
task :install do
|
7
|
-
puts "š Installing Solidstats..."
|
8
|
-
|
9
|
-
# Check Rails environment
|
10
|
-
unless Rails.env.development?
|
11
|
-
puts "ā ļø Warning: Solidstats is designed for development environments."
|
12
|
-
puts "Current environment: #{Rails.env}"
|
13
|
-
end
|
14
|
-
|
15
|
-
# Run the generator
|
16
|
-
if system("rails generate solidstats:install")
|
17
|
-
puts "\nā
Solidstats installation completed successfully!"
|
18
|
-
puts " Start your Rails server and visit http://localhost:3000/solidstats\n\n"
|
19
|
-
else
|
20
|
-
puts "\nā Solidstats installation failed. Please try running manually:"
|
21
|
-
puts " bundle exec rails generate solidstats:install\n\n"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "Validate Solidstats installation and configuration"
|
26
|
-
task validate: :environment do
|
27
|
-
puts "š Validating Solidstats installation..."
|
28
|
-
|
29
|
-
begin
|
30
|
-
# Check basic configuration
|
31
|
-
Solidstats.configuration
|
32
|
-
puts "ā
Configuration loaded"
|
33
|
-
|
34
|
-
# Check ViewComponent availability
|
35
|
-
if Solidstats.view_component_available?
|
36
|
-
version = defined?(ViewComponent::VERSION) ? ViewComponent::VERSION : "unknown"
|
37
|
-
puts "ā
ViewComponent available (#{version})"
|
38
|
-
else
|
39
|
-
puts "ā ViewComponent not available"
|
40
|
-
end
|
41
|
-
|
42
|
-
# Check asset strategy
|
43
|
-
strategy = Solidstats.asset_strategy
|
44
|
-
puts "ā
Asset strategy: #{strategy}"
|
45
|
-
|
46
|
-
# Validate asset manifest
|
47
|
-
Solidstats::AssetManifest.validate_assets!
|
48
|
-
puts "ā
All required assets present"
|
49
|
-
|
50
|
-
# Check routes
|
51
|
-
if Rails.application.routes.routes.any? { |r| r.path.spec.to_s.include?("solidstats") }
|
52
|
-
puts "ā
Routes mounted"
|
53
|
-
else
|
54
|
-
puts "ā ļø Routes not mounted - add 'mount Solidstats::Engine => \"/solidstats\"' to config/routes.rb"
|
55
|
-
end
|
56
|
-
|
57
|
-
puts "\nš Solidstats validation complete!"
|
58
|
-
|
59
|
-
rescue => e
|
60
|
-
puts "ā Validation failed: #{e.message}"
|
61
|
-
exit 1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc "Show asset configuration information"
|
66
|
-
task assets: :environment do
|
67
|
-
puts "š¦ Solidstats Asset Configuration"
|
68
|
-
puts "=" * 40
|
69
|
-
|
70
|
-
puts "Asset Strategy: #{Solidstats.asset_strategy}"
|
71
|
-
puts "Fingerprinting: #{Solidstats.asset_fingerprinting?}"
|
72
|
-
puts "Asset Prefix: #{Solidstats.asset_prefix}"
|
73
|
-
|
74
|
-
puts "\nPrecompiled Assets:"
|
75
|
-
Solidstats::AssetManifest.assets_for_environment.each do |asset|
|
76
|
-
puts " ⢠#{asset}"
|
77
|
-
end
|
78
|
-
|
79
|
-
if Rails.application.config.respond_to?(:assets)
|
80
|
-
puts "\nAsset Paths:"
|
81
|
-
Rails.application.config.assets.paths.select { |p| p.include?("solidstats") }.each do |path|
|
82
|
-
puts " ⢠#{path}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
desc "Test asset compilation"
|
88
|
-
task compile_assets: :environment do
|
89
|
-
puts "š§ Testing asset compilation..."
|
90
|
-
|
91
|
-
begin
|
92
|
-
test_assets = [ "solidstats/application.css", "solidstats/application.js" ]
|
93
|
-
|
94
|
-
if Rails.application.config.respond_to?(:assets)
|
95
|
-
manifest = Rails.application.assets
|
96
|
-
|
97
|
-
# Check if we're using Propshaft (Rails 7+) or Sprockets
|
98
|
-
if manifest.respond_to?(:find_asset)
|
99
|
-
# Sprockets
|
100
|
-
test_assets.each do |asset|
|
101
|
-
if manifest.find_asset(asset)
|
102
|
-
puts "ā
#{asset} - found and compilable (Sprockets)"
|
103
|
-
else
|
104
|
-
puts "ā #{asset} - not found (Sprockets)"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
elsif manifest.respond_to?(:load_path) && manifest.load_path.respond_to?(:find)
|
108
|
-
# Propshaft
|
109
|
-
test_assets.each do |asset|
|
110
|
-
if manifest.load_path.find(asset)
|
111
|
-
puts "ā
#{asset} - found and compilable (Propshaft)"
|
112
|
-
else
|
113
|
-
puts "ā #{asset} - not found (Propshaft)"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
else
|
117
|
-
# Unknown asset pipeline
|
118
|
-
puts "ā ļø Unknown asset pipeline type: #{manifest.class}"
|
119
|
-
puts "Available methods: #{manifest.methods.grep(/find/).join(', ')}"
|
120
|
-
end
|
121
|
-
else
|
122
|
-
puts "ā ļø No asset pipeline detected"
|
123
|
-
end
|
124
|
-
|
125
|
-
puts "ā
Asset compilation test complete"
|
126
|
-
|
127
|
-
rescue => e
|
128
|
-
puts "ā Asset compilation failed: #{e.message}"
|
129
|
-
puts "Asset pipeline class: #{Rails.application.assets.class}" if Rails.application.respond_to?(:assets)
|
130
|
-
exit 1
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|