turbo-mount 0.4.0 → 0.4.1

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: a1e390ef4fc7a3d329693a294437fa8f5d27c9157654b3a9b21621b26dd6c7c5
4
- data.tar.gz: 591ea18f8b02da05da9a9d6dba5249eccdf01ec2b4d00477341df76166c0bd7d
3
+ metadata.gz: 0b29826ddb780be9b604f24aa2a2a4a8635b1dc95106315baeef4323ace52172
4
+ data.tar.gz: 8f70abb8e1a8a44d26c294f30173b366502e4fe7f6a6e55c4dfe87778f59d883
5
5
  SHA512:
6
- metadata.gz: fd306af35603685bebc4c2a7ef0fe31909fa56b521f0808562aeee3f8c90f2d5098aa846e6633356b716ced5aa51b8c5e6131252b97c5b91ccf14242aa90baff
7
- data.tar.gz: 8a7221dad2c96c5c8c873e841a4007f1b45bcf6adada668af008692b035589590a230c411756f1cac86918d74521d0f6cec47d8c2125feddb1b5bfca91187ec3
6
+ metadata.gz: aaf7c5d7d5813d7a34137103cee1701ba05400bb3b60e1a5c72da1a261cf4930fa2566c7cba4184740cb4dc0ae91ff28c7ce724d8aca3015b46b807dbe480afa
7
+ data.tar.gz: 72dd49789b076a28aa63df75a607438998748dd69793dbd2db82d300c4022007e567b88342755aa6212d5402b4be86579c9d50549f2941e436bbdf76600441d1
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.1] - 2024-11-26
11
+
12
+ ### Added
13
+
14
+ - Support Shakapacker in the installation script. ([@skryukov])
15
+
16
+ ### Fixed
17
+
18
+ - Fix installation script interactive mode. ([@skryukov])
19
+ - Fix installation script dependencies installation. ([@skryukov])
20
+
10
21
  ## [0.4.0] - 2024-11-03
11
22
 
12
23
  ### Added
@@ -82,7 +93,8 @@ and this project adheres to [Semantic Versioning].
82
93
  [@jkogara]: https://github.com/jkogara
83
94
  [@skryukov]: https://github.com/skryukov
84
95
 
85
- [Unreleased]: https://github.com/skryukov/turbo-mount/compare/v0.4.0...HEAD
96
+ [Unreleased]: https://github.com/skryukov/turbo-mount/compare/v0.4.1...HEAD
97
+ [0.4.1]: https://github.com/skryukov/turbo-mount/compare/v0.4.0...v0.4.1
86
98
  [0.4.0]: https://github.com/skryukov/turbo-mount/compare/v0.3.3...v0.4.0
87
99
  [0.3.3]: https://github.com/skryukov/turbo-mount/compare/v0.3.2...v0.3.3
88
100
  [0.3.2]: https://github.com/skryukov/turbo-mount/compare/v0.3.1...v0.3.2
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  <p align="center">
2
- <img src="./assets/logo.svg" title="Turbo Mount logo" width="220" height="45">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
4
+ <img src="assets/logo.svg" title="Turbo Mount logo" width="220" height="45">
5
+ </picture>
3
6
  </p>
4
7
 
5
8
  <h1 align="center">Turbo Mount</h1>
@@ -20,6 +20,8 @@ module TurboMount
20
20
  def js_entrypoint
21
21
  if vite?
22
22
  js_file_path "entrypoints/application.js"
23
+ elsif shakapacker?
24
+ js_file_path "packs/application.js"
23
25
  else
24
26
  js_file_path "application.js"
25
27
  end
@@ -41,6 +43,10 @@ module TurboMount
41
43
  file?("config/vite.json") && Dir.glob(file_path("vite.config.*")).any?
42
44
  end
43
45
 
46
+ def shakapacker?
47
+ file?("config/shakapacker.yml") || file?("config/webpacker.yml")
48
+ end
49
+
44
50
  # Interactivity Helpers
45
51
  def ask(*)
46
52
  unless options[:interactive]
@@ -25,6 +25,9 @@ module TurboMount
25
25
  enum: JSPackageManager.package_managers,
26
26
  desc: "The package manager you want to use to install Turbo Mount"
27
27
 
28
+ class_option :interactive, type: :boolean, default: true,
29
+ desc: "Whether to prompt for optional installations"
30
+
28
31
  class_option :verbose, type: :boolean, default: false,
29
32
  desc: "Run the generator in verbose mode"
30
33
 
@@ -33,6 +36,7 @@ module TurboMount
33
36
 
34
37
  package_manager.validate!
35
38
 
39
+ create_initializer
36
40
  if package_manager.importmap?
37
41
  install_importmap
38
42
  else
@@ -44,35 +48,39 @@ module TurboMount
44
48
 
45
49
  private
46
50
 
47
- def install_nodejs
48
- package_manager.add_dependencies("turbo-mount", FRAMEWORKS[framework][:npm_packages])
49
-
51
+ def create_initializer
50
52
  say "Creating Turbo Mount initializer"
51
- template "turbo-mount.js", js_file_path("turbo-mount.js")
53
+
54
+ needs_alias = shakapacker? || package_manager.importmap?
55
+ initializer_path = needs_alias ? "turbo-mount-initializer.js" : "turbo-mount.js"
56
+ initializer_import = needs_alias ? %(import "turbo-mount-initializer"\n) : %(import "./turbo-mount"\n)
57
+
58
+ template "turbo-mount.js", js_file_path(initializer_path)
52
59
  begin
53
- append_to_file js_entrypoint, %(import "./turbo-mount"\n)
60
+ append_to_file js_entrypoint, initializer_import
54
61
  rescue
55
- say 'Could not find the application entrypoint, please add `import "./turbo-mount"` manually.', :yellow
62
+ say "Could not find the application entrypoint, please add `#{initializer_import.strip}` manually.", :yellow
56
63
  end
64
+ end
65
+
66
+ def install_nodejs
67
+ package_manager.add_dependencies("turbo-mount", FRAMEWORKS[framework]["npm_packages"])
68
+
57
69
  warn_about_vite_plugin if vite?
58
70
  end
59
71
 
60
72
  def install_importmap
61
- say "Creating Turbo Mount initializer"
62
- template "turbo-mount.js", js_file_path("turbo-mount-initializer.js")
63
- append_to_file "app/javascript/application.js", %(import "turbo-mount-initializer"\n)
64
-
65
73
  say "Pinning Turbo Mount to the importmap"
66
74
  append_to_file "config/importmap.rb", %(pin "turbo-mount", to: "turbo-mount.min.js"\n)
67
75
  append_to_file "config/importmap.rb", %(pin "turbo-mount/#{framework}", to: "turbo-mount/#{framework}.min.js"\n)
68
76
  append_to_file "config/importmap.rb", %(pin "turbo-mount-initializer"\n)
69
77
 
70
78
  say "Pinning framework dependencies to the importmap"
71
- package_manager.add_dependencies(FRAMEWORKS[framework][:pins])
79
+ package_manager.add_dependencies(FRAMEWORKS[framework]["pins"])
72
80
  end
73
81
 
74
82
  def warn_about_vite_plugin
75
- say "Make sure to install and add #{FRAMEWORKS[framework][:vite_plugin]} to your Vite config", :yellow
83
+ say "Make sure to install and add #{FRAMEWORKS[framework]["vite_plugin"]} to your Vite config", :yellow
76
84
  end
77
85
 
78
86
  def package_manager
@@ -80,7 +88,7 @@ module TurboMount
80
88
  end
81
89
 
82
90
  def extension
83
- FRAMEWORKS[framework][:extension]
91
+ FRAMEWORKS[framework]["extension"]
84
92
  end
85
93
 
86
94
  def framework
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Turbo
4
4
  module Mount
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-mount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-03 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.5.17
87
+ rubygems_version: 3.5.23
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Use React, Vue, Svelte, and other components with Hotwire.