stimulus_reflex 3.5.0.rc1 → 3.5.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of stimulus_reflex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -20
- data/app/assets/javascripts/stimulus_reflex.js +12 -5
- data/app/assets/javascripts/stimulus_reflex.umd.js +12 -5
- data/app/channels/stimulus_reflex/channel.rb +1 -1
- data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +6 -18
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +6 -2
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +7 -2
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +6 -2
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +5 -1
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +7 -1
- data/lib/install/config.rb +5 -5
- data/lib/install/esbuild.rb +1 -1
- data/lib/install/importmap.rb +2 -2
- data/lib/install/mrujs.rb +10 -5
- data/lib/install/npm_packages.rb +1 -1
- data/lib/install/shakapacker.rb +1 -1
- data/lib/install/vite.rb +1 -1
- data/lib/install/webpacker.rb +1 -1
- data/lib/install/yarn.rb +3 -3
- data/lib/stimulus_reflex/cable_readiness.rb +1 -7
- data/lib/stimulus_reflex/installer.rb +90 -9
- data/lib/stimulus_reflex/reflex_data.rb +1 -1
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +21 -52
- data/package.json +3 -3
- data/stimulus_reflex.gemspec +1 -1
- data/yarn.lock +500 -440
- metadata +7 -7
@@ -94,31 +94,112 @@ end
|
|
94
94
|
### memoized values
|
95
95
|
|
96
96
|
def sr_npm_version
|
97
|
-
@sr_npm_version ||= StimulusReflex::VERSION.gsub(".pre", "-pre")
|
97
|
+
@sr_npm_version ||= StimulusReflex::VERSION.gsub(".pre", "-pre").gsub(".rc", "-rc")
|
98
98
|
end
|
99
99
|
|
100
100
|
def cr_npm_version
|
101
|
-
@cr_npm_version ||= CableReady::VERSION.gsub(".pre", "-pre")
|
101
|
+
@cr_npm_version ||= CableReady::VERSION.gsub(".pre", "-pre").gsub(".rc", "-rc")
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
105
|
-
@
|
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
|
-
|
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
|
-
|
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
|
117
|
-
|
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
|
@@ -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
|
-
|
55
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
118
|
+
entrypoint = if options.key? "entrypoint"
|
119
|
+
options["entrypoint"]
|
116
120
|
else
|
117
|
-
|
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
|
-
|
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 !
|
134
|
-
|
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
|
-
|
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[
|
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-
|
3
|
+
"version": "3.5.0-rc3",
|
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
|
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-
|
73
|
+
"vitepress": "^1.0.0-beta.1"
|
74
74
|
}
|
75
75
|
}
|
data/stimulus_reflex.gemspec
CHANGED
@@ -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", "
|
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"
|