stimulus_reflex 3.4.0.pre8 → 3.4.0.pre9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2431b50e027a8144cd11458b3de85f9b09bbfac0e3929eee35f3dc62134c742a
4
- data.tar.gz: e766e76490781882ff539785408ebf48c3f9ef931d09c6322c87900c079ad857
3
+ metadata.gz: 2848aafa546f97670d86dd381bc4b05ffcd56962fea931ba537004a1bf2593c8
4
+ data.tar.gz: 7dc8dfb4ff3760ca3701b5a34f2622e3d43b449e02d7ff3fb193fd6a124186d4
5
5
  SHA512:
6
- metadata.gz: c2168b3fb2da302b53ce7c4010fad3f5fb83e8a129ab83c6dcd45e0638d2c3e8deebdbfdc7dde43197b143c73bee9703b1fe3b3406a73731a887122f28b04d89
7
- data.tar.gz: ea440d1c4ff00a93ab3574042b793406fd470c9c49205a9d9c3106b2cae78718217aa5e4b70d8024ff5db3a130476ac55a2f8117018bb700203e595164e2277f
6
+ metadata.gz: 9e9bf858782e9a3a18ae76ccbc4e8808db4bd6c6c1ffd185f62101974ddcf708f3eef80439cae12ce6405ef632fd2ee1933866dc17eded4accd66422f7ff2231
7
+ data.tar.gz: 6535eb6146e20306e5b2bd9ef04cc793b61f7dea64232c73d344dbe8ae410c23f3ecba8961f895cbd1df708f10f6341c9b292ef22714615a5be8fcc150bd1d88
@@ -2,7 +2,30 @@
2
2
 
3
3
  ## [Unreleased](https://github.com/hopsoft/stimulus_reflex/tree/HEAD)
4
4
 
5
- [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre7...HEAD)
5
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre8...HEAD)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Support for Stimulus 2 [\#398](https://github.com/hopsoft/stimulus_reflex/pull/398) ([marcoroth](https://github.com/marcoroth))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - fix up install task [\#401](https://github.com/hopsoft/stimulus_reflex/pull/401) ([leastbad](https://github.com/leastbad))
14
+ - Fix multiple broadcasts from within the same reflex [\#400](https://github.com/hopsoft/stimulus_reflex/pull/400) ([hopsoft](https://github.com/hopsoft))
15
+
16
+ **Closed issues:**
17
+
18
+ - Sanity checker will fail if node\_modules folder isn't present [\#402](https://github.com/hopsoft/stimulus_reflex/issues/402)
19
+ - stimulus\_reflex.js:388 Uncaught TypeError: Cannot read property 'completedOperations' of undefined [\#394](https://github.com/hopsoft/stimulus_reflex/issues/394)
20
+
21
+ **Merged pull requests:**
22
+
23
+ - Add dom\_id to the reflex [\#405](https://github.com/hopsoft/stimulus_reflex/pull/405) ([hopsoft](https://github.com/hopsoft))
24
+ - Check package version from yarn.lock if node\_modules folder is not av… [\#403](https://github.com/hopsoft/stimulus_reflex/pull/403) ([RolandStuder](https://github.com/RolandStuder))
25
+
26
+ ## [v3.4.0.pre8](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre8) (2020-12-02)
27
+
28
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre7...v3.4.0.pre8)
6
29
 
7
30
  **Closed issues:**
8
31
 
@@ -98,7 +121,6 @@
98
121
  - Add guard clause to return valid empty form data [\#354](https://github.com/hopsoft/stimulus_reflex/pull/354) ([julianrubisch](https://github.com/julianrubisch))
99
122
  - simplify xpath functions [\#353](https://github.com/hopsoft/stimulus_reflex/pull/353) ([leastbad](https://github.com/leastbad))
100
123
  - pass reflex id to reflex [\#352](https://github.com/hopsoft/stimulus_reflex/pull/352) ([joshleblanc](https://github.com/joshleblanc))
101
- - Fix page morphs inside Rails engines [\#344](https://github.com/hopsoft/stimulus_reflex/pull/344) ([leastbad](https://github.com/leastbad))
102
124
 
103
125
  ## [v3.4.0.pre2](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre2) (2020-11-06)
104
126
 
@@ -140,12 +162,12 @@
140
162
  - ActionController::RoutingError with Rails 6 Engines [\#342](https://github.com/hopsoft/stimulus_reflex/issues/342)
141
163
  - Wrong input name parsing [\#321](https://github.com/hopsoft/stimulus_reflex/issues/321)
142
164
  - Stimulus' controllers are not reconnecting after reflex, why? [\#314](https://github.com/hopsoft/stimulus_reflex/issues/314)
143
- - Rendering issue [\#289](https://github.com/hopsoft/stimulus_reflex/issues/289)
144
165
  - Documentation Request for a Rails 6.x app with 5.2 defaults [\#265](https://github.com/hopsoft/stimulus_reflex/issues/265)
145
166
 
146
167
  **Merged pull requests:**
147
168
 
148
169
  - \[docs\] StimulusReflex.debug= on left hand side [\#348](https://github.com/hopsoft/stimulus_reflex/pull/348) ([drnic](https://github.com/drnic))
170
+ - Fix page morphs inside Rails engines [\#344](https://github.com/hopsoft/stimulus_reflex/pull/344) ([leastbad](https://github.com/leastbad))
149
171
  - Use Webpacker folder if available [\#343](https://github.com/hopsoft/stimulus_reflex/pull/343) ([coorasse](https://github.com/coorasse))
150
172
  - feat: create a more robust package.json [\#340](https://github.com/hopsoft/stimulus_reflex/pull/340) ([ParamagicDev](https://github.com/ParamagicDev))
151
173
  - Make StimulusReflex configurable and add an initializer [\#339](https://github.com/hopsoft/stimulus_reflex/pull/339) ([RolandStuder](https://github.com/RolandStuder))
@@ -261,6 +283,7 @@
261
283
  - Fix argument of type object always being assigned to options [\#279](https://github.com/hopsoft/stimulus_reflex/pull/279) ([shawnleong](https://github.com/shawnleong))
262
284
  - Simplify devise authentication logic \(in docs\) [\#276](https://github.com/hopsoft/stimulus_reflex/pull/276) ([inner-whisper](https://github.com/inner-whisper))
263
285
  - Bump lodash from 4.17.15 to 4.17.19 in /javascript [\#275](https://github.com/hopsoft/stimulus_reflex/pull/275) ([dependabot[bot]](https://github.com/apps/dependabot))
286
+ - Fix selector morphs for updating partials and ViewComponents [\#262](https://github.com/hopsoft/stimulus_reflex/pull/262) ([leastbad](https://github.com/leastbad))
264
287
 
265
288
  ## [v3.3.0.pre2](https://github.com/hopsoft/stimulus_reflex/tree/v3.3.0.pre2) (2020-07-17)
266
289
 
@@ -285,10 +308,6 @@
285
308
 
286
309
  [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.pre0...v3.3.0.pre1)
287
310
 
288
- **Merged pull requests:**
289
-
290
- - Fix selector morphs for updating partials and ViewComponents [\#262](https://github.com/hopsoft/stimulus_reflex/pull/262) ([leastbad](https://github.com/leastbad))
291
-
292
311
  ## [v3.3.0.pre0](https://github.com/hopsoft/stimulus_reflex/tree/v3.3.0.pre0) (2020-07-04)
293
312
 
294
313
  [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.3...v3.3.0.pre0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.4.0.pre8)
4
+ stimulus_reflex (3.4.0.pre9)
5
5
  cable_ready (>= 4.4)
6
6
  nokogiri
7
7
  rack
@@ -11,64 +11,68 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (6.0.3.4)
15
- actionpack (= 6.0.3.4)
14
+ actioncable (6.1.0)
15
+ actionpack (= 6.1.0)
16
+ activesupport (= 6.1.0)
16
17
  nio4r (~> 2.0)
17
18
  websocket-driver (>= 0.6.1)
18
- actionmailbox (6.0.3.4)
19
- actionpack (= 6.0.3.4)
20
- activejob (= 6.0.3.4)
21
- activerecord (= 6.0.3.4)
22
- activestorage (= 6.0.3.4)
23
- activesupport (= 6.0.3.4)
19
+ actionmailbox (6.1.0)
20
+ actionpack (= 6.1.0)
21
+ activejob (= 6.1.0)
22
+ activerecord (= 6.1.0)
23
+ activestorage (= 6.1.0)
24
+ activesupport (= 6.1.0)
24
25
  mail (>= 2.7.1)
25
- actionmailer (6.0.3.4)
26
- actionpack (= 6.0.3.4)
27
- actionview (= 6.0.3.4)
28
- activejob (= 6.0.3.4)
26
+ actionmailer (6.1.0)
27
+ actionpack (= 6.1.0)
28
+ actionview (= 6.1.0)
29
+ activejob (= 6.1.0)
30
+ activesupport (= 6.1.0)
29
31
  mail (~> 2.5, >= 2.5.4)
30
32
  rails-dom-testing (~> 2.0)
31
- actionpack (6.0.3.4)
32
- actionview (= 6.0.3.4)
33
- activesupport (= 6.0.3.4)
34
- rack (~> 2.0, >= 2.0.8)
33
+ actionpack (6.1.0)
34
+ actionview (= 6.1.0)
35
+ activesupport (= 6.1.0)
36
+ rack (~> 2.0, >= 2.0.9)
35
37
  rack-test (>= 0.6.3)
36
38
  rails-dom-testing (~> 2.0)
37
39
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
38
- actiontext (6.0.3.4)
39
- actionpack (= 6.0.3.4)
40
- activerecord (= 6.0.3.4)
41
- activestorage (= 6.0.3.4)
42
- activesupport (= 6.0.3.4)
40
+ actiontext (6.1.0)
41
+ actionpack (= 6.1.0)
42
+ activerecord (= 6.1.0)
43
+ activestorage (= 6.1.0)
44
+ activesupport (= 6.1.0)
43
45
  nokogiri (>= 1.8.5)
44
- actionview (6.0.3.4)
45
- activesupport (= 6.0.3.4)
46
+ actionview (6.1.0)
47
+ activesupport (= 6.1.0)
46
48
  builder (~> 3.1)
47
49
  erubi (~> 1.4)
48
50
  rails-dom-testing (~> 2.0)
49
51
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
50
- activejob (6.0.3.4)
51
- activesupport (= 6.0.3.4)
52
+ activejob (6.1.0)
53
+ activesupport (= 6.1.0)
52
54
  globalid (>= 0.3.6)
53
- activemodel (6.0.3.4)
54
- activesupport (= 6.0.3.4)
55
- activerecord (6.0.3.4)
56
- activemodel (= 6.0.3.4)
57
- activesupport (= 6.0.3.4)
58
- activestorage (6.0.3.4)
59
- actionpack (= 6.0.3.4)
60
- activejob (= 6.0.3.4)
61
- activerecord (= 6.0.3.4)
55
+ activemodel (6.1.0)
56
+ activesupport (= 6.1.0)
57
+ activerecord (6.1.0)
58
+ activemodel (= 6.1.0)
59
+ activesupport (= 6.1.0)
60
+ activestorage (6.1.0)
61
+ actionpack (= 6.1.0)
62
+ activejob (= 6.1.0)
63
+ activerecord (= 6.1.0)
64
+ activesupport (= 6.1.0)
62
65
  marcel (~> 0.3.1)
63
- activesupport (6.0.3.4)
66
+ mimemagic (~> 0.3.2)
67
+ activesupport (6.1.0)
64
68
  concurrent-ruby (~> 1.0, >= 1.0.2)
65
- i18n (>= 0.7, < 2)
66
- minitest (~> 5.1)
67
- tzinfo (~> 1.1)
68
- zeitwerk (~> 2.2, >= 2.2.2)
69
+ i18n (>= 1.6, < 2)
70
+ minitest (>= 5.1)
71
+ tzinfo (~> 2.0)
72
+ zeitwerk (~> 2.3)
69
73
  ast (2.4.1)
70
74
  builder (3.2.4)
71
- cable_ready (4.4.3)
75
+ cable_ready (4.4.5)
72
76
  rails (>= 5.2)
73
77
  coderay (1.1.3)
74
78
  concurrent-ruby (1.1.7)
@@ -104,32 +108,32 @@ GEM
104
108
  rack (2.2.3)
105
109
  rack-test (1.1.0)
106
110
  rack (>= 1.0, < 3)
107
- rails (6.0.3.4)
108
- actioncable (= 6.0.3.4)
109
- actionmailbox (= 6.0.3.4)
110
- actionmailer (= 6.0.3.4)
111
- actionpack (= 6.0.3.4)
112
- actiontext (= 6.0.3.4)
113
- actionview (= 6.0.3.4)
114
- activejob (= 6.0.3.4)
115
- activemodel (= 6.0.3.4)
116
- activerecord (= 6.0.3.4)
117
- activestorage (= 6.0.3.4)
118
- activesupport (= 6.0.3.4)
119
- bundler (>= 1.3.0)
120
- railties (= 6.0.3.4)
111
+ rails (6.1.0)
112
+ actioncable (= 6.1.0)
113
+ actionmailbox (= 6.1.0)
114
+ actionmailer (= 6.1.0)
115
+ actionpack (= 6.1.0)
116
+ actiontext (= 6.1.0)
117
+ actionview (= 6.1.0)
118
+ activejob (= 6.1.0)
119
+ activemodel (= 6.1.0)
120
+ activerecord (= 6.1.0)
121
+ activestorage (= 6.1.0)
122
+ activesupport (= 6.1.0)
123
+ bundler (>= 1.15.0)
124
+ railties (= 6.1.0)
121
125
  sprockets-rails (>= 2.0.0)
122
126
  rails-dom-testing (2.0.3)
123
127
  activesupport (>= 4.2.0)
124
128
  nokogiri (>= 1.6)
125
129
  rails-html-sanitizer (1.3.0)
126
130
  loofah (~> 2.3)
127
- railties (6.0.3.4)
128
- actionpack (= 6.0.3.4)
129
- activesupport (= 6.0.3.4)
131
+ railties (6.1.0)
132
+ actionpack (= 6.1.0)
133
+ activesupport (= 6.1.0)
130
134
  method_source
131
135
  rake (>= 0.8.7)
132
- thor (>= 0.20.3, < 2.0)
136
+ thor (~> 1.0)
133
137
  rainbow (3.0.0)
134
138
  rake (13.0.1)
135
139
  redis (4.2.5)
@@ -157,15 +161,14 @@ GEM
157
161
  actionpack (>= 4.0)
158
162
  activesupport (>= 4.0)
159
163
  sprockets (>= 3.0.0)
160
- standard (0.10.1)
164
+ standard (0.10.2)
161
165
  rubocop (= 1.4.2)
162
166
  rubocop-performance (= 1.9.1)
163
167
  standardrb (1.0.0)
164
168
  standard
165
169
  thor (1.0.1)
166
- thread_safe (0.3.6)
167
- tzinfo (1.2.8)
168
- thread_safe (~> 0.1)
170
+ tzinfo (2.0.3)
171
+ concurrent-ruby (~> 1.0)
169
172
  unicode-display_width (1.7.0)
170
173
  websocket-driver (0.7.3)
171
174
  websocket-extensions (>= 0.1.0)
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-brightgreen.svg" target="_blank" />
12
12
  </a>
13
13
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/" target="_blank">
14
- <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1600-brightgreen.svg?style=flat" />
14
+ <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1632-brightgreen.svg?style=flat" />
15
15
  </a>
16
16
  <a href="https://docs.stimulusreflex.com/" target="_blank">
17
17
  <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
@@ -49,11 +49,33 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
49
49
  rescue => invoke_error
50
50
  message = exception_message_with_backtrace(invoke_error)
51
51
  body = "Reflex #{target} failed: #{message} [#{url}]"
52
+
52
53
  if reflex
53
54
  reflex.rescue_with_handler(invoke_error)
54
55
  reflex.broadcast_message subject: "error", body: body, data: data, error: invoke_error
55
56
  else
56
57
  puts "\e[31m#{body}\e[0m"
58
+
59
+ if body.to_s.include? "No route matches"
60
+ initializer_path = Rails.root.join("config", "initializers", "stimulus_reflex.rb")
61
+
62
+ puts <<~NOTE
63
+ \e[33mNOTE: StimulusReflex failed to locate a matching route and could not re-render the page.
64
+
65
+ If your app uses Rack middleware to rewrite part of the request path, you must enable those middleware modules in StimulusReflex.
66
+ The StimulusReflex initializer should be located at #{initializer_path}, or you can generate it with:
67
+
68
+ $ bundle exec rails generate stimulus_reflex:config
69
+
70
+ Configure any required middleware:
71
+
72
+ StimulusReflex.configure do |config|
73
+ config.middleware.use FirstRackMiddleware
74
+ config.middleware.use SecondRackMiddleware
75
+ end\e[0m
76
+
77
+ NOTE
78
+ end
57
79
  end
58
80
  return
59
81
  end
@@ -15,6 +15,15 @@ StimulusReflex.configure do |config|
15
15
  # Available colors: red, green, yellow, blue, magenta, cyan, white
16
16
  # You can also use attributes from your ActionCable Connection's identifiers that resolve to valid ActiveRecord models
17
17
  # eg. if your connection is `identified_by :current_user` and your User model has an email attribute, you can access r.email (it will display `-` if the user isn't logged in)
18
+ # Learn more at: https://docs.stimulusreflex.com/troubleshooting#stimulusreflex-logging
18
19
 
19
20
  # config.logging = proc { "[#{session_id}] #{operation_counter.magenta} #{reflex_info.green} -> #{selector.cyan} via #{mode} Morph (#{operation.yellow})" }
21
+
22
+ # Optimized for speed, StimulusReflex doesn't enable Rack middleware by default.
23
+ # If you are using Page Morphs and your app uses Rack middleware to rewrite part of the request path, you must enable those middleware modules in StimulusReflex.
24
+ #
25
+ # Learn more about registering Rack middleware in Rails here: https://guides.rubyonrails.org/rails_on_rack.html#configuring-middleware-stack
26
+
27
+ # config.middleware.use FirstRackMiddleware
28
+ # config.middleware.use SecondRackMiddleware
20
29
  end
@@ -24,7 +24,7 @@ require "stimulus_reflex/logger"
24
24
  module StimulusReflex
25
25
  class Engine < Rails::Engine
26
26
  initializer "stimulus_reflex.sanity_check" do
27
- SanityChecker.check!
27
+ SanityChecker.check! unless Rails.env.production?
28
28
  end
29
29
  end
30
30
  end
@@ -1,12 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module StimulusReflex
2
4
  class CableReadyChannels
3
5
  stimulus_reflex_channel_methods = CableReady::Channels.instance.operations.keys + [:broadcast, :broadcast_to]
4
- delegate(*stimulus_reflex_channel_methods, to: "@stimulus_reflex_channel")
5
- delegate :[], to: "@cable_ready_channels"
6
+ delegate(*stimulus_reflex_channel_methods, to: "stimulus_reflex_channel")
7
+ delegate :[], to: "cable_ready_channels"
6
8
 
7
9
  def initialize(stream_name)
8
- @cable_ready_channels = CableReady::Channels.instance
9
- @stimulus_reflex_channel = @cable_ready_channels[stream_name]
10
+ @stream_name = stream_name
11
+ end
12
+
13
+ def cable_ready_channels
14
+ CableReady::Channels.instance
15
+ end
16
+
17
+ def stimulus_reflex_channel
18
+ CableReady::Channels.instance[@stream_name]
10
19
  end
11
20
  end
12
21
  end
@@ -14,7 +14,7 @@ module StimulusReflex
14
14
  end
15
15
 
16
16
  class Configuration
17
- attr_accessor :on_failed_sanity_checks, :parent_channel, :logging
17
+ attr_accessor :on_failed_sanity_checks, :parent_channel, :logging, :middleware
18
18
 
19
19
  DEFAULT_LOGGING = proc { "[#{session_id}] #{operation_counter.magenta} #{reflex_info.green} -> #{selector.cyan} via #{mode} Morph (#{operation.yellow})" }
20
20
 
@@ -22,6 +22,7 @@ module StimulusReflex
22
22
  @on_failed_sanity_checks = :exit
23
23
  @parent_channel = "ApplicationCable::Channel"
24
24
  @logging = DEFAULT_LOGGING
25
+ @middleware = ActionDispatch::MiddlewareStack.new
25
26
  end
26
27
  end
27
28
  end
@@ -53,6 +53,7 @@ class StimulusReflex::Reflex
53
53
  delegate :broadcast, :broadcast_message, to: :broadcaster
54
54
  delegate :reflex_id, :reflex_controller, :xpath, :c_xpath, :permanent_attribute_name, to: :client_attributes
55
55
  delegate :render, to: :controller_class
56
+ delegate :dom_id, to: "ActionView::RecordIdentifier"
56
57
 
57
58
  def initialize(channel, url: nil, element: nil, selectors: [], method_name: nil, params: {}, client_attributes: {})
58
59
  @channel = channel
@@ -87,6 +88,14 @@ class StimulusReflex::Reflex
87
88
  )
88
89
 
89
90
  env = connection.env.merge(mock_env)
91
+
92
+ middleware = StimulusReflex.config.middleware
93
+
94
+ if middleware.any?
95
+ stack = middleware.build(Rails.application.routes)
96
+ stack.call(env)
97
+ end
98
+
90
99
  req = ActionDispatch::Request.new(env)
91
100
 
92
101
  path_params = Rails.application.routes.recognize_path_with_request(req, url, req.env[:extras] || {})
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class StimulusReflex::SanityChecker
4
+ NODE_VERSION_FORMAT = /(\d+\.\d+\.\d+.*):/
4
5
  JSON_VERSION_FORMAT = /(\d+\.\d+\.\d+.*)"/
5
6
 
6
7
  class << self
@@ -86,6 +87,8 @@ class StimulusReflex::SanityChecker
86
87
  def find_javascript_package_version
87
88
  if (match = search_file(package_json_path, regex: /version/))
88
89
  match[JSON_VERSION_FORMAT, 1]
90
+ elsif (match = search_file(yarn_lock_path, regex: /^stimulus_reflex/))
91
+ match[NODE_VERSION_FORMAT, 1]
89
92
  end
90
93
  end
91
94
 
@@ -98,6 +101,10 @@ class StimulusReflex::SanityChecker
98
101
  Rails.root.join("node_modules", "stimulus_reflex", "package.json")
99
102
  end
100
103
 
104
+ def yarn_lock_path
105
+ Rails.root.join("yarn.lock")
106
+ end
107
+
101
108
  def initializer_path
102
109
  @_initializer_path ||= Rails.root.join("config", "initializers", "stimulus_reflex.rb")
103
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusReflex
4
- VERSION = "3.4.0.pre8"
4
+ VERSION = "3.4.0.pre9"
5
5
  end
@@ -6,9 +6,10 @@ require "stimulus_reflex/version"
6
6
  namespace :stimulus_reflex do
7
7
  desc "Install StimulusReflex in this application"
8
8
  task install: :environment do
9
- system "bundle exec rails webpacker:install:stimulus"
9
+ system "rails dev:cache" unless Rails.root.join("tmp", "caching-dev.txt").exist?
10
10
  gem_version = StimulusReflex::VERSION.gsub(".pre", "-pre")
11
11
  system "yarn add stimulus_reflex@#{gem_version}"
12
+ system "bundle exec rails webpacker:install:stimulus"
12
13
  main_folder = defined?(Webpacker) ? Webpacker.config.source_path.to_s.gsub("#{Rails.root}/", "") : "app/javascript"
13
14
 
14
15
  FileUtils.mkdir_p Rails.root.join("#{main_folder}/controllers"), verbose: true
@@ -39,7 +40,7 @@ namespace :stimulus_reflex do
39
40
 
40
41
  unless lines.find { |line| line.start_with?("import controller") }
41
42
  matches = lines.select { |line| line =~ /\A(require|import)/ }
42
- lines.insert lines.index(matches.last).to_i + 1, "import controller from './application_controller'\n"
43
+ lines.insert lines.index(matches.last).to_i + 1, "import controller from '../controllers/application_controller'\n"
43
44
  end
44
45
 
45
46
  initialize_line = lines.find { |line| line.start_with?("StimulusReflex.initialize") }
@@ -67,6 +68,10 @@ namespace :stimulus_reflex do
67
68
  system "bundle exec rails generate stimulus_reflex example"
68
69
  puts "Generating default StimulusReflex configuration file into your application config/initializers directory"
69
70
  system "bundle exec rails generate stimulus_reflex:config"
70
- system "rails dev:cache" unless Rails.root.join("tmp", "caching-dev.txt").exist?
71
+
72
+ puts
73
+ puts "StimulusReflex and CableReady have been successfully installed!"
74
+ puts "Go to https://docs.stimulusreflex.com/quickstart if you need help getting started."
75
+ puts
71
76
  end
72
77
  end