turbo-rails 0.7.10 → 0.7.11

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: 41cfe42f850783258d151d4d6ed872633cbb2a7f2ba3c20ad434af326c65dd15
4
- data.tar.gz: cff176c51977f6c1ba19c31eb36d97ea1958394e7fcde6a489f0d53ec9a74b3b
3
+ metadata.gz: 0fe3ad5cd094491982825ff80d21c619aab81bbcbe7e07168e467beeb3daa493
4
+ data.tar.gz: 757f2faa9d39389014fc277ef75d3c806c9864b1deb87f6efae5118c604cf89b
5
5
  SHA512:
6
- metadata.gz: 6a8c79d8a32ce7a36aa3f289cd222600d3040bdd5cebaca4836c2fb659ac6e6d847ab02299290429b434a530b7397d9580628edaaba13b088e59c641174ab994
7
- data.tar.gz: 58eea1099a495e6987a8197630b9c9e6386af8e2016d0cceb92555ca2ce5fba19e6f32eba2244a14751ef9879b92c6793fdc1e1dd6e0b639678ed4c757680a47
6
+ metadata.gz: e38bd507e3eaeeccd3e8e570e3341cdc8ae27074ba03d3e509605a13f3df4188bd54250bbbb8f6161e3d3e261e5ae6edd928d3fb2aac7fd8d9ede9e7c1810717
7
+ data.tar.gz: 77f0a351ce8ab0cca1bc69413a508d6d8b790f61e18623ae16aad7d929536baa4f8c75b6407e6752d5301d022f0b49472c4376506181d1ffd31ed91b033459a2
data/README.md CHANGED
@@ -50,7 +50,7 @@ The JavaScript for Turbo can either be run through the asset pipeline, which is
50
50
 
51
51
  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.
52
52
 
53
- 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)).
53
+ If you're using node 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)).
54
54
 
55
55
  The `Turbo` instance is automatically assigned to `window.Turbo` upon import:
56
56
 
@@ -0,0 +1,5 @@
1
+ say "Import Turbo"
2
+ append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
3
+
4
+ say "Pin Turbo"
5
+ append_to_file "config/importmap.rb", %(pin "@hotwired/turbo-rails", to: "turbo.js"\n)
@@ -0,0 +1,9 @@
1
+ if (js_entrypoint_path = Rails.root.join("app/javascript/application.js")).exist?
2
+ say "Import Turbo"
3
+ append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
4
+ else
5
+ say "You must import @hotwired/turbo-rails in your JavaScript entrypoint file", :red
6
+ end
7
+
8
+ say "Install Turbo"
9
+ run "yarn add @hotwired/turbo-rails"
@@ -17,23 +17,25 @@ end
17
17
  namespace :turbo do
18
18
  desc "Install Turbo into the app"
19
19
  task :install do
20
- if defined?(Webpacker::Engine)
21
- Rake::Task["turbo:install:webpacker"].invoke
20
+ if Rails.root.join("config/importmap.rb").exist?
21
+ Rake::Task["turbo:install:importmap"].invoke
22
+ elsif Rails.root.join("package.json").exist?
23
+ Rake::Task["turbo:install:node"].invoke
22
24
  else
23
- Rake::Task["turbo:install:asset_pipeline"].invoke
25
+ puts "You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem."
24
26
  end
25
27
  end
26
28
 
27
29
  namespace :install do
28
30
  desc "Install Turbo into the app with asset pipeline"
29
- task :asset_pipeline do
30
- run_turbo_install_template "turbo_with_asset_pipeline"
31
+ task :importmap do
32
+ run_turbo_install_template "turbo_with_importmap"
31
33
  switch_on_redis_if_available
32
34
  end
33
35
 
34
36
  desc "Install Turbo into the app with webpacker"
35
- task :webpacker do
36
- run_turbo_install_template "turbo_with_webpacker"
37
+ task :node do
38
+ run_turbo_install_template "turbo_with_node"
37
39
  switch_on_redis_if_available
38
40
  end
39
41
 
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "0.7.10"
2
+ VERSION = "0.7.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-09-01 00:00:00.000000000 Z
13
+ date: 2021-09-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -57,8 +57,8 @@ files:
57
57
  - app/models/turbo/streams/tag_builder.rb
58
58
  - config/routes.rb
59
59
  - lib/install/turbo_needs_redis.rb
60
- - lib/install/turbo_with_asset_pipeline.rb
61
- - lib/install/turbo_with_webpacker.rb
60
+ - lib/install/turbo_with_importmap.rb
61
+ - lib/install/turbo_with_node.rb
62
62
  - lib/tasks/turbo_tasks.rake
63
63
  - lib/turbo-rails.rb
64
64
  - lib/turbo/engine.rb
@@ -1,18 +0,0 @@
1
- if (app_js_path = Rails.root.join("app/javascript/application.js")).exist?
2
- say "Import turbo-rails in existing app/javascript/application.js"
3
- append_to_file app_js_path, %(import "@hotwired/turbo-rails"\n)
4
- else
5
- say <<~INSTRUCTIONS, :red
6
- You must import @hotwired/turbo-rails in your application.js.
7
- INSTRUCTIONS
8
- end
9
-
10
- if (importmap_path = Rails.root.join("config/importmap.rb")).exist?
11
- say "Pin @hotwired/turbo-rails in config/importmap.rb"
12
- append_to_file importmap_path.to_s, %(pin "@hotwired/turbo-rails", to: "turbo.js"\n)
13
- else
14
- say <<~INSTRUCTIONS, :red
15
- You must add @hotwired/turbo-rails to your importmap to reference them via ESM.
16
- Example: pin "@hotwired/turbo-rails", to: "turbo.js"
17
- INSTRUCTIONS
18
- end
@@ -1,5 +0,0 @@
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)
3
-
4
- say "Install Turbo"
5
- run "yarn add @hotwired/turbo-rails"