stimulus_reflex 3.5.0.rc4 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -13
- data/app/assets/javascripts/stimulus_reflex.js +1 -1
- data/app/assets/javascripts/stimulus_reflex.umd.js +1 -1
- data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +2 -2
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +1 -1
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +1 -1
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +1 -1
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +1 -1
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +1 -1
- data/lib/install/action_cable.rb +30 -30
- data/lib/install/broadcaster.rb +11 -11
- data/lib/install/bundle.rb +9 -9
- data/lib/install/compression.rb +5 -5
- data/lib/install/config.rb +22 -22
- data/lib/install/development.rb +19 -19
- data/lib/install/esbuild.rb +28 -28
- data/lib/install/example.rb +3 -3
- data/lib/install/importmap.rb +29 -29
- data/lib/install/initializers.rb +3 -3
- data/lib/install/mrujs.rb +25 -25
- data/lib/install/npm_packages.rb +7 -7
- data/lib/install/reflexes.rb +2 -2
- data/lib/install/shakapacker.rb +23 -23
- data/lib/install/spring.rb +7 -7
- data/lib/install/updatable.rb +7 -7
- data/lib/install/vite.rb +22 -22
- data/lib/install/webpacker.rb +27 -27
- data/lib/install/yarn.rb +9 -9
- data/lib/stimulus_reflex/html/document_fragment.rb +5 -3
- data/lib/stimulus_reflex/installer.rb +303 -277
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/stimulus_reflex.rb +2 -0
- data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +8 -8
- data/package.json +1 -1
- data/stimulus_reflex.gemspec +2 -0
- data/yarn.lock +7 -7
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b03ea1fc12e4b3f3367a8f8c1daa82d03d198604afb21cd625489ea15b5509b2
|
4
|
+
data.tar.gz: daf235d6803af70cc1ddbc5616e9b5c4bdf8eceb4b610a7fc124eabb4e1a5b1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53cd791b9e756070eba8022fc360e6a05e268f75e5ff8f2d89d2627132a249ff3dc17ee602e706ff10110ae1b57241189cc97678fab2cd6c92af2372ddd20030
|
7
|
+
data.tar.gz: 5030553b6416e07ac2c4f6c6798d296333a85fda27e9d43503d28b821fa665f35f2ee4436cee7b259efcc56104752024161d94887d046e8503deaff3c8d83651
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stimulus_reflex (3.5.0
|
4
|
+
stimulus_reflex (3.5.0)
|
5
5
|
actioncable (>= 5.2, < 8)
|
6
6
|
actionpack (>= 5.2, < 8)
|
7
7
|
actionview (>= 5.2, < 8)
|
8
8
|
activesupport (>= 5.2, < 8)
|
9
9
|
cable_ready (~> 5.0)
|
10
10
|
nokogiri (~> 1.0)
|
11
|
+
nokogiri-html5-inference (~> 0.3)
|
11
12
|
rack (>= 2, < 4)
|
12
13
|
railties (>= 5.2, < 8)
|
13
14
|
redis (>= 4.0, < 6.0)
|
@@ -82,24 +83,25 @@ GEM
|
|
82
83
|
tzinfo (~> 2.0)
|
83
84
|
ast (2.4.2)
|
84
85
|
builder (3.2.4)
|
85
|
-
cable_ready (5.0.
|
86
|
+
cable_ready (5.0.4)
|
86
87
|
actionpack (>= 5.2)
|
87
88
|
actionview (>= 5.2)
|
88
89
|
activesupport (>= 5.2)
|
90
|
+
observer (~> 0.1)
|
89
91
|
railties (>= 5.2)
|
90
92
|
thread-local (>= 1.1.0)
|
91
|
-
concurrent-ruby (1.2.
|
93
|
+
concurrent-ruby (1.2.3)
|
92
94
|
connection_pool (2.4.0)
|
93
95
|
crass (1.0.6)
|
94
96
|
date (3.3.3)
|
95
97
|
erubi (1.12.0)
|
96
98
|
globalid (1.1.0)
|
97
99
|
activesupport (>= 5.0)
|
98
|
-
i18n (1.14.
|
100
|
+
i18n (1.14.5)
|
99
101
|
concurrent-ruby (~> 1.0)
|
100
102
|
json (2.6.3)
|
101
103
|
language_server-protocol (3.17.0.3)
|
102
|
-
loofah (2.
|
104
|
+
loofah (2.22.0)
|
103
105
|
crass (~> 1.0.2)
|
104
106
|
nokogiri (>= 1.12.0)
|
105
107
|
magic_frozen_string_literal (1.2.0)
|
@@ -109,7 +111,7 @@ GEM
|
|
109
111
|
net-pop
|
110
112
|
net-smtp
|
111
113
|
marcel (1.0.2)
|
112
|
-
method_source (1.
|
114
|
+
method_source (1.1.0)
|
113
115
|
mini_mime (1.1.2)
|
114
116
|
minitest (5.18.1)
|
115
117
|
mocha (1.13.0)
|
@@ -123,15 +125,18 @@ GEM
|
|
123
125
|
net-smtp (0.3.3)
|
124
126
|
net-protocol
|
125
127
|
nio4r (2.5.8)
|
126
|
-
nokogiri (1.16.
|
128
|
+
nokogiri (1.16.4-x86_64-darwin)
|
127
129
|
racc (~> 1.4)
|
128
|
-
nokogiri (1.16.
|
130
|
+
nokogiri (1.16.4-x86_64-linux)
|
129
131
|
racc (~> 1.4)
|
132
|
+
nokogiri-html5-inference (0.3.0)
|
133
|
+
nokogiri (~> 1.14)
|
134
|
+
observer (0.1.2)
|
130
135
|
parallel (1.22.1)
|
131
136
|
parser (3.2.1.0)
|
132
137
|
ast (~> 2.4.1)
|
133
138
|
racc (1.7.3)
|
134
|
-
rack (2.2.
|
139
|
+
rack (2.2.9)
|
135
140
|
rack-test (2.1.0)
|
136
141
|
rack (>= 1.3)
|
137
142
|
rails (7.0.4.2)
|
@@ -148,7 +153,7 @@ GEM
|
|
148
153
|
activesupport (= 7.0.4.2)
|
149
154
|
bundler (>= 1.15.0)
|
150
155
|
railties (= 7.0.4.2)
|
151
|
-
rails-dom-testing (2.
|
156
|
+
rails-dom-testing (2.2.0)
|
152
157
|
activesupport (>= 5.0.0)
|
153
158
|
minitest
|
154
159
|
nokogiri (>= 1.6)
|
@@ -163,7 +168,7 @@ GEM
|
|
163
168
|
thor (~> 1.0)
|
164
169
|
zeitwerk (~> 2.5)
|
165
170
|
rainbow (3.1.1)
|
166
|
-
rake (13.
|
171
|
+
rake (13.2.1)
|
167
172
|
redis (5.0.6)
|
168
173
|
redis-client (>= 0.9.0)
|
169
174
|
redis-client (0.14.0)
|
@@ -190,7 +195,7 @@ GEM
|
|
190
195
|
language_server-protocol (~> 3.17.0.2)
|
191
196
|
rubocop (= 1.44.1)
|
192
197
|
rubocop-performance (= 1.15.2)
|
193
|
-
thor (1.
|
198
|
+
thor (1.3.1)
|
194
199
|
thread-local (1.1.0)
|
195
200
|
timeout (0.3.2)
|
196
201
|
tzinfo (2.0.6)
|
@@ -199,7 +204,7 @@ GEM
|
|
199
204
|
websocket-driver (0.7.5)
|
200
205
|
websocket-extensions (>= 0.1.0)
|
201
206
|
websocket-extensions (0.1.5)
|
202
|
-
zeitwerk (2.6.
|
207
|
+
zeitwerk (2.6.13)
|
203
208
|
|
204
209
|
PLATFORMS
|
205
210
|
x86_64-darwin-19
|
@@ -210,6 +215,7 @@ PLATFORMS
|
|
210
215
|
DEPENDENCIES
|
211
216
|
bundler (~> 2.0)
|
212
217
|
magic_frozen_string_literal (~> 1.2)
|
218
|
+
minitest (= 5.18.1)
|
213
219
|
mocha (~> 1.13)
|
214
220
|
rails (>= 5.2, < 8)
|
215
221
|
rake (~> 13.0)
|
@@ -20,13 +20,13 @@ class StimulusReflexGenerator < Rails::Generators::NamedBase
|
|
20
20
|
|
21
21
|
template(reflex_src, reflex_path) unless options[:skip_reflex]
|
22
22
|
|
23
|
-
if !options[:skip_stimulus] && entrypoint.blank?
|
23
|
+
if !options[:skip_stimulus] && StimulusReflex::Installer.entrypoint.blank?
|
24
24
|
puts "❌ You must specify a valid JavaScript entrypoint."
|
25
25
|
exit
|
26
26
|
end
|
27
27
|
|
28
28
|
stimulus_controller_src = "app/javascript/controllers/%file_name%_controller.js.tt"
|
29
|
-
stimulus_controller_path = Rails.root.join(entrypoint, "controllers/#{file_name}_controller.js")
|
29
|
+
stimulus_controller_path = Rails.root.join(StimulusReflex::Installer.entrypoint, "controllers/#{file_name}_controller.js")
|
30
30
|
|
31
31
|
template(stimulus_controller_src, stimulus_controller_path) unless options[:skip_stimulus]
|
32
32
|
|
data/lib/install/action_cable.rb
CHANGED
@@ -6,11 +6,11 @@ require "stimulus_reflex/installer"
|
|
6
6
|
if defined?(ActionCable::Engine)
|
7
7
|
say "⏩ ActionCable::Engine is already loaded and in scope. Skipping"
|
8
8
|
else
|
9
|
-
halt "ActionCable::Engine is not loaded, please add or uncomment `require \"action_cable/engine\"` to your `config/application.rb`"
|
9
|
+
StimulusReflex::Installer.halt "ActionCable::Engine is not loaded, please add or uncomment `require \"action_cable/engine\"` to your `config/application.rb`"
|
10
10
|
return
|
11
11
|
end
|
12
12
|
|
13
|
-
return if pack_path_missing?
|
13
|
+
return if StimulusReflex::Installer.pack_path_missing?
|
14
14
|
|
15
15
|
# verify that the Action Cable pubsub config is created
|
16
16
|
cable_config = Rails.root.join("config/cable.yml")
|
@@ -37,7 +37,7 @@ elsif yaml["development"]["adapter"] == "async"
|
|
37
37
|
"url" => "<%= ENV.fetch(\"REDIS_URL\") { \"redis://localhost:6379/1\" } %>",
|
38
38
|
"channel_prefix" => "#{app_name}_development"
|
39
39
|
}
|
40
|
-
backup(cable_config) do
|
40
|
+
StimulusReflex::Installer.backup(cable_config) do
|
41
41
|
cable_config.write(yaml.to_yaml)
|
42
42
|
end
|
43
43
|
say "✅ config/cable.yml was updated to use the redis adapter in development"
|
@@ -45,29 +45,29 @@ else
|
|
45
45
|
say "🤷 config/cable.yml should use the redis adapter - or something like it - in development. You have something else specified, and we trust that you know what you're doing."
|
46
46
|
end
|
47
47
|
|
48
|
-
if gemfile.match?(/gem ['"]redis['"]/)
|
48
|
+
if StimulusReflex::Installer.gemfile.match?(/gem ['"]redis['"]/)
|
49
49
|
say "⏩ redis gem is already present in Gemfile. Skipping."
|
50
50
|
elsif Rails::VERSION::MAJOR >= 7
|
51
|
-
add_gem "redis@~> 5"
|
51
|
+
StimulusReflex::Installer.add_gem "redis@~> 5"
|
52
52
|
else
|
53
|
-
add_gem "redis@~> 4"
|
53
|
+
StimulusReflex::Installer.add_gem "redis@~> 4"
|
54
54
|
end
|
55
55
|
|
56
56
|
# install action-cable-redis-backport gem if using Action Cable < 7.1
|
57
57
|
unless ActionCable::VERSION::MAJOR >= 7 && ActionCable::VERSION::MINOR >= 1
|
58
|
-
if gemfile.match?(/gem ['"]action-cable-redis-backport['"]/)
|
58
|
+
if StimulusReflex::Installer.gemfile.match?(/gem ['"]action-cable-redis-backport['"]/)
|
59
59
|
say "⏩ action-cable-redis-backport gem is already present in Gemfile. Skipping."
|
60
60
|
else
|
61
|
-
add_gem "action-cable-redis-backport@~> 1"
|
61
|
+
StimulusReflex::Installer.add_gem "action-cable-redis-backport@~> 1"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
# verify that the Action Cable channels folder and consumer class is available
|
66
66
|
step_path = "/app/javascript/channels/"
|
67
|
-
channels_path = Rails.root.join(entrypoint, "channels")
|
68
|
-
consumer_src = fetch(step_path, "consumer.js.tt")
|
67
|
+
channels_path = Rails.root.join(StimulusReflex::Installer.entrypoint, "channels")
|
68
|
+
consumer_src = StimulusReflex::Installer.fetch(step_path, "consumer.js.tt")
|
69
69
|
consumer_path = channels_path / "consumer.js"
|
70
|
-
index_src = fetch(step_path, "index.js.#{bundler}.tt")
|
70
|
+
index_src = StimulusReflex::Installer.fetch(step_path, "index.js.#{StimulusReflex::Installer.bundler}.tt")
|
71
71
|
index_path = channels_path / "index.js"
|
72
72
|
friendly_index_path = index_path.relative_path_from(Rails.root).to_s
|
73
73
|
|
@@ -79,7 +79,7 @@ if index_path.exist?
|
|
79
79
|
if index_path.read == index_src.read
|
80
80
|
say "⏩ #{friendly_index_path} is already present. Skipping."
|
81
81
|
else
|
82
|
-
backup(index_path) do
|
82
|
+
StimulusReflex::Installer.backup(index_path) do
|
83
83
|
copy_file(index_src, index_path, verbose: false)
|
84
84
|
end
|
85
85
|
say "✅ #{friendly_index_path} has been updated"
|
@@ -92,45 +92,45 @@ end
|
|
92
92
|
# import Action Cable channels into application pack
|
93
93
|
channels_pattern = /import ['"](\.\.\/|\.\/)?channels['"]/
|
94
94
|
channels_commented_pattern = /\s*\/\/\s*#{channels_pattern}/
|
95
|
-
channel_import = "import \"#{prefix}channels\"\n"
|
95
|
+
channel_import = "import \"#{StimulusReflex::Installer.prefix}channels\"\n"
|
96
96
|
|
97
|
-
if pack.match?(channels_pattern)
|
98
|
-
if pack.match?(channels_commented_pattern)
|
99
|
-
proceed = if options.key? "uncomment"
|
100
|
-
options["uncomment"]
|
97
|
+
if StimulusReflex::Installer.pack.match?(channels_pattern)
|
98
|
+
if StimulusReflex::Installer.pack.match?(channels_commented_pattern)
|
99
|
+
proceed = if StimulusReflex::Installer.options.key? "uncomment"
|
100
|
+
StimulusReflex::Installer.options["uncomment"]
|
101
101
|
else
|
102
102
|
!no?("✨ Action Cable seems to be commented out in your application.js. Do you want to uncomment it? (Y/n)")
|
103
103
|
end
|
104
104
|
|
105
105
|
if proceed
|
106
106
|
# uncomment_lines only works with Ruby comments 🙄
|
107
|
-
lines = pack_path.readlines
|
107
|
+
lines = StimulusReflex::Installer.pack_path.readlines
|
108
108
|
matches = lines.select { |line| line =~ channels_commented_pattern }
|
109
109
|
lines[lines.index(matches.last).to_i] = channel_import
|
110
|
-
pack_path.write lines.join
|
111
|
-
say "✅ Uncommented channels import in #{friendly_pack_path}"
|
110
|
+
StimulusReflex::Installer.pack_path.write lines.join
|
111
|
+
say "✅ Uncommented channels import in #{StimulusReflex::Installer.friendly_pack_path}"
|
112
112
|
else
|
113
113
|
say "🤷 your Action Cable channels are not being imported in your application.js. We trust that you have a reason for this."
|
114
114
|
end
|
115
115
|
else
|
116
|
-
say "⏩ channels are already being imported in #{friendly_pack_path}. Skipping."
|
116
|
+
say "⏩ channels are already being imported in #{StimulusReflex::Installer.friendly_pack_path}. Skipping."
|
117
117
|
end
|
118
118
|
else
|
119
|
-
lines = pack_path.readlines
|
119
|
+
lines = StimulusReflex::Installer.pack_path.readlines
|
120
120
|
matches = lines.select { |line| line =~ /^import / }
|
121
121
|
lines.insert lines.index(matches.last).to_i + 1, channel_import
|
122
|
-
pack_path.write lines.join
|
123
|
-
say "✅ channels imported in #{friendly_pack_path}"
|
122
|
+
StimulusReflex::Installer.pack_path.write lines.join
|
123
|
+
say "✅ channels imported in #{StimulusReflex::Installer.friendly_pack_path}"
|
124
124
|
end
|
125
125
|
|
126
126
|
# create working copy of Action Cable initializer in tmp
|
127
|
-
if action_cable_initializer_path.exist?
|
128
|
-
FileUtils.cp(action_cable_initializer_path, action_cable_initializer_working_path)
|
127
|
+
if StimulusReflex::Installer.action_cable_initializer_path.exist?
|
128
|
+
FileUtils.cp(StimulusReflex::Installer.action_cable_initializer_path, StimulusReflex::Installer.action_cable_initializer_working_path)
|
129
129
|
|
130
130
|
say "⏩ Action Cable initializer already exists. Skipping"
|
131
131
|
else
|
132
132
|
# create Action Cable initializer if it doesn't already exist
|
133
|
-
create_file(action_cable_initializer_working_path, verbose: false) do
|
133
|
+
create_file(StimulusReflex::Installer.action_cable_initializer_working_path, verbose: false) do
|
134
134
|
<<~RUBY
|
135
135
|
# frozen_string_literal: true
|
136
136
|
|
@@ -140,10 +140,10 @@ else
|
|
140
140
|
end
|
141
141
|
|
142
142
|
# silence notoriously chatty Action Cable logs
|
143
|
-
if action_cable_initializer_working_path.read.match?(/^[^#]*ActionCable.server.config.logger/)
|
143
|
+
if StimulusReflex::Installer.action_cable_initializer_working_path.read.match?(/^[^#]*ActionCable.server.config.logger/)
|
144
144
|
say "⏩ Action Cable logger is already being silenced. Skipping"
|
145
145
|
else
|
146
|
-
append_file(action_cable_initializer_working_path, verbose: false) do
|
146
|
+
append_file(StimulusReflex::Installer.action_cable_initializer_working_path, verbose: false) do
|
147
147
|
<<~RUBY
|
148
148
|
ActionCable.server.config.logger = Logger.new(nil)
|
149
149
|
|
@@ -152,4 +152,4 @@ else
|
|
152
152
|
say "✅ Action Cable logger silenced for performance and legibility"
|
153
153
|
end
|
154
154
|
|
155
|
-
complete_step :action_cable
|
155
|
+
StimulusReflex::Installer.complete_step :action_cable
|
data/lib/install/broadcaster.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
channel_path = Rails.root.join("app/channels/application_cable/channel.rb")
|
12
12
|
controller_path = Rails.root.join("app/controllers/application_controller.rb")
|
13
13
|
job_path = Rails.root.join("app/jobs/application_job.rb")
|
14
|
-
model_path = Rails.root.join(application_record_path)
|
14
|
+
model_path = Rails.root.join(StimulusReflex::Installer.application_record_path)
|
15
15
|
|
16
16
|
include_in_channel = needs_broadcaster?(channel_path)
|
17
17
|
include_in_controller = needs_broadcaster?(controller_path)
|
@@ -21,20 +21,20 @@ include_in_model = needs_broadcaster?(model_path)
|
|
21
21
|
proceed = [include_in_channel, include_in_controller, include_in_job, include_in_model].reduce(:|)
|
22
22
|
|
23
23
|
unless proceed
|
24
|
-
complete_step :broadcaster
|
24
|
+
StimulusReflex::Installer.complete_step :broadcaster
|
25
25
|
|
26
26
|
puts "⏩ CableReady::Broadcaster already included in all files. Skipping."
|
27
27
|
return
|
28
28
|
end
|
29
29
|
|
30
|
-
proceed = if options.key? "broadcaster"
|
31
|
-
options["broadcaster"]
|
30
|
+
proceed = if StimulusReflex::Installer.options.key? "broadcaster"
|
31
|
+
StimulusReflex::Installer.options["broadcaster"]
|
32
32
|
else
|
33
33
|
!no?("✨ Make CableReady::Broadcaster available to channels, controllers, jobs and models? (Y/n)")
|
34
34
|
end
|
35
35
|
|
36
36
|
unless proceed
|
37
|
-
complete_step :broadcaster
|
37
|
+
StimulusReflex::Installer.complete_step :broadcaster
|
38
38
|
|
39
39
|
puts "⏩ Skipping."
|
40
40
|
return
|
@@ -44,7 +44,7 @@ broadcaster_include = "\n include CableReady::Broadcaster\n"
|
|
44
44
|
|
45
45
|
# include CableReady::Broadcaster in Action Cable Channel classes
|
46
46
|
if include_in_channel
|
47
|
-
backup(channel_path) do
|
47
|
+
StimulusReflex::Installer.backup(channel_path) do
|
48
48
|
inject_into_file channel_path, broadcaster_include, after: /class (ApplicationCable::)?Channel < ActionCable::Channel::Base/, verbose: false
|
49
49
|
end
|
50
50
|
|
@@ -55,7 +55,7 @@ end
|
|
55
55
|
|
56
56
|
# include CableReady::Broadcaster in Action Controller classes
|
57
57
|
if include_in_controller
|
58
|
-
backup(controller_path) do
|
58
|
+
StimulusReflex::Installer.backup(controller_path) do
|
59
59
|
inject_into_class controller_path, "ApplicationController", broadcaster_include, verbose: false
|
60
60
|
end
|
61
61
|
|
@@ -67,7 +67,7 @@ end
|
|
67
67
|
# include CableReady::Broadcaster in Active Job classes, if present
|
68
68
|
|
69
69
|
if include_in_job
|
70
|
-
backup(job_path) do
|
70
|
+
StimulusReflex::Installer.backup(job_path) do
|
71
71
|
inject_into_class job_path, "ApplicationJob", broadcaster_include, verbose: false
|
72
72
|
end
|
73
73
|
|
@@ -78,8 +78,8 @@ end
|
|
78
78
|
|
79
79
|
# include CableReady::Broadcaster in Active Record model classes
|
80
80
|
if include_in_model
|
81
|
-
backup(application_record_path) do
|
82
|
-
inject_into_class application_record_path, "ApplicationRecord", broadcaster_include, verbose: false
|
81
|
+
StimulusReflex::Installer.backup(StimulusReflex::Installer.application_record_path) do
|
82
|
+
inject_into_class StimulusReflex::Installer.application_record_path, "ApplicationRecord", broadcaster_include, verbose: false
|
83
83
|
end
|
84
84
|
|
85
85
|
puts "✅ include CableReady::Broadcaster in ApplicationRecord"
|
@@ -87,4 +87,4 @@ else
|
|
87
87
|
puts "⏩ Not including CableReady::Broadcaster in ApplicationRecord. Skipping"
|
88
88
|
end
|
89
89
|
|
90
|
-
complete_step :broadcaster
|
90
|
+
StimulusReflex::Installer.complete_step :broadcaster
|
data/lib/install/bundle.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require "stimulus_reflex/installer"
|
4
4
|
|
5
|
-
hash = gemfile_hash
|
5
|
+
hash = StimulusReflex::Installer.gemfile_hash
|
6
6
|
|
7
7
|
# run bundle only when gems are waiting to be added or removed
|
8
|
-
add = add_gem_list.exist? ? add_gem_list.readlines.map(&:chomp) : []
|
9
|
-
remove = remove_gem_list.exist? ? remove_gem_list.readlines.map(&:chomp) : []
|
8
|
+
add = StimulusReflex::Installer.add_gem_list.exist? ? StimulusReflex::Installer.add_gem_list.readlines.map(&:chomp) : []
|
9
|
+
remove = StimulusReflex::Installer.remove_gem_list.exist? ? StimulusReflex::Installer.remove_gem_list.readlines.map(&:chomp) : []
|
10
10
|
|
11
11
|
if add.present? || remove.present?
|
12
|
-
lines = gemfile_path.readlines
|
12
|
+
lines = StimulusReflex::Installer.gemfile_path.readlines
|
13
13
|
|
14
14
|
remove.each do |name|
|
15
15
|
index = lines.index { |line| line =~ /gem ['"]#{name}['"]/ }
|
@@ -40,17 +40,17 @@ if add.present? || remove.present?
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
gemfile_path.write lines.join
|
43
|
+
StimulusReflex::Installer.gemfile_path.write lines.join
|
44
44
|
|
45
|
-
bundle_command("install --quiet", "BUNDLE_IGNORE_MESSAGES" => "1") if hash != gemfile_hash
|
45
|
+
bundle_command("install --quiet", "BUNDLE_IGNORE_MESSAGES" => "1") if hash != StimulusReflex::Installer.gemfile_hash
|
46
46
|
else
|
47
47
|
say "⏩ No rubygems depedencies to install. Skipping."
|
48
48
|
end
|
49
49
|
|
50
|
-
FileUtils.cp(development_working_path, development_path)
|
50
|
+
FileUtils.cp(StimulusReflex::Installer.development_working_path, StimulusReflex::Installer.development_path)
|
51
51
|
say "✅ development environment configuration installed"
|
52
52
|
|
53
|
-
FileUtils.cp(action_cable_initializer_working_path, action_cable_initializer_path)
|
53
|
+
FileUtils.cp(StimulusReflex::Installer.action_cable_initializer_working_path, StimulusReflex::Installer.action_cable_initializer_path)
|
54
54
|
say "✅ Action Cable initializer installed"
|
55
55
|
|
56
|
-
complete_step :bundle
|
56
|
+
StimulusReflex::Installer.complete_step :bundle
|
data/lib/install/compression.rb
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
require "stimulus_reflex/installer"
|
4
4
|
|
5
|
-
initializer = action_cable_initializer_working_path.read
|
5
|
+
initializer = StimulusReflex::Installer.action_cable_initializer_working_path.read
|
6
6
|
|
7
|
-
if gemfile.match?(/gem ['"]permessage_deflate['"]/)
|
7
|
+
if StimulusReflex::Installer.gemfile.match?(/gem ['"]permessage_deflate['"]/)
|
8
8
|
say "⏩ permessage_deflate already present in Gemfile. Skipping."
|
9
9
|
else
|
10
|
-
add_gem "permessage_deflate@>= 0.1"
|
10
|
+
StimulusReflex::Installer.add_gem "permessage_deflate@>= 0.1"
|
11
11
|
end
|
12
12
|
|
13
13
|
# add permessage_deflate config to Action Cable initializer
|
14
14
|
if initializer.exclude? "PermessageDeflate.configure"
|
15
|
-
create_or_append(action_cable_initializer_working_path, verbose: false) do
|
15
|
+
StimulusReflex::Installer.create_or_append(StimulusReflex::Installer.action_cable_initializer_working_path, verbose: false) do
|
16
16
|
<<~RUBY
|
17
17
|
module ActionCable
|
18
18
|
module Connection
|
@@ -38,4 +38,4 @@ else
|
|
38
38
|
say "⏩ Action Cable initializer is already patched to deflate websocket traffic. Skipping."
|
39
39
|
end
|
40
40
|
|
41
|
-
complete_step :compression
|
41
|
+
StimulusReflex::Installer.complete_step :compression
|
data/lib/install/config.rb
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
|
3
3
|
require "stimulus_reflex/installer"
|
4
4
|
|
5
|
-
return if pack_path_missing?
|
5
|
+
return if StimulusReflex::Installer.pack_path_missing?
|
6
6
|
|
7
7
|
step_path = "/app/javascript/config/"
|
8
|
-
index_src = fetch(step_path, "index.js.tt")
|
9
|
-
index_path = config_path / "index.js"
|
8
|
+
index_src = StimulusReflex::Installer.fetch(step_path, "index.js.tt")
|
9
|
+
index_path = StimulusReflex::Installer.config_path / "index.js"
|
10
10
|
friendly_index_path = index_path.relative_path_from(Rails.root).to_s
|
11
|
-
stimulus_reflex_src = fetch(step_path, "stimulus_reflex.js.tt")
|
12
|
-
stimulus_reflex_path = config_path / "stimulus_reflex.js"
|
11
|
+
stimulus_reflex_src = StimulusReflex::Installer.fetch(step_path, "stimulus_reflex.js.tt")
|
12
|
+
stimulus_reflex_path = StimulusReflex::Installer.config_path / "stimulus_reflex.js"
|
13
13
|
friendly_stimulus_reflex_path = stimulus_reflex_path.relative_path_from(Rails.root).to_s
|
14
|
-
cable_ready_src = fetch(step_path, "cable_ready.js.tt")
|
15
|
-
cable_ready_path = config_path / "cable_ready.js"
|
14
|
+
cable_ready_src = StimulusReflex::Installer.fetch(step_path, "cable_ready.js.tt")
|
15
|
+
cable_ready_path = StimulusReflex::Installer.config_path / "cable_ready.js"
|
16
16
|
|
17
|
-
empty_directory config_path unless config_path.exist?
|
17
|
+
empty_directory StimulusReflex::Installer.config_path unless StimulusReflex::Installer.config_path.exist?
|
18
18
|
|
19
19
|
if index_path.exist?
|
20
20
|
say "⏩ #{friendly_index_path} already exists. Skipping"
|
21
21
|
else
|
22
|
-
backup(index_path, delete: true) do
|
22
|
+
StimulusReflex::Installer.backup(index_path, delete: true) do
|
23
23
|
template(index_src, index_path)
|
24
24
|
end
|
25
25
|
say "✅ Created #{friendly_index_path}"
|
@@ -27,26 +27,26 @@ end
|
|
27
27
|
|
28
28
|
index_pattern = /import ['"](\.\.\/|\.\/)?config['"]/
|
29
29
|
index_commented_pattern = /\s*\/\/\s*#{index_pattern}/
|
30
|
-
index_import = "import \"#{prefix}config\"\n"
|
30
|
+
index_import = "import \"#{StimulusReflex::Installer.prefix}config\"\n"
|
31
31
|
|
32
|
-
if pack.match?(index_pattern)
|
33
|
-
if pack.match?(index_commented_pattern)
|
34
|
-
lines = pack_path.readlines
|
32
|
+
if StimulusReflex::Installer.pack.match?(index_pattern)
|
33
|
+
if StimulusReflex::Installer.pack.match?(index_commented_pattern)
|
34
|
+
lines = StimulusReflex::Installer.pack_path.readlines
|
35
35
|
matches = lines.select { |line| line =~ index_commented_pattern }
|
36
36
|
lines[lines.index(matches.last).to_i] = index_import
|
37
|
-
pack_path.write lines.join
|
37
|
+
StimulusReflex::Installer.pack_path.write lines.join
|
38
38
|
|
39
|
-
say "✅ Uncommented StimulusReflex and CableReady configs imports in #{friendly_pack_path}"
|
39
|
+
say "✅ Uncommented StimulusReflex and CableReady configs imports in #{StimulusReflex::Installer.friendly_pack_path}"
|
40
40
|
else
|
41
|
-
say "⏩ StimulusReflex and CableReady configs are already being imported in #{friendly_pack_path}. Skipping"
|
41
|
+
say "⏩ StimulusReflex and CableReady configs are already being imported in #{StimulusReflex::Installer.friendly_pack_path}. Skipping"
|
42
42
|
end
|
43
43
|
else
|
44
|
-
lines = pack_path.readlines
|
44
|
+
lines = StimulusReflex::Installer.pack_path.readlines
|
45
45
|
matches = lines.select { |line| line =~ /^import / }
|
46
46
|
lines.insert lines.index(matches.last).to_i + 1, index_import
|
47
|
-
pack_path.write lines.join
|
47
|
+
StimulusReflex::Installer.pack_path.write lines.join
|
48
48
|
|
49
|
-
say "✅ StimulusReflex and CableReady configs will be imported in #{friendly_pack_path}"
|
49
|
+
say "✅ StimulusReflex and CableReady configs will be imported in #{StimulusReflex::Installer.friendly_pack_path}"
|
50
50
|
end
|
51
51
|
|
52
52
|
# create entrypoint/config/cable_ready.js and make sure it's imported in application.js
|
@@ -58,14 +58,14 @@ template(stimulus_reflex_src, stimulus_reflex_path) unless stimulus_reflex_path.
|
|
58
58
|
if stimulus_reflex_path.read.include?("StimulusReflex.debug =")
|
59
59
|
say "⏩ Development environment options are already set in #{friendly_stimulus_reflex_path}. Skipping"
|
60
60
|
else
|
61
|
-
if bundler.webpacker? || bundler.shakapacker?
|
61
|
+
if StimulusReflex::Installer.bundler.webpacker? || StimulusReflex::Installer.bundler.shakapacker?
|
62
62
|
append_file(stimulus_reflex_path, <<~JS, verbose: false)
|
63
63
|
|
64
64
|
if (process.env.RAILS_ENV === 'development') {
|
65
65
|
StimulusReflex.debug = true
|
66
66
|
}
|
67
67
|
JS
|
68
|
-
elsif bundler.vite?
|
68
|
+
elsif StimulusReflex::Installer.bundler.vite?
|
69
69
|
append_file(stimulus_reflex_path, <<~JS, verbose: false) unless stimulus_reflex_path.read.include?("StimulusReflex.debug")
|
70
70
|
|
71
71
|
if (import.meta.env.MODE === "development") {
|
@@ -84,4 +84,4 @@ else
|
|
84
84
|
say "✅ Set useful development environment options in #{friendly_stimulus_reflex_path}"
|
85
85
|
end
|
86
86
|
|
87
|
-
complete_step :config
|
87
|
+
StimulusReflex::Installer.complete_step :config
|