inertia_rails-contrib 0.2.0 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e6c5bccb1afe9ba7ccd8366ea492d47c947ec2c5787ca63b871f7303ea1c598
|
4
|
+
data.tar.gz: 3a6eeaabc968804dfc1d2cab8e9a5064332c7e96a6d480e0ae1d34fa4fd5b967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e275e6b29e124aeb22edf64f676112af27e037b720aafc7e22ea70eddd965491447fbb3a1e40f5f78c6117764c5327e5e809616c66f5603f7f787f9f4f54123
|
7
|
+
data.tar.gz: b419a7c886222c86ee2893c3741e1a6dbea59b47144723c7f187bb1ce386edbd551ad6df68eac99368db80566cd75f64256be087a04375ec6447b8f3b83dac46
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning].
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.2.1] - 2024-08-11
|
11
|
+
|
12
|
+
Added:
|
13
|
+
|
14
|
+
- Support `pnpm` package manager ([@skryukov])
|
15
|
+
- New `--verbose` option for the installation generator ([@skryukov])
|
16
|
+
|
17
|
+
Fixed:
|
18
|
+
|
19
|
+
- Support installation alongside Webpacker ([@skryukov])
|
20
|
+
|
10
21
|
## [0.2.0] - 2024-08-10
|
11
22
|
|
12
23
|
Added:
|
@@ -32,7 +43,8 @@ Added:
|
|
32
43
|
[@iurev]: https://github.com/iurev
|
33
44
|
[@skryukov]: https://github.com/skryukov
|
34
45
|
|
35
|
-
[Unreleased]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.
|
46
|
+
[Unreleased]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.1...HEAD
|
47
|
+
[0.2.1]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.0...v0.2.1
|
36
48
|
[0.2.0]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.1.1...v0.2.0
|
37
49
|
[0.1.1]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.1.0...v0.1.1
|
38
50
|
[0.1.0]: https://github.com/skryukov/inertia_rails-contrib/commits/v0.1.0
|
@@ -3,7 +3,13 @@ module Inertia
|
|
3
3
|
module Helpers
|
4
4
|
### FS Helpers
|
5
5
|
def js_destination_path
|
6
|
-
|
6
|
+
return ViteRuby.config.source_code_dir if defined?(ViteRuby)
|
7
|
+
if file?("config/vite.json")
|
8
|
+
source_code_dir = JSON.parse(File.read(file_path("config/vite.json"))).dig("all", "sourceCodeDir")
|
9
|
+
return source_code_dir if source_code_dir
|
10
|
+
end
|
11
|
+
|
12
|
+
"app/frontend"
|
7
13
|
end
|
8
14
|
|
9
15
|
def js_destination_root
|
@@ -18,7 +18,7 @@ module Inertia
|
|
18
18
|
enum: FRAMEWORKS.keys,
|
19
19
|
default: nil
|
20
20
|
|
21
|
-
class_option :package_manager, type: :string, default: nil, enum: %w[npm yarn bun],
|
21
|
+
class_option :package_manager, type: :string, default: nil, enum: %w[npm yarn bun pnpm],
|
22
22
|
desc: "The package manager you want to use to install Inertia's npm packages"
|
23
23
|
|
24
24
|
class_option :interactive, type: :boolean, default: true,
|
@@ -31,6 +31,9 @@ module Inertia
|
|
31
31
|
class_option :example_page, type: :boolean, default: true,
|
32
32
|
desc: "Whether to add an example Inertia page"
|
33
33
|
|
34
|
+
class_option :verbose, type: :boolean, default: false,
|
35
|
+
desc: "Run the generator in verbose mode"
|
36
|
+
|
34
37
|
remove_class_option :skip_namespace, :skip_collision_check
|
35
38
|
|
36
39
|
def install
|
@@ -46,7 +49,7 @@ module Inertia
|
|
46
49
|
|
47
50
|
say "Copying bin/dev"
|
48
51
|
copy_file "#{__dir__}/templates/dev", "bin/dev"
|
49
|
-
chmod "bin/dev", 0o755, verbose:
|
52
|
+
chmod "bin/dev", 0o755, verbose: verbose?
|
50
53
|
|
51
54
|
say "Inertia's Rails adapter successfully installed", :green
|
52
55
|
end
|
@@ -132,14 +135,14 @@ module Inertia
|
|
132
135
|
|
133
136
|
in_root do
|
134
137
|
Bundler.with_original_env do
|
135
|
-
if (capture = run("bundle add vite_rails", capture:
|
138
|
+
if (capture = run("bundle add vite_rails", capture: !verbose?))
|
136
139
|
say "Vite Rails gem successfully installed", :green
|
137
140
|
else
|
138
141
|
say capture
|
139
142
|
say_error "Failed to install Vite Rails gem", :red
|
140
143
|
exit(false)
|
141
144
|
end
|
142
|
-
if (capture = run("bundle exec vite install", capture:
|
145
|
+
if (capture = run("bundle exec vite install", capture: !verbose?))
|
143
146
|
say "Vite Rails successfully installed", :green
|
144
147
|
else
|
145
148
|
say capture
|
@@ -155,12 +158,22 @@ module Inertia
|
|
155
158
|
|
156
159
|
if package_manager.nil?
|
157
160
|
say_status "Could not find a package.json file to install Inertia to.", nil
|
161
|
+
elsif gem_installed?("webpacker") || gem_installed?("shakapacker")
|
162
|
+
say "Webpacker or Shakapacker is installed.", :yellow
|
163
|
+
say "Vite Ruby can work alongside Webpacker or Shakapacker, but it might cause issues.", :yellow
|
164
|
+
say "Please see the Vite Ruby documentation for the migration guide:", :yellow
|
165
|
+
say "https://vite-ruby.netlify.app/guide/migration.html#webpacker-%F0%9F%93%A6", :yellow
|
158
166
|
else
|
159
|
-
say_status "Could not find a Vite configuration files (`config/vite.json` & `vite.config.{ts,js,mjs,cjs}`).", nil
|
167
|
+
say_status "Could not find a Vite configuration files (`config/vite.json` & `vite.config.{ts,js,mjs,cjs,mts,cts}`).", nil
|
160
168
|
end
|
161
169
|
false
|
162
170
|
end
|
163
171
|
|
172
|
+
def gem_installed?(name)
|
173
|
+
regex = /^[^#]*gem\s+['"]#{name}['"]/
|
174
|
+
File.read(file_path("Gemfile")).match?(regex)
|
175
|
+
end
|
176
|
+
|
164
177
|
def application_layout
|
165
178
|
@application_layout ||= Pathname.new(file_path("app/views/layouts/application.html.erb"))
|
166
179
|
end
|
@@ -175,7 +188,7 @@ module Inertia
|
|
175
188
|
|
176
189
|
def add_packages(*packages)
|
177
190
|
in_root do
|
178
|
-
run "#{package_manager} add #{packages.join(" ")} --silent"
|
191
|
+
run "#{package_manager} add #{packages.join(" ")} #{verbose? ? "" : "--silent"}"
|
179
192
|
end
|
180
193
|
end
|
181
194
|
|
@@ -184,15 +197,17 @@ module Inertia
|
|
184
197
|
|
185
198
|
if file?("package-lock.json")
|
186
199
|
"npm"
|
187
|
-
elsif file?("bun.
|
200
|
+
elsif file?("bun.lockb")
|
188
201
|
"bun"
|
202
|
+
elsif file?("pnpm-lock.yaml")
|
203
|
+
"pnpm"
|
189
204
|
else
|
190
205
|
"yarn"
|
191
206
|
end
|
192
207
|
end
|
193
208
|
|
194
209
|
def vite_config_path
|
195
|
-
@vite_config_path ||= Dir.glob(file_path("vite.config.{ts,js,mjs,cjs}")).first
|
210
|
+
@vite_config_path ||= Dir.glob(file_path("vite.config.{ts,js,mjs,cjs,mts,cts}")).first
|
196
211
|
end
|
197
212
|
|
198
213
|
def install_vite?
|
@@ -207,6 +222,10 @@ module Inertia
|
|
207
222
|
@install_tailwind = options[:install_tailwind] || yes?("Would you like to install Tailwind CSS? (y/n)", :green)
|
208
223
|
end
|
209
224
|
|
225
|
+
def verbose?
|
226
|
+
options[:verbose]
|
227
|
+
end
|
228
|
+
|
210
229
|
def framework
|
211
230
|
@framework ||= options[:framework] || ask("What framework do you want to use with Inertia?", :green, limited_to: FRAMEWORKS.keys, default: "react")
|
212
231
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inertia_rails-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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-08-
|
11
|
+
date: 2024-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|