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 +4 -4
- data/README.md +2 -2
- data/lib/install/turbo_with_asset_pipeline.rb +19 -21
- data/lib/install/turbo_with_webpacker.rb +3 -15
- data/lib/turbo/engine.rb +1 -1
- data/lib/turbo/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2608402a944433e82b78b6aed5ac64e54579566e23a5a3b1a6837a695c7031ff
|
4
|
+
data.tar.gz: b342da8a4a13bc4b9fbbec5ee1a06afff0db881e3ab4103adba4c47188dd351a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
6
|
-
say "
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
23
|
-
|
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
|
-
|
2
|
-
|
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
|
-
|
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
data/lib/turbo/version.rb
CHANGED
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.
|
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-
|
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: []
|