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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cce31cfe35841f8e96b70fe52e22ee84cf6aa287562b3ab6d1d0ee318fa109ee
|
4
|
+
data.tar.gz: 33e86551718a90441a3110e7daf72c110ecf42fcd73105d788ec508d92a30ca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a56cd9fcedd2859b3d9b828dbc0fc91c59e9b773ddb983a22ce23709bc443ab4cbd25270bfda366a4594767f08f9964af4fd30475307889eb6ab10ad187828f3
|
7
|
+
data.tar.gz: a5f3a462fe156023852d2db3911040436034c3fe54e3716aeecad1fcf2aa0ef86484f04236f20fa75ae149a3530dad23d8935d71a8dd817da43084ce2d895c8a
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stimulus_reflex (3.5.0.
|
4
|
+
stimulus_reflex (3.5.0.rc3)
|
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
|
-
cable_ready (
|
9
|
+
cable_ready (~> 5.0)
|
10
10
|
nokogiri (~> 1.0)
|
11
11
|
rack (>= 2, < 4)
|
12
12
|
railties (>= 5.2, < 8)
|
@@ -82,26 +82,26 @@ GEM
|
|
82
82
|
tzinfo (~> 2.0)
|
83
83
|
ast (2.4.2)
|
84
84
|
builder (3.2.4)
|
85
|
-
cable_ready (5.0.
|
85
|
+
cable_ready (5.0.1)
|
86
86
|
actionpack (>= 5.2)
|
87
87
|
actionview (>= 5.2)
|
88
88
|
activesupport (>= 5.2)
|
89
89
|
railties (>= 5.2)
|
90
90
|
thread-local (>= 1.1.0)
|
91
|
-
concurrent-ruby (1.2.
|
91
|
+
concurrent-ruby (1.2.2)
|
92
92
|
connection_pool (2.4.0)
|
93
93
|
crass (1.0.6)
|
94
94
|
date (3.3.3)
|
95
95
|
erubi (1.12.0)
|
96
96
|
globalid (1.1.0)
|
97
97
|
activesupport (>= 5.0)
|
98
|
-
i18n (1.
|
98
|
+
i18n (1.14.1)
|
99
99
|
concurrent-ruby (~> 1.0)
|
100
100
|
json (2.6.3)
|
101
101
|
language_server-protocol (3.17.0.3)
|
102
|
-
loofah (2.
|
102
|
+
loofah (2.21.3)
|
103
103
|
crass (~> 1.0.2)
|
104
|
-
nokogiri (>= 1.
|
104
|
+
nokogiri (>= 1.12.0)
|
105
105
|
magic_frozen_string_literal (1.2.0)
|
106
106
|
mail (2.8.1)
|
107
107
|
mini_mime (>= 0.1.1)
|
@@ -111,7 +111,7 @@ GEM
|
|
111
111
|
marcel (1.0.2)
|
112
112
|
method_source (1.0.0)
|
113
113
|
mini_mime (1.1.2)
|
114
|
-
minitest (5.
|
114
|
+
minitest (5.18.1)
|
115
115
|
mocha (1.13.0)
|
116
116
|
net-imap (0.3.4)
|
117
117
|
date
|
@@ -123,16 +123,16 @@ GEM
|
|
123
123
|
net-smtp (0.3.3)
|
124
124
|
net-protocol
|
125
125
|
nio4r (2.5.8)
|
126
|
-
nokogiri (1.
|
126
|
+
nokogiri (1.15.3-x86_64-darwin)
|
127
127
|
racc (~> 1.4)
|
128
|
-
nokogiri (1.
|
128
|
+
nokogiri (1.15.3-x86_64-linux)
|
129
129
|
racc (~> 1.4)
|
130
130
|
parallel (1.22.1)
|
131
131
|
parser (3.2.1.0)
|
132
132
|
ast (~> 2.4.1)
|
133
|
-
racc (1.
|
134
|
-
rack (2.2.
|
135
|
-
rack-test (2.0
|
133
|
+
racc (1.7.1)
|
134
|
+
rack (2.2.7)
|
135
|
+
rack-test (2.1.0)
|
136
136
|
rack (>= 1.3)
|
137
137
|
rails (7.0.4.2)
|
138
138
|
actioncable (= 7.0.4.2)
|
@@ -148,11 +148,13 @@ GEM
|
|
148
148
|
activesupport (= 7.0.4.2)
|
149
149
|
bundler (>= 1.15.0)
|
150
150
|
railties (= 7.0.4.2)
|
151
|
-
rails-dom-testing (2.
|
152
|
-
activesupport (>=
|
151
|
+
rails-dom-testing (2.1.1)
|
152
|
+
activesupport (>= 5.0.0)
|
153
|
+
minitest
|
153
154
|
nokogiri (>= 1.6)
|
154
|
-
rails-html-sanitizer (1.
|
155
|
-
loofah (~> 2.
|
155
|
+
rails-html-sanitizer (1.6.0)
|
156
|
+
loofah (~> 2.21)
|
157
|
+
nokogiri (~> 1.14)
|
156
158
|
railties (7.0.4.2)
|
157
159
|
actionpack (= 7.0.4.2)
|
158
160
|
activesupport (= 7.0.4.2)
|
@@ -188,7 +190,7 @@ GEM
|
|
188
190
|
language_server-protocol (~> 3.17.0.2)
|
189
191
|
rubocop (= 1.44.1)
|
190
192
|
rubocop-performance (= 1.15.2)
|
191
|
-
thor (1.2.
|
193
|
+
thor (1.2.2)
|
192
194
|
thread-local (1.1.0)
|
193
195
|
timeout (0.3.2)
|
194
196
|
tzinfo (2.0.6)
|
@@ -197,10 +199,11 @@ GEM
|
|
197
199
|
websocket-driver (0.7.5)
|
198
200
|
websocket-extensions (>= 0.1.0)
|
199
201
|
websocket-extensions (0.1.5)
|
200
|
-
zeitwerk (2.6.
|
202
|
+
zeitwerk (2.6.8)
|
201
203
|
|
202
204
|
PLATFORMS
|
203
205
|
x86_64-darwin-19
|
206
|
+
x86_64-darwin-22
|
204
207
|
x86_64-linux
|
205
208
|
|
206
209
|
DEPENDENCIES
|
@@ -213,4 +216,4 @@ DEPENDENCIES
|
|
213
216
|
stimulus_reflex!
|
214
217
|
|
215
218
|
BUNDLED WITH
|
216
|
-
2.
|
219
|
+
2.4.14
|
@@ -608,8 +608,15 @@ class Reflex {
|
|
608
608
|
|
609
609
|
const received = data => {
|
610
610
|
if (!data.cableReady) return;
|
611
|
-
if (data.version.replace(".pre", "-pre") !== CableReady.version) {
|
612
|
-
|
611
|
+
if (data.version.replace(".pre", "-pre").replace(".rc", "-rc") !== CableReady.version) {
|
612
|
+
const mismatch = `CableReady failed to execute your reflex action due to a version mismatch between your gem and JavaScript version. Package versions must match exactly.\n\ncable_ready gem: ${data.version}\ncable_ready npm: ${CableReady.version}`;
|
613
|
+
console.error(mismatch);
|
614
|
+
if (Debug$1.enabled) {
|
615
|
+
CableReady.operations.stimulusReflexVersionMismatch({
|
616
|
+
text: mismatch,
|
617
|
+
level: "error"
|
618
|
+
});
|
619
|
+
}
|
613
620
|
return;
|
614
621
|
}
|
615
622
|
let reflexOperations = [];
|
@@ -938,7 +945,7 @@ const extractDataAttributes = element => {
|
|
938
945
|
|
939
946
|
var name = "stimulus_reflex";
|
940
947
|
|
941
|
-
var version = "3.5.0-
|
948
|
+
var version = "3.5.0-rc3";
|
942
949
|
|
943
950
|
var description = "Build reactive applications with the Rails tooling you already know and love.";
|
944
951
|
|
@@ -988,7 +995,7 @@ var peerDependencies = {
|
|
988
995
|
var dependencies = {
|
989
996
|
"@hotwired/stimulus": "^3",
|
990
997
|
"@rails/actioncable": "^6 || ^7",
|
991
|
-
cable_ready: "5.0.0
|
998
|
+
cable_ready: "^5.0.0"
|
992
999
|
};
|
993
1000
|
|
994
1001
|
var devDependencies = {
|
@@ -1002,7 +1009,7 @@ var devDependencies = {
|
|
1002
1009
|
"prettier-standard": "^16.4.1",
|
1003
1010
|
rollup: "^3.19.1",
|
1004
1011
|
"toastify-js": "^1.12.0",
|
1005
|
-
vitepress: "^1.0.0-
|
1012
|
+
vitepress: "^1.0.0-beta.1"
|
1006
1013
|
};
|
1007
1014
|
|
1008
1015
|
var packageInfo = {
|
@@ -562,8 +562,15 @@
|
|
562
562
|
}
|
563
563
|
const received = data => {
|
564
564
|
if (!data.cableReady) return;
|
565
|
-
if (data.version.replace(".pre", "-pre") !== CableReady.version) {
|
566
|
-
|
565
|
+
if (data.version.replace(".pre", "-pre").replace(".rc", "-rc") !== CableReady.version) {
|
566
|
+
const mismatch = `CableReady failed to execute your reflex action due to a version mismatch between your gem and JavaScript version. Package versions must match exactly.\n\ncable_ready gem: ${data.version}\ncable_ready npm: ${CableReady.version}`;
|
567
|
+
console.error(mismatch);
|
568
|
+
if (Debug$1.enabled) {
|
569
|
+
CableReady.operations.stimulusReflexVersionMismatch({
|
570
|
+
text: mismatch,
|
571
|
+
level: "error"
|
572
|
+
});
|
573
|
+
}
|
567
574
|
return;
|
568
575
|
}
|
569
576
|
let reflexOperations = [];
|
@@ -862,7 +869,7 @@
|
|
862
869
|
return attrs;
|
863
870
|
};
|
864
871
|
var name = "stimulus_reflex";
|
865
|
-
var version = "3.5.0-
|
872
|
+
var version = "3.5.0-rc3";
|
866
873
|
var description = "Build reactive applications with the Rails tooling you already know and love.";
|
867
874
|
var keywords = [ "ruby", "rails", "websockets", "actioncable", "turbolinks", "reactive", "cable", "ujs", "ssr", "stimulus", "reflex", "stimulus_reflex", "dom", "morphdom" ];
|
868
875
|
var homepage = "https://docs.stimulusreflex.com";
|
@@ -895,7 +902,7 @@
|
|
895
902
|
var dependencies = {
|
896
903
|
"@hotwired/stimulus": "^3",
|
897
904
|
"@rails/actioncable": "^6 || ^7",
|
898
|
-
cable_ready: "5.0.0
|
905
|
+
cable_ready: "^5.0.0"
|
899
906
|
};
|
900
907
|
var devDependencies = {
|
901
908
|
"@open-wc/testing": "^3.1.7",
|
@@ -908,7 +915,7 @@
|
|
908
915
|
"prettier-standard": "^16.4.1",
|
909
916
|
rollup: "^3.19.1",
|
910
917
|
"toastify-js": "^1.12.0",
|
911
|
-
vitepress: "^1.0.0-
|
918
|
+
vitepress: "^1.0.0-beta.1"
|
912
919
|
};
|
913
920
|
var packageInfo = {
|
914
921
|
name: name,
|
@@ -27,7 +27,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
27
27
|
reflex.logger&.error error_message
|
28
28
|
reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
|
29
29
|
else
|
30
|
-
unless exception.is_a?(StimulusReflex::
|
30
|
+
unless exception.is_a?(StimulusReflex::VersionMismatchError)
|
31
31
|
StimulusReflex.config.logger.error error_message
|
32
32
|
end
|
33
33
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rails/generators"
|
4
4
|
require "stimulus_reflex/version"
|
5
|
+
require "stimulus_reflex/installer"
|
5
6
|
|
6
7
|
class StimulusReflexGenerator < Rails::Generators::NamedBase
|
7
8
|
source_root File.expand_path("templates", __dir__)
|
@@ -13,33 +14,20 @@ class StimulusReflexGenerator < Rails::Generators::NamedBase
|
|
13
14
|
def execute
|
14
15
|
actions.map!(&:underscore)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Rails.root.join("app/javascript"),
|
22
|
-
Rails.root.join("app/frontend")
|
23
|
-
].find(&:exist?) || "app/javascript"
|
24
|
-
puts "Where do JavaScript files live in your app? Our best guess is: \e[1#{entrypoint}\e[22m 🤔"
|
25
|
-
puts "Press enter to accept this, or type a different path."
|
26
|
-
print "> "
|
27
|
-
input = Rails.env.test? ? "tmp/app/javascript" : $stdin.gets.chomp
|
28
|
-
entrypoint = input unless input.blank?
|
29
|
-
end
|
17
|
+
reflex_entrypoint = Rails.env.test? ? "tmp/app/reflexes" : "app/reflexes"
|
18
|
+
reflex_src = "app/reflexes/%file_name%_reflex.rb.tt"
|
19
|
+
reflex_path = Rails.root.join(reflex_entrypoint, "#{file_name}_reflex.rb")
|
20
|
+
|
21
|
+
template(reflex_src, reflex_path) unless options[:skip_reflex]
|
30
22
|
|
31
23
|
if !options[:skip_stimulus] && entrypoint.blank?
|
32
24
|
puts "❌ You must specify a valid JavaScript entrypoint."
|
33
25
|
exit
|
34
26
|
end
|
35
27
|
|
36
|
-
reflex_entrypoint = Rails.env.test? ? "tmp/app/reflexes" : "app/reflexes"
|
37
|
-
reflex_src = "app/reflexes/%file_name%_reflex.rb.tt"
|
38
|
-
reflex_path = Rails.root.join(reflex_entrypoint, "#{file_name}_reflex.rb")
|
39
28
|
stimulus_controller_src = "app/javascript/controllers/%file_name%_controller.js.tt"
|
40
29
|
stimulus_controller_path = Rails.root.join(entrypoint, "controllers/#{file_name}_controller.js")
|
41
30
|
|
42
|
-
template(reflex_src, reflex_path) unless options[:skip_reflex]
|
43
31
|
template(stimulus_controller_src, stimulus_controller_path) unless options[:skip_stimulus]
|
44
32
|
|
45
33
|
if file_name == "example"
|
@@ -1,4 +1,8 @@
|
|
1
|
-
|
2
|
-
import
|
1
|
+
<%- if bundler.importmap? -%>
|
2
|
+
import consumer from "channels/consumer"
|
3
|
+
<%- else -%>
|
4
|
+
import consumer from "../channels/consumer"
|
5
|
+
<%- end -%>
|
6
|
+
import CableReady from "cable_ready"
|
3
7
|
|
4
8
|
CableReady.initialize({ consumer })
|
@@ -1,5 +1,10 @@
|
|
1
|
+
<%- if bundler.importmap? -%>
|
2
|
+
import { application } from "controllers/application"
|
3
|
+
import controller from "controllers/application_controller"
|
4
|
+
<%- else -%>
|
1
5
|
import { application } from "../controllers/application"
|
2
6
|
import controller from "../controllers/application_controller"
|
7
|
+
<%- end -%>
|
3
8
|
import StimulusReflex from "stimulus_reflex"
|
4
9
|
|
5
10
|
StimulusReflex.initialize(application, { controller, isolate: true })
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
1
|
+
<%- if bundler.importmap? -%>
|
2
|
+
import ApplicationController from "controllers/application_controller"
|
3
|
+
<%- else -%>
|
4
|
+
import ApplicationController from "./application_controller"
|
5
|
+
<%- end -%>
|
2
6
|
|
3
7
|
<%- if class_name == "Example" -%>
|
4
|
-
//
|
8
|
+
//
|
5
9
|
// This is the Stimulus controller for the Example Reflex.
|
6
10
|
//
|
7
11
|
// It corresponds to the server-side Reflex class located at /app/reflexes/example.rb
|
@@ -1,11 +1,15 @@
|
|
1
1
|
import { Application } from "@hotwired/stimulus"
|
2
|
+
<%- if bundler.importmap? %>
|
3
|
+
import consumer from "channels/consumer"
|
4
|
+
<%- else %>
|
2
5
|
import consumer from "../channels/consumer"
|
6
|
+
<%- end %>
|
3
7
|
|
4
8
|
const application = Application.start()
|
5
9
|
|
6
10
|
// Configure Stimulus development experience
|
7
11
|
application.debug = false
|
8
12
|
application.consumer = consumer
|
9
|
-
window.Stimulus
|
13
|
+
window.Stimulus = application
|
10
14
|
|
11
15
|
export { application }
|
data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
|
1
|
+
// Import and register all your controllers from the importmap under controllers/*
|
2
|
+
|
3
|
+
import { application } from "controllers/application"
|
2
4
|
|
3
5
|
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
4
6
|
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
5
7
|
eagerLoadControllersFrom("controllers", application)
|
8
|
+
|
9
|
+
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
|
10
|
+
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
11
|
+
// lazyLoadControllersFrom("controllers", application)
|
data/lib/install/config.rb
CHANGED
@@ -20,7 +20,7 @@ if index_path.exist?
|
|
20
20
|
say "⏩ #{friendly_index_path} already exists. Skipping"
|
21
21
|
else
|
22
22
|
backup(index_path, delete: true) do
|
23
|
-
|
23
|
+
template(index_src, index_path)
|
24
24
|
end
|
25
25
|
say "✅ Created #{friendly_index_path}"
|
26
26
|
end
|
@@ -50,22 +50,22 @@ else
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# create entrypoint/config/cable_ready.js and make sure it's imported in application.js
|
53
|
-
|
53
|
+
template(cable_ready_src, cable_ready_path) unless cable_ready_path.exist?
|
54
54
|
|
55
55
|
# create entrypoint/config/stimulus_reflex.js and make sure it's imported in application.js
|
56
|
-
|
56
|
+
template(stimulus_reflex_src, stimulus_reflex_path) unless stimulus_reflex_path.exist?
|
57
57
|
|
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
|
61
|
+
if bundler.webpacker? || 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
|
68
|
+
elsif 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") {
|
data/lib/install/esbuild.rb
CHANGED
@@ -5,7 +5,7 @@ require "stimulus_reflex/installer"
|
|
5
5
|
return if pack_path_missing?
|
6
6
|
|
7
7
|
# verify that all critical dependencies are up to date; if not, queue for later
|
8
|
-
lines =
|
8
|
+
lines = package_json_path.readlines
|
9
9
|
|
10
10
|
if !lines.index { |line| line =~ /^\s*["']esbuild-rails["']: ["']\^1.0.3["']/ }
|
11
11
|
add_package "esbuild-rails@^1.0.3"
|
data/lib/install/importmap.rb
CHANGED
@@ -104,12 +104,12 @@ backup(application_js_path) do
|
|
104
104
|
if application_js_path.read.include?("import consumer")
|
105
105
|
say "⏩ #{friendly_application_js_path} is present. Skipping."
|
106
106
|
else
|
107
|
-
inject_into_file application_js_path, "import consumer from \"
|
107
|
+
inject_into_file application_js_path, "import consumer from \"channels/consumer\"\n", after: "import { Application } from \"@hotwired/stimulus\"\n", verbose: false
|
108
108
|
inject_into_file application_js_path, "application.consumer = consumer\n", after: "application.debug = false\n", verbose: false
|
109
109
|
say "✅ #{friendly_application_js_path} has been updated to import the Action Cable consumer"
|
110
110
|
end
|
111
111
|
else
|
112
|
-
|
112
|
+
template(application_js_src, application_js_path)
|
113
113
|
say "✅ #{friendly_application_js_path} has been created"
|
114
114
|
end
|
115
115
|
end
|
data/lib/install/mrujs.rb
CHANGED
@@ -17,7 +17,7 @@ if !File.exist?(mrujs_path)
|
|
17
17
|
end
|
18
18
|
|
19
19
|
if proceed
|
20
|
-
if bundler
|
20
|
+
if bundler.importmap?
|
21
21
|
|
22
22
|
if !importmap_path.exist?
|
23
23
|
halt "#{friendly_importmap_path} is missing. You need a valid importmap config file to proceed."
|
@@ -45,14 +45,14 @@ if proceed
|
|
45
45
|
end
|
46
46
|
else
|
47
47
|
# queue mrujs for installation
|
48
|
-
if
|
48
|
+
if package_json_path.read.include?('"mrujs":')
|
49
49
|
say "⏩ mrujs already present. Skipping."
|
50
50
|
else
|
51
51
|
add_package "mrujs@^0.10.1"
|
52
52
|
end
|
53
53
|
|
54
54
|
# queue @rails/ujs for removal
|
55
|
-
if
|
55
|
+
if package_json_path.read.include?('"@rails/ujs":')
|
56
56
|
drop_package "@rails/ujs"
|
57
57
|
else
|
58
58
|
say "⏩ @rails/ujs not present. Skipping."
|
@@ -70,10 +70,15 @@ if proceed
|
|
70
70
|
index = index_path.read
|
71
71
|
friendly_index_path = index_path.relative_path_from(Rails.root).to_s
|
72
72
|
mrujs_pattern = /import ['"].\/mrujs['"]/
|
73
|
-
|
73
|
+
|
74
|
+
mrujs_import = if bundler.importmap?
|
75
|
+
%(import "config/mrujs"\n)
|
76
|
+
else
|
77
|
+
%(import "./mrujs"\n)
|
78
|
+
end
|
74
79
|
|
75
80
|
if index.match?(mrujs_pattern)
|
76
|
-
say "⏩ mrujs
|
81
|
+
say "⏩ mrujs already imported in #{friendly_index_path}. Skipping."
|
77
82
|
else
|
78
83
|
append_file(index_path, mrujs_import, verbose: false)
|
79
84
|
say "✅ mrujs imported in #{friendly_index_path}"
|
data/lib/install/npm_packages.rb
CHANGED
data/lib/install/shakapacker.rb
CHANGED
@@ -5,7 +5,7 @@ require "stimulus_reflex/installer"
|
|
5
5
|
return if pack_path_missing?
|
6
6
|
|
7
7
|
# verify that all critical dependencies are up to date; if not, queue for later
|
8
|
-
lines =
|
8
|
+
lines = package_json_path.readlines
|
9
9
|
|
10
10
|
if !lines.index { |line| line =~ /^\s*["']@hotwired\/stimulus-webpack-helpers["']: ["']\^1.0.1["']/ }
|
11
11
|
add_package "@hotwired/stimulus-webpack-helpers@^1.0.1"
|
data/lib/install/vite.rb
CHANGED
@@ -5,7 +5,7 @@ require "stimulus_reflex/installer"
|
|
5
5
|
return if pack_path_missing?
|
6
6
|
|
7
7
|
# verify that all critical dependencies are up to date; if not, queue for later
|
8
|
-
lines =
|
8
|
+
lines = package_json_path.readlines
|
9
9
|
|
10
10
|
if !lines.index { |line| line =~ /^\s*["']stimulus-vite-helpers["']: ["']\^3["']/ }
|
11
11
|
add_package "stimulus-vite-helpers@^3"
|
data/lib/install/webpacker.rb
CHANGED
@@ -5,7 +5,7 @@ require "stimulus_reflex/installer"
|
|
5
5
|
return if pack_path_missing?
|
6
6
|
|
7
7
|
# verify that all critical dependencies are up to date; if not, queue for later
|
8
|
-
lines =
|
8
|
+
lines = package_json_path.readlines
|
9
9
|
if !lines.index { |line| line =~ /^\s*["']webpack["']: ["']\^4.46.0["']/ }
|
10
10
|
add_package "webpack@^4.46.0"
|
11
11
|
else
|
data/lib/install/yarn.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "stimulus_reflex/installer"
|
4
4
|
|
5
|
-
if !
|
5
|
+
if !package_json_path.exist?
|
6
6
|
say "⏩ No package.json file found. Skipping."
|
7
7
|
|
8
8
|
return
|
@@ -36,7 +36,7 @@ if add.present? || dev.present? || drop.present?
|
|
36
36
|
json["devDependencies"].delete(package)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
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
|
-
|
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
|
-
|
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)
|