stimulus_reflex 3.5.0.rc2 → 3.5.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +22 -18
  3. data/app/assets/javascripts/stimulus_reflex.js +8 -6
  4. data/app/assets/javascripts/stimulus_reflex.umd.js +8 -5
  5. data/app/channels/stimulus_reflex/channel.rb +49 -53
  6. data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +6 -18
  7. data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +6 -2
  8. data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +7 -2
  9. data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
  10. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +6 -2
  11. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +5 -1
  12. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +7 -1
  13. data/lib/install/config.rb +5 -5
  14. data/lib/install/esbuild.rb +1 -1
  15. data/lib/install/importmap.rb +2 -2
  16. data/lib/install/mrujs.rb +10 -5
  17. data/lib/install/npm_packages.rb +1 -1
  18. data/lib/install/shakapacker.rb +1 -1
  19. data/lib/install/vite.rb +1 -1
  20. data/lib/install/webpacker.rb +1 -1
  21. data/lib/install/yarn.rb +4 -4
  22. data/lib/stimulus_reflex/cable_readiness.rb +1 -7
  23. data/lib/stimulus_reflex/installer.rb +88 -7
  24. data/lib/stimulus_reflex/reflex.rb +14 -29
  25. data/lib/stimulus_reflex/reflex_data.rb +17 -17
  26. data/lib/stimulus_reflex/reflex_factory.rb +49 -26
  27. data/lib/stimulus_reflex/version.rb +1 -1
  28. data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +21 -52
  29. data/package.json +3 -3
  30. data/stimulus_reflex.gemspec +2 -2
  31. data/yarn.lock +518 -444
  32. metadata +10 -10
data/lib/install/yarn.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "stimulus_reflex/installer"
4
4
 
5
- if !package_json.exist?
5
+ if !package_json_path.exist?
6
6
  say "⏩ No package.json file found. Skipping."
7
7
 
8
8
  return
@@ -13,7 +13,7 @@ add = package_list.exist? ? package_list.readlines.map(&:chomp) : []
13
13
  dev = dev_package_list.exist? ? dev_package_list.readlines.map(&:chomp) : []
14
14
  drop = drop_package_list.exist? ? drop_package_list.readlines.map(&:chomp) : []
15
15
 
16
- json = JSON.parse(package_json.read)
16
+ json = JSON.parse(package_json_path.read)
17
17
 
18
18
  if add.present? || dev.present? || drop.present?
19
19
 
@@ -36,7 +36,7 @@ if add.present? || dev.present? || drop.present?
36
36
  json["devDependencies"].delete(package)
37
37
  end
38
38
 
39
- package_json.write JSON.pretty_generate(json)
39
+ package_json_path.write JSON.pretty_generate(json)
40
40
 
41
41
  system "yarn install --silent"
42
42
  else
@@ -46,7 +46,7 @@ end
46
46
  if bundler == "esbuild" && json["scripts"]["build"] != "node esbuild.config.mjs"
47
47
  json["scripts"]["build:default"] = json["scripts"]["build"]
48
48
  json["scripts"]["build"] = "node esbuild.config.mjs"
49
- package_json.write JSON.pretty_generate(json)
49
+ package_json_path.write JSON.pretty_generate(json)
50
50
  say "✅ Your yarn build script has been updated to use esbuild.config.mjs"
51
51
  else
52
52
  say "⏩ Your yarn build script is already setup. Skipping."
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/concern"
4
-
5
3
  module StimulusReflex
6
4
  module CableReadiness
7
- extend ActiveSupport::Concern
8
-
9
- prepended do
10
- attr_reader :cable_ready
11
- end
5
+ attr_reader :cable_ready
12
6
 
13
7
  def initialize(*args, **kwargs)
14
8
  super(*args, **kwargs)
@@ -101,24 +101,105 @@ def cr_npm_version
101
101
  @cr_npm_version ||= CableReady::VERSION.gsub(".pre", "-pre").gsub(".rc", "-rc")
102
102
  end
103
103
 
104
- def package_json
105
- @package_json ||= Rails.root.join("package.json")
104
+ def package_json_path
105
+ @package_json_path ||= Rails.root.join("package.json")
106
+ end
107
+
108
+ def installer_entrypoint_path
109
+ create_dir_for_file_if_not_exists("tmp/stimulus_reflex_installer/entrypoint")
106
110
  end
107
111
 
108
112
  def entrypoint
109
- @entrypoint ||= File.read("tmp/stimulus_reflex_installer/entrypoint")
113
+ path = installer_entrypoint_path
114
+ @entrypoint ||= File.exist?(path) ? File.read(path) : auto_detect_entrypoint
115
+ end
116
+
117
+ def auto_detect_entrypoint
118
+ entrypoint = [
119
+ "app/javascript",
120
+ "app/frontend",
121
+ "app/client",
122
+ "app/webpack"
123
+ ].find { |path| File.exist?(Rails.root.join(path)) } || "app/javascript"
124
+
125
+ puts
126
+ puts "Where do JavaScript files live in your app? Our best guess is: \e[1m#{entrypoint}\e[22m 🤔"
127
+ puts "Press enter to accept this, or type a different path."
128
+ print "> "
129
+
130
+ input = Rails.env.test? ? "tmp/app/javascript" : $stdin.gets.chomp
131
+ entrypoint = input unless input.blank?
132
+
133
+ File.write(installer_entrypoint_path, entrypoint)
134
+
135
+ entrypoint
136
+ end
137
+
138
+ def installer_bundler_path
139
+ create_dir_for_file_if_not_exists("tmp/stimulus_reflex_installer/bundler")
110
140
  end
111
141
 
112
142
  def bundler
113
- @bundler ||= File.read("tmp/stimulus_reflex_installer/bundler")
143
+ path = installer_bundler_path
144
+ @bundler ||= File.exist?(path) ? File.read(path) : auto_detect_bundler
145
+
146
+ @bundler.inquiry
147
+ end
148
+
149
+ def auto_detect_bundler
150
+ # auto-detect build tool based on existing packages and configuration
151
+ if importmap_path.exist?
152
+ bundler = "importmap"
153
+ elsif package_json_path.exist?
154
+ package_json = package_json_path.read
155
+
156
+ bundler = "webpacker" if package_json.include?('"@rails/webpacker":')
157
+ bundler = "esbuild" if package_json.include?('"esbuild":')
158
+ bundler = "vite" if package_json.include?('"vite":')
159
+ bundler = "shakapacker" if package_json.include?('"shakapacker":')
160
+
161
+ if !bundler
162
+ puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use StimulusReflex."
163
+ exit
164
+ end
165
+ else
166
+ puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use StimulusReflex."
167
+ exit
168
+ end
169
+
170
+ puts
171
+ puts "It looks like you're using \e[1m#{bundler}\e[22m as your bundler. Is that correct? (Y/n)"
172
+ print "> "
173
+
174
+ input = $stdin.gets.chomp
175
+
176
+ if input.downcase == "n"
177
+ puts
178
+ puts "StimulusReflex installation supports: esbuild, webpacker, vite, shakapacker and importmap."
179
+ puts "Please run \e[1;94mrails stimulus_reflex:install [bundler]\e[0m to install StimulusReflex and CableReady."
180
+ exit
181
+ end
182
+
183
+ File.write(installer_bundler_path, bundler)
184
+
185
+ bundler
114
186
  end
115
187
 
116
- def network_issue_path
117
- @network_issue_path ||= Rails.root.join("tmp/stimulus_reflex_installer/network_issue")
188
+ def create_dir_if_not_exists(dir_path)
189
+ FileUtils.mkdir_p(dir_path)
190
+
191
+ Pathname.new(dir_path)
192
+ end
193
+
194
+ def create_dir_for_file_if_not_exists(file_path)
195
+ dir_path = File.dirname(file_path)
196
+ create_dir_if_not_exists(dir_path)
197
+
198
+ Pathname.new(file_path)
118
199
  end
119
200
 
120
201
  def config_path
121
- @config_path ||= Rails.root.join(entrypoint, "config")
202
+ @config_path ||= create_dir_if_not_exists(Rails.root.join(entrypoint, "config"))
122
203
  end
123
204
 
124
205
  def importmap_path
@@ -3,20 +3,6 @@
3
3
  require "stimulus_reflex/cable_readiness"
4
4
  require "stimulus_reflex/version_checker"
5
5
 
6
- # TODO remove xpath_controller and xpath_element for v4
7
- ClientAttributes = Struct.new(
8
- :id,
9
- :tab_id,
10
- :reflex_controller,
11
- :xpath_controller,
12
- :xpath_element,
13
- :permanent_attribute_name,
14
- :version,
15
- :npm_version,
16
- :suppress_logging,
17
- keyword_init: true
18
- )
19
-
20
6
  class StimulusReflex::Reflex
21
7
  prepend StimulusReflex::CableReadiness
22
8
  include StimulusReflex::VersionChecker
@@ -26,32 +12,27 @@ class StimulusReflex::Reflex
26
12
  include CableReady::Identifiable
27
13
 
28
14
  attr_accessor :payload, :headers
29
- attr_reader :channel, :url, :element, :selectors, :method_name, :broadcaster, :client_attributes, :logger
30
-
31
- alias_method :action_name, :method_name # for compatibility with controller libraries like Pundit that expect an action name
15
+ attr_reader :channel, :reflex_data, :broadcaster
32
16
 
33
17
  delegate :connection, :stream_name, to: :channel
34
18
  delegate :controller_class, :flash, :session, to: :request
35
19
  delegate :broadcast, :broadcast_halt, :broadcast_forbid, :broadcast_error, to: :broadcaster
20
+
36
21
  # TODO remove xpath_controller and xpath_element for v4
37
- delegate :id, :tab_id, :reflex_controller, :xpath_controller, :xpath_element, :permanent_attribute_name, :version, :npm_version, :suppress_logging, to: :client_attributes
22
+ delegate :url, :element, :selectors, :method_name, :id, :tab_id, :reflex_controller, :xpath_controller, :xpath_element, :permanent_attribute_name, :version, :npm_version, :suppress_logging, to: :reflex_data
23
+ # END TODO: remove
38
24
 
39
- def initialize(channel, url: nil, element: nil, selectors: [], method_name: nil, params: {}, client_attributes: {})
25
+ alias_method :action_name, :method_name # for compatibility with controller libraries like Pundit that expect an action name
26
+ alias_method :data, :reflex_data
27
+
28
+ def initialize(channel, reflex_data:)
40
29
  @channel = channel
41
- @url = url
42
- @element = element
43
- @selectors = selectors
44
- @method_name = method_name
45
- @params = params
46
- @client_attributes = ClientAttributes.new(client_attributes)
30
+ @reflex_data = reflex_data
47
31
  @broadcaster = StimulusReflex::PageBroadcaster.new(self)
48
- @logger = suppress_logging ? nil : StimulusReflex::Logger.new(self)
49
32
  @payload = {}
50
33
  @headers = {}
51
34
 
52
35
  check_version!
53
-
54
- self.params
55
36
  end
56
37
 
57
38
  # TODO: remove this for v4
@@ -61,6 +42,10 @@ class StimulusReflex::Reflex
61
42
  end
62
43
  # END TODO: remove
63
44
 
45
+ def logger
46
+ @logger ||= StimulusReflex::Logger.new(self) unless suppress_logging
47
+ end
48
+
64
49
  def request
65
50
  @request ||= begin
66
51
  uri = URI.parse(url)
@@ -91,7 +76,7 @@ class StimulusReflex::Reflex
91
76
  req = ActionDispatch::Request.new(env)
92
77
 
93
78
  # fetch path params (controller, action, ...) and apply them
94
- request_params = StimulusReflex::RequestParameters.new(params: @params, req: req, url: url)
79
+ request_params = StimulusReflex::RequestParameters.new(params: reflex_data.params, req: req, url: url)
95
80
  req = request_params.apply!
96
81
 
97
82
  req
@@ -4,7 +4,7 @@ class StimulusReflex::ReflexData
4
4
  attr_reader :data
5
5
 
6
6
  def initialize(data)
7
- @data = data
7
+ @data = data.deep_merge(data.deep_transform_keys { |k| k.to_s.underscore }).with_indifferent_access
8
8
  end
9
9
 
10
10
  def reflex_name
@@ -14,13 +14,13 @@ class StimulusReflex::ReflexData
14
14
  end
15
15
 
16
16
  def selectors
17
- selectors = (data["selectors"] || []).select(&:present?)
18
- selectors = data["selectors"] = ["body"] if selectors.blank?
17
+ selectors = (data[:selectors] || []).select(&:present?)
18
+ selectors = data[:selectors] = ["body"] if selectors.blank?
19
19
  selectors
20
20
  end
21
21
 
22
22
  def target
23
- data["target"].to_s
23
+ data[:target].to_s
24
24
  end
25
25
 
26
26
  def method_name
@@ -28,11 +28,11 @@ class StimulusReflex::ReflexData
28
28
  end
29
29
 
30
30
  def arguments
31
- (data["args"] || []).map { |arg| object_with_indifferent_access arg } || []
31
+ (data[:args] || []).map { |arg| object_with_indifferent_access arg } || []
32
32
  end
33
33
 
34
34
  def url
35
- data["url"].to_s
35
+ data[:url].to_s
36
36
  end
37
37
 
38
38
  def element
@@ -40,15 +40,15 @@ class StimulusReflex::ReflexData
40
40
  end
41
41
 
42
42
  def permanent_attribute_name
43
- data["permanentAttributeName"]
43
+ data[:permanent_attribute_name]
44
44
  end
45
45
 
46
46
  def suppress_logging
47
- data["suppressLogging"]
47
+ data[:suppress_logging]
48
48
  end
49
49
 
50
50
  def form_data
51
- Rack::Utils.parse_nested_query(data["formData"])
51
+ Rack::Utils.parse_nested_query(data[:form_data])
52
52
  end
53
53
 
54
54
  def params
@@ -56,7 +56,7 @@ class StimulusReflex::ReflexData
56
56
  end
57
57
 
58
58
  def form_params
59
- form_data.deep_merge(data["params"] || {})
59
+ form_data.deep_merge(data[:params] || {})
60
60
  end
61
61
 
62
62
  def url_params
@@ -64,33 +64,33 @@ class StimulusReflex::ReflexData
64
64
  end
65
65
 
66
66
  def id
67
- data["id"]
67
+ data[:id]
68
68
  end
69
69
 
70
70
  def tab_id
71
- data["tabId"]
71
+ data[:tab_id]
72
72
  end
73
73
 
74
74
  # TODO: remove this in v4
75
75
  def xpath_controller
76
- data["xpathController"]
76
+ data[:xpath_controller]
77
77
  end
78
78
 
79
79
  def xpath_element
80
- data["xpathElement"]
80
+ data[:xpath_element]
81
81
  end
82
82
  # END TODO remove
83
83
 
84
84
  def reflex_controller
85
- data["reflexController"]
85
+ data[:reflex_controller]
86
86
  end
87
87
 
88
88
  def npm_version
89
- data["version"].to_s
89
+ data[:version].to_s
90
90
  end
91
91
 
92
92
  def version
93
- data["version"].to_s.gsub("-pre", ".pre").gsub("-rc", ".rc")
93
+ npm_version.gsub("-pre", ".pre").gsub("-rc", ".rc")
94
94
  end
95
95
 
96
96
  private
@@ -1,36 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class StimulusReflex::ReflexFactory
4
- class << self
5
- attr_reader :reflex_data
6
-
7
- def create_reflex_from_data(channel, reflex_data)
8
- @reflex_data = reflex_data
9
- reflex_class.new(channel,
10
- url: reflex_data.url,
11
- element: reflex_data.element,
12
- selectors: reflex_data.selectors,
13
- method_name: reflex_data.method_name,
14
- params: reflex_data.params,
15
- client_attributes: {
16
- id: reflex_data.id,
17
- tab_id: reflex_data.tab_id,
18
- xpath_controller: reflex_data.xpath_controller,
19
- xpath_element: reflex_data.xpath_element,
20
- reflex_controller: reflex_data.reflex_controller,
21
- permanent_attribute_name: reflex_data.permanent_attribute_name,
22
- suppress_logging: reflex_data.suppress_logging,
23
- version: reflex_data.version,
24
- npm_version: reflex_data.npm_version
25
- })
4
+ attr_reader :channel, :data
5
+
6
+ delegate :reflex_name, :method_name, to: :data
7
+
8
+ def initialize(channel, data)
9
+ @channel = channel
10
+ @data = StimulusReflex::ReflexData.new(data)
11
+ end
12
+
13
+ def call
14
+ verify_method_name!
15
+ reflex_class.new(channel, reflex_data: data)
16
+ end
17
+
18
+ private
19
+
20
+ def verify_method_name!
21
+ return if default_reflex?
22
+
23
+ argument_error = ArgumentError.new("Reflex method '#{method_name}' is not defined on class '#{reflex_name}' or on any of its ancestors")
24
+
25
+ if reflex_method.nil?
26
+ raise argument_error
26
27
  end
27
28
 
28
- def reflex_class
29
- reflex_data.reflex_name.constantize.tap { |klass| raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex") unless is_reflex?(klass) }
29
+ if !safe_ancestors.include?(reflex_method.owner)
30
+ raise argument_error
30
31
  end
32
+ end
31
33
 
32
- def is_reflex?(klass)
33
- klass.ancestors.include? StimulusReflex::Reflex
34
+ def reflex_class
35
+ @reflex_class ||= reflex_name.constantize.tap do |klass|
36
+ unless klass.ancestors.include?(StimulusReflex::Reflex)
37
+ raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex")
38
+ end
34
39
  end
35
40
  end
41
+
42
+ def reflex_method
43
+ if reflex_class.public_instance_methods.include?(method_name.to_sym)
44
+ reflex_class.public_instance_method(method_name)
45
+ end
46
+ end
47
+
48
+ def default_reflex?
49
+ method_name == "default_reflex" && reflex_method.owner == ::StimulusReflex::Reflex
50
+ end
51
+
52
+ def safe_ancestors
53
+ # We want to include every class and module up to the `StimulusReflex::Reflex` class,
54
+ # but not the StimulusReflex::Reflex itself
55
+ reflex_class_index = reflex_class.ancestors.index(StimulusReflex::Reflex) - 1
56
+
57
+ reflex_class.ancestors.to(reflex_class_index)
58
+ end
36
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusReflex
4
- VERSION = "3.5.0.rc2"
4
+ VERSION = "3.5.0.rc4"
5
5
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "stimulus_reflex/installer"
4
+
3
5
  SR_STEPS = {
4
6
  "action_cable" => "Action Cable",
5
7
  "webpacker" => "Install StimulusReflex using Webpacker",
@@ -51,17 +53,18 @@ end
51
53
  namespace :stimulus_reflex do
52
54
  desc "✨ Install StimulusReflex and CableReady ✨"
53
55
  task :install do
54
- FileUtils.mkdir_p(Rails.root.join("tmp/stimulus_reflex_installer/templates"))
55
- FileUtils.mkdir_p(Rails.root.join("tmp/stimulus_reflex_installer/working"))
56
+ create_dir_if_not_exists(Rails.root.join("tmp/stimulus_reflex_installer/templates"))
57
+ create_dir_if_not_exists(Rails.root.join("tmp/stimulus_reflex_installer/working"))
58
+
56
59
  install_complete = Rails.root.join("tmp/stimulus_reflex_installer/complete")
57
60
 
58
- bundler = nil
61
+ used_bundler = nil
59
62
  options = {}
60
63
 
61
64
  ARGV.each do |arg|
62
65
  # make sure we have a valid build tool specified, or proceed to automatic detection
63
66
  if ["webpacker", "esbuild", "vite", "shakapacker", "importmap"].include?(arg)
64
- bundler = arg
67
+ used_bundler = arg
65
68
  else
66
69
  kv = arg.split("=")
67
70
  if kv.length == 2
@@ -90,9 +93,9 @@ namespace :stimulus_reflex do
90
93
  end
91
94
 
92
95
  # if there is an installation in progress, continue where we left off
93
- cached_entrypoint = Rails.root.join("tmp/stimulus_reflex_installer/entrypoint")
94
- if cached_entrypoint.exist?
95
- entrypoint = File.read(cached_entrypoint)
96
+ if installer_entrypoint_path.exist?
97
+ entrypoint = installer_entrypoint_path.read
98
+
96
99
  puts "✨ Resuming \e[38;5;220mStimulusReflex\e[0m and \e[38;5;220mCableReady\e[0m installation ✨"
97
100
  puts
98
101
  puts "If you have any setup issues, please consult \e[4;97mhttps://docs.stimulusreflex.com/hello-world/setup\e[0m"
@@ -106,69 +109,35 @@ namespace :stimulus_reflex do
106
109
  puts
107
110
  puts "If you have any setup issues, please consult \e[4;97mhttps://docs.stimulusreflex.com/hello-world/setup\e[0m"
108
111
  puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
112
+
109
113
  if Rails.root.join(".git").exist?
110
114
  puts
111
115
  puts "We recommend running \e[1;94mgit commit\e[0m before proceeding. A diff will be generated at the end."
112
116
  end
113
117
 
114
- if options.key? "entrypoint"
115
- entrypoint = options["entrypoint"]
118
+ entrypoint = if options.key? "entrypoint"
119
+ options["entrypoint"]
116
120
  else
117
- entrypoint = [
118
- "app/javascript",
119
- "app/frontend"
120
- ].find { |path| File.exist?(Rails.root.join(path)) } || "app/javascript"
121
-
122
- puts
123
- puts "Where do JavaScript files live in your app? Our best guess is: \e[1m#{entrypoint}\e[22m 🤔"
124
- puts "Press enter to accept this, or type a different path."
125
- print "> "
126
- input = $stdin.gets.chomp
127
- entrypoint = input unless input.blank?
121
+ auto_detect_entrypoint
128
122
  end
129
- File.write(cached_entrypoint, entrypoint)
123
+
124
+ installer_entrypoint_path.write(entrypoint)
130
125
  end
131
126
 
132
127
  # verify their bundler before starting, unless they explicitly specified on CLI
133
- if !bundler
134
- # auto-detect build tool based on existing packages and configuration
135
- if Rails.root.join("config/importmap.rb").exist?
136
- bundler = "importmap"
137
- elsif Rails.root.join("package.json").exist?
138
- package_json = File.read(Rails.root.join("package.json"))
139
- bundler = "webpacker" if package_json.include?('"@rails/webpacker":')
140
- bundler = "esbuild" if package_json.include?('"esbuild":')
141
- bundler = "vite" if package_json.include?('"vite":')
142
- bundler = "shakapacker" if package_json.include?('"shakapacker":')
143
- if !bundler
144
- puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use StimulusReflex."
145
- exit
146
- end
147
- else
148
- puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use StimulusReflex."
149
- exit
150
- end
151
-
152
- puts
153
- puts "It looks like you're using \e[1m#{bundler}\e[22m as your bundler. Is that correct? (Y/n)"
154
- print "> "
155
- input = $stdin.gets.chomp
156
- if input.downcase == "n"
157
- puts
158
- puts "StimulusReflex installation supports: esbuild, webpacker, vite, shakapacker and importmap."
159
- puts "Please run \e[1;94mrails stimulus_reflex:install [bundler]\e[0m to install StimulusReflex and CableReady."
160
- exit
161
- end
128
+ if !used_bundler
129
+ used_bundler = bundler
162
130
  end
163
131
 
164
- File.write("tmp/stimulus_reflex_installer/bundler", bundler)
132
+ installer_bundler_path.write(used_bundler)
133
+
165
134
  FileUtils.touch("tmp/stimulus_reflex_installer/backups")
166
135
  File.write("tmp/stimulus_reflex_installer/template_src", File.expand_path("../../generators/stimulus_reflex/templates/", __dir__))
167
136
 
168
137
  `bin/spring stop` if defined?(Spring)
169
138
 
170
139
  # do the things
171
- SR_BUNDLERS[bundler].each do |template|
140
+ SR_BUNDLERS[used_bundler].each do |template|
172
141
  run_install_template(template, trace: !!options["trace"])
173
142
  end
174
143
 
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stimulus_reflex",
3
- "version": "3.5.0-rc2",
3
+ "version": "3.5.0-rc4",
4
4
  "description": "Build reactive applications with the Rails tooling you already know and love.",
5
5
  "keywords": [
6
6
  "ruby",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@hotwired/stimulus": "^3",
59
59
  "@rails/actioncable": "^6 || ^7",
60
- "cable_ready": "5.0.0-rc2"
60
+ "cable_ready": "^5.0.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@open-wc/testing": "^3.1.7",
@@ -70,6 +70,6 @@
70
70
  "prettier-standard": "^16.4.1",
71
71
  "rollup": "^3.19.1",
72
72
  "toastify-js": "^1.12.0",
73
- "vitepress": "^1.0.0-alpha.56"
73
+ "vitepress": "^1.0.0-beta.1"
74
74
  }
75
75
  }
@@ -37,7 +37,7 @@ Gem::Specification.new do |gem|
37
37
  "[A-Z]*"
38
38
  ]
39
39
 
40
- gem.required_ruby_version = ">= 2.7.0"
40
+ gem.required_ruby_version = ">= 3.0.0"
41
41
 
42
42
  rails_version = [">= 5.2", "< 8"]
43
43
  gem.add_dependency "actioncable", *rails_version
@@ -46,7 +46,7 @@ Gem::Specification.new do |gem|
46
46
  gem.add_dependency "activesupport", *rails_version
47
47
  gem.add_dependency "railties", *rails_version
48
48
 
49
- gem.add_dependency "cable_ready", ">= 5.0.0.rc2"
49
+ gem.add_dependency "cable_ready", "~> 5.0"
50
50
  gem.add_dependency "nokogiri", "~> 1.0"
51
51
  gem.add_dependency "rack", ">= 2", "< 4"
52
52
  gem.add_dependency "redis", ">= 4.0", "< 6.0"