turbo-rails 0.7.2 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e401e540c8c64780f9984ed0d5120511777c47ca3b5d4c023f980469e10085e8
4
- data.tar.gz: 44d76bd4452ec01a2580d58e828616f2b634d8cb29a4470f082dd1c4ece899b5
3
+ metadata.gz: 2608402a944433e82b78b6aed5ac64e54579566e23a5a3b1a6837a695c7031ff
4
+ data.tar.gz: b342da8a4a13bc4b9fbbec5ee1a06afff0db881e3ab4103adba4c47188dd351a
5
5
  SHA512:
6
- metadata.gz: 5ff10bfdaecd3c50008a3f9ac63976be979b5a1208c0f2cf39b786889156bdaef33e863ad5e6cdb45e2cf2e61acb8672e42a177326d8b0155e7da7d0bd559006
7
- data.tar.gz: 77413a732f4014a257f724c117d47b07ebb3190dc70802348462a9bcd19c6a525e9d18a22c5342bab6f74b70f0f461b871e4c92a5650b5ec10ced95304c6e472
6
+ metadata.gz: 9183cb91a6ce9b2bc0b401ec35b7a3ff835b30d2732c96c6ab8db6ef23a3276e80e08ade5648ceb118c00a8cb5b2b07bb87e6ac8451224bf72885d12fcde2204
7
+ data.tar.gz: 0665d67d6cb734a670c12412588e23359a63204a72d92fce01a940e19b34e3e8a4217acf42e88b61d60b0700b6bc36ed2fba3e533140ea69503a7a047597fea0
@@ -1,8 +1,27 @@
1
- APP_JS_ROOT = Rails.root.join("app/assets/javascripts")
1
+ APP_JS_PATH = Rails.root.join("app/javascript/application.js")
2
2
  CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
3
+ IMPORTMAP_PATH = Rails.root.join("config/importmap.rb")
3
4
 
4
- say "Import turbo-rails in existing app/assets/javascripts/application.js"
5
- append_to_file APP_JS_ROOT.join("application.js"), %(import "@hotwired/turbo-rails"\n)
5
+ if APP_JS_PATH.exist?
6
+ say "Import turbo-rails in existing app/javascript/application.js"
7
+ append_to_file APP_JS_PATH, %(import "@hotwired/turbo-rails"\n)
8
+ else
9
+ say <<~INSTRUCTIONS, :red
10
+ You must import @hotwire/turbo-rails in your application.js.
11
+ INSTRUCTIONS
12
+ end
13
+
14
+ if IMPORTMAP_PATH.exist?
15
+ say "Pin @hotwired/turbo-rails in config/importmap.rb"
16
+ insert_into_file \
17
+ IMPORTMAP_PATH.to_s,
18
+ %( pin "@hotwired/turbo-rails", to: "turbo.js"\n\n),
19
+ after: "Rails.application.config.importmap.draw do\n"
20
+ else
21
+ say <<~INSTRUCTIONS, :red
22
+ You must add @hotwire/turbo-rails to your importmap to reference them via ESM.
23
+ INSTRUCTIONS
24
+ end
6
25
 
7
26
  if CABLE_CONFIG_PATH.exist?
8
27
  say "Enable redis in bundle"
@@ -1,20 +1,10 @@
1
- # Some Rails versions use commonJS(require) others use ESM(import).
2
- TURBOLINKS_REGEX = /(import .* from "turbolinks".*\n|require\("turbolinks"\).*\n)/.freeze
3
- ACTIVE_STORAGE_REGEX = /(import.*ActiveStorage|require.*@rails\/activestorage.*)/.freeze
4
- CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
5
-
6
- abort "❌ Webpacker not found. Exiting." unless defined?(Webpacker::Engine)
1
+ say "Appending Turbo setup code to #{Webpacker.config.source_entry_path}/application.js"
2
+ append_to_file "#{Webpacker.config.source_entry_path}/application.js", %(\nimport "@hotwired/turbo-rails"\n)
7
3
 
8
4
  say "Install Turbo"
9
5
  run "yarn add @hotwired/turbo-rails"
10
- insert_into_file "#{Webpacker.config.source_entry_path}/application.js", "import \"@hotwired/turbo-rails\"\n", before: ACTIVE_STORAGE_REGEX
11
6
 
12
- say "Remove Turbolinks"
13
- run "#{RbConfig.ruby} bin/bundle remove turbolinks"
14
- run "#{RbConfig.ruby} bin/bundle", capture: true
15
- run "#{RbConfig.ruby} bin/yarn remove turbolinks"
16
- gsub_file "#{Webpacker.config.source_entry_path}/application.js", TURBOLINKS_REGEX, ''
17
- gsub_file "#{Webpacker.config.source_entry_path}/application.js", /Turbolinks.start.*\n/, ''
7
+ CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
18
8
 
19
9
  if CABLE_CONFIG_PATH.exist?
20
10
  say "Enable redis in bundle"
data/lib/turbo/engine.rb CHANGED
@@ -26,12 +26,6 @@ module Turbo
26
26
  end
27
27
  end
28
28
 
29
- initializer "turbo.importmap" do
30
- if Rails.application.config.respond_to?(:importmap)
31
- Rails.application.config.importmap.pin "@hotwired/turbo-rails", to: "turbo.js"
32
- end
33
- end
34
-
35
29
  initializer "turbo.helpers", before: :load_config_initializers do
36
30
  ActiveSupport.on_load(:action_controller_base) do
37
31
  include Turbo::Streams::TurboStreamsTagBuilder, Turbo::Frames::FrameRequest, Turbo::Native::Navigation
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.4"
3
3
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
8
8
  - Javan Mahkmali
9
9
  - David Heinemeier Hansson
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-08-14 00:00:00.000000000 Z
13
+ date: 2021-08-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -26,7 +26,7 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: 6.0.0
29
- description:
29
+ description:
30
30
  email: david@loudthinking.com
31
31
  executables: []
32
32
  extensions: []
@@ -67,7 +67,7 @@ homepage: https://github.com/hotwired/turbo-rails
67
67
  licenses:
68
68
  - MIT
69
69
  metadata: {}
70
- post_install_message:
70
+ post_install_message:
71
71
  rdoc_options: []
72
72
  require_paths:
73
73
  - lib
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubygems_version: 3.1.4
86
- signing_key:
86
+ signing_key:
87
87
  specification_version: 4
88
88
  summary: The speed of a single-page web application without having to write any JavaScript.
89
89
  test_files: []