turbo-rails 0.6.0 → 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: 42d7a658511c698c83b4e41853f96f5b2534a9ee81b89500044a22d6695a5150
4
- data.tar.gz: 46e9abb9a01e4c9b50d2c2b704ff0e522a7231496b58d7acbc78303cdef67486
3
+ metadata.gz: 2608402a944433e82b78b6aed5ac64e54579566e23a5a3b1a6837a695c7031ff
4
+ data.tar.gz: b342da8a4a13bc4b9fbbec5ee1a06afff0db881e3ab4103adba4c47188dd351a
5
5
  SHA512:
6
- metadata.gz: be906021b12ba905c7ce316900cb28db1ec22cbec561c2e009758a58cb059c82984862bae1f045c2f60b1db9fd396ebb2c88ba07c08a2871d1f39556f67cd2b1
7
- data.tar.gz: de3c17c9f07971421add4c6038f385b609d465eb939f1860900c635b35b72b65ebbbea030a2d45722bb6bda86b2b38e5d794c005e063698c3ec63478fd3dd083
6
+ metadata.gz: 9183cb91a6ce9b2bc0b401ec35b7a3ff835b30d2732c96c6ab8db6ef23a3276e80e08ade5648ceb118c00a8cb5b2b07bb87e6ac8451224bf72885d12fcde2204
7
+ data.tar.gz: 0665d67d6cb734a670c12412588e23359a63204a72d92fce01a940e19b34e3e8a4217acf42e88b61d60b0700b6bc36ed2fba3e533140ea69503a7a047597fea0
data/README.md CHANGED
@@ -38,7 +38,7 @@ The JavaScript for Turbo can either be run through the asset pipeline, which is
38
38
  2. Run `./bin/bundle install`
39
39
  3. Run `./bin/rails turbo:install`
40
40
 
41
- Running `turbo:install` will install through NPM if Webpacker is installed in the application. Otherwise the asset pipeline version is used.
41
+ Running `turbo:install` will install through NPM if Webpacker is installed in the application. Otherwise the asset pipeline version is used. To use the asset pipeline version, you must have `importmap-rails` installed first and listed higher in the Gemfile.
42
42
 
43
43
  If you're using Webpack and need to use the cable consumer, you can import [`cable`](https://github.com/hotwired/turbo-rails/blob/main/app/javascript/turbo/cable.js) (`import { cable } from "@hotwired/turbo-rails"`), but ensure that your application actually *uses* the members it `import`s when using this style (see [turbo-rails#48](https://github.com/hotwired/turbo-rails/issues/48)).
44
44
 
@@ -62,7 +62,7 @@ Turbo can coexist with Rails UJS, but you need to take a series of upgrade steps
62
62
 
63
63
  * To run the Rails tests: `bundle exec rake`.
64
64
  * To install dependencies: `bundle install`
65
- * To prepare the test database: `cd tests/dummy; RAILS_ENV=test ./bin/rails db:migrate`
65
+ * To prepare the test database: `cd test/dummy; RAILS_ENV=test ./bin/rails db:migrate`
66
66
  * To compile the JavaScript for the asset pipeline: `yarn build`
67
67
 
68
68
 
@@ -1,26 +1,26 @@
1
- APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
2
- IMPORTMAP_PATH = Rails.root.join("app/assets/javascripts/importmap.json.erb")
1
+ APP_JS_PATH = Rails.root.join("app/javascript/application.js")
3
2
  CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
3
+ IMPORTMAP_PATH = Rails.root.join("config/importmap.rb")
4
4
 
5
- if APPLICATION_LAYOUT_PATH.exist?
6
- say "Yield head in application layout for cache helper"
7
- insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= yield :head %>", before: /\s*<\/head>/
8
-
9
- if APPLICATION_LAYOUT_PATH.read =~ /stimulus/
10
- say "Add Turbo include tags in application layout"
11
- insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module-shim" %>), after: /<%= stimulus_include_tags %>/
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
12
13
 
13
- if IMPORTMAP_PATH.exist?
14
- say "Add Turbo to importmap"
15
- insert_into_file IMPORTMAP_PATH, %( "turbo": "<%= asset_path "turbo" %>",\n), after: / "imports": {\s*\n/
16
- end
17
- else
18
- say "Add Turbo include tags in application layout"
19
- insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module" %>), before: /\s*<\/head>/
20
- end
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"
21
20
  else
22
- say "Default application.html.erb is missing!", :red
23
- say %( Add <%= javascript_include_tag("turbo", type: "module-shim") %> and <%= yield :head %> within the <head> tag after Stimulus includes in your custom layout.)
21
+ say <<~INSTRUCTIONS, :red
22
+ You must add @hotwire/turbo-rails to your importmap to reference them via ESM.
23
+ INSTRUCTIONS
24
24
  end
25
25
 
26
26
  if CABLE_CONFIG_PATH.exist?
@@ -32,5 +32,3 @@ if CABLE_CONFIG_PATH.exist?
32
32
  else
33
33
  say 'ActionCable config file (config/cable.yml) is missing. Uncomment "gem \'redis\'" in your Gemfile and create config/cable.yml to use the Turbo Streams broadcast feature.'
34
34
  end
35
-
36
- say "Turbo successfully installed ⚡️", :green
@@ -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"
@@ -25,5 +15,3 @@ if CABLE_CONFIG_PATH.exist?
25
15
  else
26
16
  say 'ActionCable config file (config/cable.yml) is missing. Uncomment "gem \'redis\'" in your Gemfile and create config/cable.yml to use the Turbo Streams broadcast feature.'
27
17
  end
28
-
29
- say "Turbo successfully installed ⚡️", :green
data/lib/turbo/engine.rb CHANGED
@@ -22,7 +22,7 @@ module Turbo
22
22
 
23
23
  initializer "turbo.assets" do
24
24
  if Rails.application.config.respond_to?(:assets)
25
- Rails.application.config.assets.precompile += %w( turbo )
25
+ Rails.application.config.assets.precompile += %w( turbo.js )
26
26
  end
27
27
  end
28
28
 
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "0.6.0"
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.6.0
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-07-21 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: []