inertia_rails 3.4.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +17 -13
- data/lib/generators/inertia/controller/controller_generator.rb +18 -0
- data/lib/generators/inertia/controller/templates/controller.rb.tt +10 -0
- data/lib/generators/inertia/install/frameworks.yml +98 -0
- data/lib/generators/inertia/install/helpers.rb +51 -0
- data/lib/generators/inertia/install/install_generator.rb +291 -0
- data/lib/generators/inertia/install/js_package_manager.rb +50 -0
- data/lib/generators/inertia/install/templates/assets/inertia.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/react.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/svelte.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/vite_ruby.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/vue.svg +1 -0
- data/lib/generators/{inertia_rails/install → inertia/install/templates}/controller.rb +3 -1
- data/lib/generators/inertia/install/templates/dev +23 -0
- data/lib/generators/inertia/install/templates/initializer.rb +6 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +60 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +80 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +60 -0
- data/lib/generators/inertia/install/templates/react/inertia.js +45 -0
- data/lib/generators/inertia/install/templates/react/inertia.ts +51 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.app.json +27 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.json +11 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.node.json +13 -0
- data/lib/generators/inertia/install/templates/react/vite-env.d.ts +1 -0
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +112 -0
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +112 -0
- data/lib/generators/inertia/install/templates/svelte/inertia.js +44 -0
- data/lib/generators/inertia/install/templates/svelte/inertia.ts.tt +45 -0
- data/lib/generators/inertia/install/templates/svelte/svelte.config.js +7 -0
- data/lib/generators/inertia/install/templates/svelte/tsconfig.json +21 -0
- data/lib/generators/inertia/install/templates/svelte/tsconfig.node.json +12 -0
- data/lib/generators/inertia/install/templates/svelte/vite-env.d.ts +2 -0
- data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +116 -0
- data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +116 -0
- data/lib/generators/inertia/install/templates/svelte4/inertia.js +43 -0
- data/lib/generators/inertia/install/templates/svelte4/inertia.ts.tt +44 -0
- data/lib/generators/inertia/install/templates/svelte4/svelte.config.js +7 -0
- data/lib/generators/inertia/install/templates/svelte4/tsconfig.json +21 -0
- data/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +12 -0
- data/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +2 -0
- data/lib/generators/inertia/install/templates/tailwind/application.css +13 -0
- data/lib/generators/inertia/install/templates/tailwind/postcss.config.js +6 -0
- data/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt +18 -0
- data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +117 -0
- data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +117 -0
- data/lib/generators/inertia/install/templates/vue/inertia.js +35 -0
- data/lib/generators/inertia/install/templates/vue/inertia.ts +35 -0
- data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +24 -0
- data/lib/generators/inertia/install/templates/vue/tsconfig.json +11 -0
- data/lib/generators/inertia/install/templates/vue/tsconfig.node.json +22 -0
- data/lib/generators/inertia/install/templates/vue/vite-env.d.ts +1 -0
- data/lib/generators/inertia/scaffold/scaffold_generator.rb +16 -0
- data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +60 -0
- data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +100 -0
- data/lib/generators/inertia_templates/controller/controller_generator.rb +12 -0
- data/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt +8 -0
- data/lib/generators/inertia_templates/controller/templates/react/view.tsx.tt +8 -0
- data/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt +2 -0
- data/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +2 -0
- data/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt +4 -0
- data/lib/generators/inertia_templates/scaffold/scaffold_generator.rb +12 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Edit.tsx.tt +40 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +111 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Form.tsx.tt +130 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Index.jsx.tt +26 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Index.tsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/New.jsx.tt +27 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/New.tsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/One.jsx.tt +26 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/One.tsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Show.jsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Show.tsx.tt +38 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/types.ts.tt +19 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.svelte.tt +36 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +97 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.ts.svelte.tt +102 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.ts.svelte.tt +39 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt +29 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/New.ts.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt +28 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.ts.svelte.tt +39 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/types.ts.tt +19 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +38 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +96 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +106 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +36 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.ts.svelte.tt +31 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +28 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +39 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +40 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/types.ts.tt +19 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Edit.ts.vue.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt +36 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Form.ts.vue.tt +101 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +94 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Index.ts.vue.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Index.vue.tt +31 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/New.ts.vue.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/New.vue.tt +29 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/One.ts.vue.tt +28 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/One.vue.tt +26 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Show.ts.vue.tt +41 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Show.vue.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/controller/controller_generator.rb +12 -0
- data/lib/generators/inertia_tw_templates/controller/templates/react/view.jsx.tt +8 -0
- data/lib/generators/inertia_tw_templates/controller/templates/react/view.tsx.tt +8 -0
- data/lib/generators/inertia_tw_templates/controller/templates/svelte/view.svelte.tt +2 -0
- data/lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt +2 -0
- data/lib/generators/inertia_tw_templates/controller/templates/vue/view.vue.tt +4 -0
- data/lib/generators/inertia_tw_templates/scaffold/scaffold_generator.rb +12 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.jsx.tt +42 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.tsx.tt +47 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +122 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.tsx.tt +142 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Index.jsx.tt +43 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Index.tsx.tt +49 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/New.jsx.tt +30 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/New.tsx.tt +35 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/One.jsx.tt +26 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/One.tsx.tt +32 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt +47 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Show.tsx.tt +53 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.svelte.tt +44 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +45 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +118 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.ts.svelte.tt +123 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.svelte.tt +42 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.ts.svelte.tt +46 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.svelte.tt +32 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.ts.svelte.tt +33 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.svelte.tt +28 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.svelte.tt +50 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.ts.svelte.tt +54 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.svelte.tt +45 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +46 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt +120 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +130 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt +43 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +44 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.svelte.tt +33 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.ts.svelte.tt +34 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt +28 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt +51 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +52 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.ts.vue.tt +45 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.vue.tt +44 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.ts.vue.tt +134 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.vue.tt +127 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.ts.vue.tt +47 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.vue.tt +43 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/New.ts.vue.tt +33 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/New.vue.tt +32 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/One.ts.vue.tt +28 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/One.vue.tt +26 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.ts.vue.tt +53 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.vue.tt +49 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/types.ts.tt +19 -0
- data/lib/inertia_rails/always_prop.rb +6 -0
- data/lib/inertia_rails/base_prop.rb +14 -0
- data/lib/inertia_rails/configuration.rb +4 -1
- data/lib/inertia_rails/controller.rb +16 -4
- data/lib/inertia_rails/defer_prop.rb +21 -0
- data/lib/inertia_rails/generators/controller_template_base.rb +63 -0
- data/lib/inertia_rails/generators/helper.rb +139 -0
- data/lib/inertia_rails/generators/scaffold_template_base.rb +45 -0
- data/lib/inertia_rails/ignore_on_first_load_prop.rb +6 -0
- data/lib/inertia_rails/inertia_rails.rb +34 -12
- data/lib/inertia_rails/lazy_prop.rb +24 -0
- data/lib/inertia_rails/merge_prop.rb +14 -0
- data/lib/inertia_rails/middleware.rb +7 -2
- data/lib/inertia_rails/optional_prop.rb +6 -0
- data/lib/inertia_rails/renderer.rb +106 -20
- data/lib/inertia_rails/version.rb +1 -1
- data/lib/inertia_rails.rb +2 -0
- data/lib/patches/better_errors.rb +10 -8
- data/lib/patches/debug_exceptions/patch-5-0.rb +7 -3
- data/lib/patches/debug_exceptions/patch-5-1.rb +7 -3
- data/lib/patches/mapper.rb +9 -5
- data/lib/patches/request.rb +10 -6
- metadata +185 -13
- data/lib/generators/inertia_rails/install/react/InertiaExample.jsx +0 -9
- data/lib/generators/inertia_rails/install/react/inertia.jsx +0 -17
- data/lib/generators/inertia_rails/install/svelte/InertiaExample.svelte +0 -11
- data/lib/generators/inertia_rails/install/svelte/inertia.js +0 -14
- data/lib/generators/inertia_rails/install/vue/InertiaExample.vue +0 -11
- data/lib/generators/inertia_rails/install/vue/inertia.js +0 -20
- data/lib/generators/inertia_rails/install_generator.rb +0 -84
- data/lib/inertia_rails/lazy.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1703f19fcb6d8f3d2c580e6e7bd80ff999cda8f55f72f7ea915001279577386c
|
4
|
+
data.tar.gz: d5ff27be81328583e03aa7eb4473f1a4a966139993a3d856c54c0b6ae447b122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cdd9eebf261e555bc09d237272852c4c59cf08618462f5deb5aaa314e09538e121a8c116e989c9c66632f38d2bcf14617d0d0f6ca9f5fe152e7b646a5a652f3
|
7
|
+
data.tar.gz: 4fea8b1605262d6d80ccec45fe68368b9f62ae4cd96cca7768b58b0b65e5a690877216f6f10f7d4e93915cbba8003b4635b99ea4b3af3f2100bceda8c572cd73
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [3.6.0] - 2024-12-13
|
8
|
+
|
9
|
+
Support for the v2.0 Inertia.js release! It's a minor bump because there are no breaking changes!
|
10
|
+
|
11
|
+
Kudos to @skryukov and @PedroAugustoRamalhoDuarte for driving the features in this release!
|
12
|
+
|
13
|
+
* InertiaRails.defer for deferred props
|
14
|
+
* History encryption
|
15
|
+
* InertiaRails.merge for merge props
|
16
|
+
* InertiaRails.optional props (replaces lazy props in v2.0, InertiaRails.lazy now has a deprecation warning)
|
17
|
+
|
18
|
+
## [3.5.0] - 2024-11-29
|
19
|
+
|
20
|
+
* Add Algolia search for docs (#151, @skryukov)
|
21
|
+
* Add support for Always props (#152, @skryukov)
|
22
|
+
* Add support for :except in partial reloads (#152, @skryukov)
|
23
|
+
* CI fixes (#156, @bknoles)
|
24
|
+
* Support dot notation for :only partial reloads (#163, @bknoles)
|
25
|
+
* Avoid some monkey patching (#164, @adrianpacala)
|
26
|
+
* Upstream generators from inertia_rails-contrib (#158, @skryukov)
|
27
|
+
* Raise a deprecation warning instead of an exception if you pass a non-hashable to inertia errors (#168, @skryukov)
|
28
|
+
|
7
29
|
## [3.4.0] - 2024-11-02
|
8
30
|
|
9
31
|
* Inertia Rails documentation (@skryukov)
|
data/README.md
CHANGED
@@ -13,16 +13,15 @@ Add the `inertia_rails` gem to your Gemfile.
|
|
13
13
|
gem 'inertia_rails'
|
14
14
|
```
|
15
15
|
|
16
|
-
|
16
|
+
Follow the complete [Server-side setup](https://inertia-rails.dev/guide/server-side-setup) in the official documentation.
|
17
17
|
|
18
18
|
### Frontend
|
19
19
|
|
20
|
-
|
21
|
-
the [official docs](https://inertiajs.com/client-side-setup) are specific to Laravel.
|
20
|
+
Follow the [Client-side setup](https://inertia-rails.dev/guide/client-side-setup) guide for detailed configuration steps.
|
22
21
|
|
23
|
-
|
22
|
+
### Example Projects:
|
24
23
|
|
25
|
-
|
24
|
+
Reference these sample implementations:
|
26
25
|
|
27
26
|
- [React/Vite](https://github.com/BrandonShar/inertia-rails-template)
|
28
27
|
- [React/Vite + SSR](https://github.com/ElMassimo/inertia-rails-ssr-template)
|
@@ -103,11 +102,11 @@ end
|
|
103
102
|
|
104
103
|
### Shared Data
|
105
104
|
|
106
|
-
If you have data that you want to be provided as a prop to every component (a common use-case is information about the authenticated user) you can use the `
|
105
|
+
If you have data that you want to be provided as a prop to every component (a common use-case is information about the authenticated user) you can use the `inertia_share` controller method.
|
107
106
|
|
108
107
|
```ruby
|
109
108
|
class EventsController < ApplicationController
|
110
|
-
# share
|
109
|
+
# share synchronously
|
111
110
|
inertia_share app_name: env['app.name']
|
112
111
|
|
113
112
|
# share lazily, evaluated at render time
|
@@ -189,15 +188,12 @@ end
|
|
189
188
|
}
|
190
189
|
```
|
191
190
|
|
192
|
-
###
|
191
|
+
### Optional Props
|
193
192
|
|
194
|
-
On the
|
193
|
+
On the frontend, Inertia supports the concept of "partial reloads" where only the props requested are returned by the server. Sometimes, you may want to use this flow to avoid processing a particularly slow prop on the initial load. In this case, you can use Optional props. Optional props aren't evaluated unless they're specifically requested by name in a partial reload.
|
195
194
|
|
196
195
|
```ruby
|
197
|
-
inertia_share some_data: InertiaRails.
|
198
|
-
|
199
|
-
# Using a Ruby block syntax
|
200
|
-
inertia_share some_data: InertiaRails.lazy { some_very_slow_method }
|
196
|
+
inertia_share some_data: InertiaRails.optional { some_very_slow_method }
|
201
197
|
```
|
202
198
|
|
203
199
|
### Routing
|
@@ -270,6 +266,14 @@ end
|
|
270
266
|
|
271
267
|
__Default__: `false`
|
272
268
|
|
269
|
+
#### `encrypt_history`
|
270
|
+
|
271
|
+
When enabled, you instruct Inertia to encrypt your app's history, it uses
|
272
|
+
the browser's built-in [`crypto` api](https://developer.mozilla.org/en-US/docs/Web/API/Crypto)
|
273
|
+
to encrypt the current page's data before pushing it to the history state.
|
274
|
+
|
275
|
+
__Default__: `false`
|
276
|
+
|
273
277
|
#### `ssr_enabled` _(experimental)_
|
274
278
|
|
275
279
|
Whether to use a JavaScript server to pre-render your JavaScript pages,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/rails/controller/controller_generator'
|
4
|
+
require 'inertia_rails/generators/helper'
|
5
|
+
|
6
|
+
module Inertia
|
7
|
+
module Generators
|
8
|
+
class ControllerGenerator < Rails::Generators::ControllerGenerator
|
9
|
+
include InertiaRails::Generators::Helper
|
10
|
+
|
11
|
+
source_root File.expand_path('./templates', __dir__)
|
12
|
+
|
13
|
+
remove_hook_for :template_engine
|
14
|
+
|
15
|
+
hook_for :inertia_templates, required: true, default: InertiaRails::Generators::Helper.guess_inertia_template
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %>Controller < <%= parent_class_name.classify %>
|
3
|
+
<% actions.each do |action| -%>
|
4
|
+
def <%= action %>
|
5
|
+
render inertia: '<%= "#{inertia_base_path}/#{action.camelize}" %>'
|
6
|
+
end
|
7
|
+
<%= "\n" unless action == actions.last -%>
|
8
|
+
<% end -%>
|
9
|
+
end
|
10
|
+
<% end -%>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
react:
|
2
|
+
inertia_package: "@inertiajs/react"
|
3
|
+
packages:
|
4
|
+
- "@vitejs/plugin-react"
|
5
|
+
- "react"
|
6
|
+
- "react-dom"
|
7
|
+
packages_ts:
|
8
|
+
- "@types/react"
|
9
|
+
- "@types/react-dom"
|
10
|
+
- "typescript"
|
11
|
+
vite_plugin_import: "import react from '@vitejs/plugin-react'"
|
12
|
+
vite_plugin_call: "react()"
|
13
|
+
copy_files_ts:
|
14
|
+
"InertiaExample.tsx": "%{js_destination_path}/pages/InertiaExample.tsx"
|
15
|
+
"tsconfig.json": "tsconfig.json"
|
16
|
+
"tsconfig.app.json": "tsconfig.app.json"
|
17
|
+
"tsconfig.node.json": "tsconfig.node.json"
|
18
|
+
"vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
|
19
|
+
copy_files_js:
|
20
|
+
"InertiaExample.jsx": "%{js_destination_path}/pages/InertiaExample.jsx"
|
21
|
+
copy_files:
|
22
|
+
"InertiaExample.module.css": "%{js_destination_path}/pages/InertiaExample.module.css"
|
23
|
+
"../assets/react.svg": "%{js_destination_path}/assets/react.svg"
|
24
|
+
"../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
|
25
|
+
"../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
|
26
|
+
|
27
|
+
vue:
|
28
|
+
inertia_package: "@inertiajs/vue3"
|
29
|
+
packages:
|
30
|
+
- "vue"
|
31
|
+
- "@vitejs/plugin-vue"
|
32
|
+
packages_ts:
|
33
|
+
- "typescript@~5.6.2"
|
34
|
+
- "vue-tsc"
|
35
|
+
vite_plugin_import: "import vue from '@vitejs/plugin-vue'"
|
36
|
+
vite_plugin_call: "vue()"
|
37
|
+
copy_files:
|
38
|
+
"../assets/vue.svg": "%{js_destination_path}/assets/vue.svg"
|
39
|
+
"../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
|
40
|
+
"../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
|
41
|
+
copy_files_ts:
|
42
|
+
"InertiaExample.ts.vue": "%{js_destination_path}/pages/InertiaExample.vue"
|
43
|
+
"tsconfig.json": "tsconfig.json"
|
44
|
+
"tsconfig.app.json": "tsconfig.app.json"
|
45
|
+
"tsconfig.node.json": "tsconfig.node.json"
|
46
|
+
"vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
|
47
|
+
copy_files_js:
|
48
|
+
"InertiaExample.vue": "%{js_destination_path}/pages/InertiaExample.vue"
|
49
|
+
|
50
|
+
svelte4:
|
51
|
+
inertia_package: "@inertiajs/svelte"
|
52
|
+
packages:
|
53
|
+
- "svelte@4"
|
54
|
+
- "@sveltejs/vite-plugin-svelte@3"
|
55
|
+
packages_ts:
|
56
|
+
- "@tsconfig/svelte@4"
|
57
|
+
- "svelte-check"
|
58
|
+
- "typescript"
|
59
|
+
- "tslib"
|
60
|
+
vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
|
61
|
+
vite_plugin_call: "svelte()"
|
62
|
+
copy_files_ts:
|
63
|
+
"InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
|
64
|
+
"tsconfig.json": "tsconfig.json"
|
65
|
+
"tsconfig.node.json": "tsconfig.node.json"
|
66
|
+
"vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
|
67
|
+
copy_files_js:
|
68
|
+
"InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
|
69
|
+
copy_files:
|
70
|
+
"svelte.config.js": "svelte.config.js"
|
71
|
+
"../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg"
|
72
|
+
"../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
|
73
|
+
"../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
|
74
|
+
|
75
|
+
svelte:
|
76
|
+
inertia_package: "@inertiajs/svelte"
|
77
|
+
packages:
|
78
|
+
- "svelte@5"
|
79
|
+
- "@sveltejs/vite-plugin-svelte@4"
|
80
|
+
packages_ts:
|
81
|
+
- "@tsconfig/svelte@5"
|
82
|
+
- "svelte-check"
|
83
|
+
- "typescript"
|
84
|
+
- "tslib"
|
85
|
+
vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
|
86
|
+
vite_plugin_call: "svelte()"
|
87
|
+
copy_files_ts:
|
88
|
+
"InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
|
89
|
+
"tsconfig.json": "tsconfig.json"
|
90
|
+
"tsconfig.node.json": "tsconfig.node.json"
|
91
|
+
"vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
|
92
|
+
copy_files_js:
|
93
|
+
"InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
|
94
|
+
copy_files:
|
95
|
+
"svelte.config.js": "svelte.config.js"
|
96
|
+
"../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg"
|
97
|
+
"../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
|
98
|
+
"../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Inertia
|
4
|
+
module Generators
|
5
|
+
module Helpers
|
6
|
+
### FS Helpers
|
7
|
+
def js_destination_path
|
8
|
+
return ViteRuby.config.source_code_dir if defined?(ViteRuby)
|
9
|
+
|
10
|
+
if file?('config/vite.json')
|
11
|
+
source_code_dir = JSON.parse(File.read(file_path('config/vite.json'))).dig('all', 'sourceCodeDir')
|
12
|
+
return source_code_dir if source_code_dir
|
13
|
+
end
|
14
|
+
|
15
|
+
'app/frontend'
|
16
|
+
end
|
17
|
+
|
18
|
+
def js_destination_root
|
19
|
+
file_path(js_destination_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def js_file_path(*relative_path)
|
23
|
+
File.join(js_destination_root, *relative_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def file?(*relative_path)
|
27
|
+
File.file?(file_path(*relative_path))
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_path(*relative_path)
|
31
|
+
File.join(destination_root, *relative_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Interactivity Helpers
|
35
|
+
def ask(*)
|
36
|
+
unless options[:interactive]
|
37
|
+
say_error 'Specify all options when running the generator non-interactively.', :red
|
38
|
+
exit(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def yes?(*)
|
45
|
+
return false unless options[:interactive]
|
46
|
+
|
47
|
+
super
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'rails/generators'
|
5
|
+
require 'rails/generators/base'
|
6
|
+
|
7
|
+
require_relative 'helpers'
|
8
|
+
require_relative 'js_package_manager'
|
9
|
+
|
10
|
+
module Inertia
|
11
|
+
module Generators
|
12
|
+
class InstallGenerator < Rails::Generators::Base
|
13
|
+
include Helpers
|
14
|
+
|
15
|
+
FRAMEWORKS = YAML.load_file(File.expand_path('./frameworks.yml', __dir__))
|
16
|
+
|
17
|
+
source_root File.expand_path('./templates', __dir__)
|
18
|
+
|
19
|
+
class_option :framework, type: :string,
|
20
|
+
desc: 'The framework you want to use with Inertia',
|
21
|
+
enum: FRAMEWORKS.keys,
|
22
|
+
default: nil
|
23
|
+
|
24
|
+
class_option :inertia_version, type: :string, default: 'latest',
|
25
|
+
desc: 'The version of Inertia.js to install'
|
26
|
+
|
27
|
+
class_option :typescript, type: :boolean, default: false,
|
28
|
+
desc: 'Whether to use TypeScript'
|
29
|
+
|
30
|
+
class_option :package_manager, type: :string, default: nil,
|
31
|
+
enum: JSPackageManager.package_managers,
|
32
|
+
desc: "The package manager you want to use to install Inertia's npm packages"
|
33
|
+
|
34
|
+
class_option :interactive, type: :boolean, default: true,
|
35
|
+
desc: 'Whether to prompt for optional installations'
|
36
|
+
|
37
|
+
class_option :tailwind, type: :boolean, default: false,
|
38
|
+
desc: 'Whether to install Tailwind CSS'
|
39
|
+
class_option :vite, type: :boolean, default: false,
|
40
|
+
desc: 'Whether to install Vite Ruby'
|
41
|
+
class_option :example_page, type: :boolean, default: true,
|
42
|
+
desc: 'Whether to add an example Inertia page'
|
43
|
+
|
44
|
+
class_option :verbose, type: :boolean, default: false,
|
45
|
+
desc: 'Run the generator in verbose mode'
|
46
|
+
|
47
|
+
remove_class_option :skip_namespace, :skip_collision_check
|
48
|
+
|
49
|
+
def install
|
50
|
+
say "Installing Inertia's Rails adapter"
|
51
|
+
|
52
|
+
if inertia_resolved_version.version == '0'
|
53
|
+
say_error "Could not find the Inertia.js package version #{options[:inertia_version]}.", :red
|
54
|
+
exit(false)
|
55
|
+
end
|
56
|
+
|
57
|
+
install_vite unless ruby_vite_installed?
|
58
|
+
|
59
|
+
install_typescript if typescript?
|
60
|
+
|
61
|
+
install_tailwind if install_tailwind?
|
62
|
+
|
63
|
+
install_inertia
|
64
|
+
|
65
|
+
install_example_page if options[:example_page]
|
66
|
+
|
67
|
+
say 'Copying bin/dev'
|
68
|
+
copy_file "#{__dir__}/templates/dev", 'bin/dev'
|
69
|
+
chmod 'bin/dev', 0o755, verbose: verbose?
|
70
|
+
|
71
|
+
say "Inertia's Rails adapter successfully installed", :green
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def install_inertia
|
77
|
+
say "Adding Inertia's Rails adapter initializer"
|
78
|
+
template 'initializer.rb', file_path('config/initializers/inertia_rails.rb')
|
79
|
+
|
80
|
+
say 'Installing Inertia npm packages'
|
81
|
+
add_dependencies(*FRAMEWORKS[framework]['packages'])
|
82
|
+
add_dependencies(inertia_package)
|
83
|
+
|
84
|
+
unless File.read(vite_config_path).include?(FRAMEWORKS[framework]['vite_plugin_import'])
|
85
|
+
say "Adding Vite plugin for #{framework}"
|
86
|
+
insert_into_file vite_config_path, "\n #{FRAMEWORKS[framework]['vite_plugin_call']},", after: 'plugins: ['
|
87
|
+
prepend_file vite_config_path, "#{FRAMEWORKS[framework]['vite_plugin_import']}\n"
|
88
|
+
end
|
89
|
+
|
90
|
+
say "Copying #{inertia_entrypoint} entrypoint"
|
91
|
+
template "#{framework}/#{inertia_entrypoint}", js_file_path("entrypoints/#{inertia_entrypoint}")
|
92
|
+
|
93
|
+
if application_layout.exist?
|
94
|
+
say "Adding #{inertia_entrypoint} script tag to the application layout"
|
95
|
+
headers = <<-ERB
|
96
|
+
<%= #{vite_tag} "inertia" %>
|
97
|
+
<%= inertia_ssr_head %>
|
98
|
+
ERB
|
99
|
+
insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n"
|
100
|
+
|
101
|
+
if framework == 'react' && !application_layout.read.include?('vite_react_refresh_tag')
|
102
|
+
say 'Adding Vite React Refresh tag to the application layout'
|
103
|
+
insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ",
|
104
|
+
before: '<%= vite_client_tag %>'
|
105
|
+
end
|
106
|
+
|
107
|
+
gsub_file application_layout.to_s, /<title>/, '<title inertia>' unless svelte?
|
108
|
+
else
|
109
|
+
say_error 'Could not find the application layout file. Please add the following tags manually:', :red
|
110
|
+
say_error '- <title>...</title>'
|
111
|
+
say_error '+ <title inertia>...</title>'
|
112
|
+
say_error '+ <%= inertia_ssr_head %>'
|
113
|
+
say_error '+ <%= vite_react_refresh_tag %>' if framework == 'react'
|
114
|
+
say_error "+ <%= #{vite_tag} \"inertia\" %>"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def install_typescript
|
119
|
+
say 'Adding TypeScript support'
|
120
|
+
if svelte? && inertia_resolved_version.release < Gem::Version.new('1.3.0')
|
121
|
+
say 'WARNING: @inertiajs/svelte < 1.3.0 does not support TypeScript ' \
|
122
|
+
"(resolved version: #{inertia_resolved_version}).",
|
123
|
+
:yellow
|
124
|
+
say 'Skipping TypeScript support for @inertiajs/svelte', :yellow
|
125
|
+
@typescript = false
|
126
|
+
return
|
127
|
+
end
|
128
|
+
|
129
|
+
add_dependencies(*FRAMEWORKS[framework]['packages_ts'])
|
130
|
+
|
131
|
+
say 'Copying adding scripts to package.json'
|
132
|
+
run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"' if svelte?
|
133
|
+
run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'vue'
|
134
|
+
run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'react'
|
135
|
+
end
|
136
|
+
|
137
|
+
def install_example_page
|
138
|
+
say 'Copying example Inertia controller'
|
139
|
+
template 'controller.rb', file_path('app/controllers/inertia_example_controller.rb')
|
140
|
+
|
141
|
+
say 'Adding a route for the example Inertia controller'
|
142
|
+
route "get 'inertia-example', to: 'inertia_example#index'"
|
143
|
+
|
144
|
+
say 'Copying page assets'
|
145
|
+
copy_files = FRAMEWORKS[framework]['copy_files'].merge(
|
146
|
+
FRAMEWORKS[framework]["copy_files_#{typescript? ? 'ts' : 'js'}"]
|
147
|
+
)
|
148
|
+
copy_files.each do |source, destination|
|
149
|
+
template "#{framework}/#{source}", file_path(format(destination, js_destination_path: js_destination_path))
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def install_tailwind
|
154
|
+
say 'Installing Tailwind CSS'
|
155
|
+
add_dependencies(%w[tailwindcss postcss autoprefixer @tailwindcss/forms @tailwindcss/typography
|
156
|
+
@tailwindcss/container-queries])
|
157
|
+
|
158
|
+
template 'tailwind/tailwind.config.js', file_path('tailwind.config.js')
|
159
|
+
copy_file 'tailwind/postcss.config.js', file_path('postcss.config.js')
|
160
|
+
copy_file 'tailwind/application.css', js_file_path('entrypoints/application.css')
|
161
|
+
|
162
|
+
if application_layout.exist?
|
163
|
+
say 'Adding Tailwind CSS to the application layout'
|
164
|
+
insert_into_file application_layout.to_s, "<%= vite_stylesheet_tag \"application\" %>\n ",
|
165
|
+
before: '<%= vite_client_tag %>'
|
166
|
+
else
|
167
|
+
say_error 'Could not find the application layout file. Please add the following tags manually:', :red
|
168
|
+
say_error '+ <%= vite_stylesheet_tag "application" %>' if install_tailwind?
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def install_vite
|
173
|
+
unless install_vite?
|
174
|
+
say_error 'This generator only supports Ruby on Rails with Vite.', :red
|
175
|
+
exit(false)
|
176
|
+
end
|
177
|
+
|
178
|
+
in_root do
|
179
|
+
Bundler.with_original_env do
|
180
|
+
if (capture = run('bundle add vite_rails', capture: !verbose?))
|
181
|
+
say 'Vite Rails gem successfully installed', :green
|
182
|
+
else
|
183
|
+
say capture
|
184
|
+
say_error 'Failed to install Vite Rails gem', :red
|
185
|
+
exit(false)
|
186
|
+
end
|
187
|
+
if (capture = run('bundle exec vite install', capture: !verbose?))
|
188
|
+
say 'Vite Rails successfully installed', :green
|
189
|
+
else
|
190
|
+
say capture
|
191
|
+
say_error 'Failed to install Vite Rails', :red
|
192
|
+
exit(false)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def ruby_vite_installed?
|
199
|
+
return true if package_manager.present? && ruby_vite?
|
200
|
+
|
201
|
+
if !package_manager.present?
|
202
|
+
say_status 'Could not find a package.json file to install Inertia to.', nil
|
203
|
+
elsif gem_installed?('webpacker') || gem_installed?('shakapacker')
|
204
|
+
say 'Webpacker or Shakapacker is installed.', :yellow
|
205
|
+
say 'Vite Ruby can work alongside Webpacker or Shakapacker, but it might cause issues.', :yellow
|
206
|
+
say 'Please see the Vite Ruby documentation for the migration guide:', :yellow
|
207
|
+
say 'https://vite-ruby.netlify.app/guide/migration.html#webpacker-%F0%9F%93%A6', :yellow
|
208
|
+
else
|
209
|
+
say_status 'Could not find a Vite configuration files ' \
|
210
|
+
'(`config/vite.json` & `vite.config.{ts,js,mjs,cjs,mts,cts}`).',
|
211
|
+
nil
|
212
|
+
end
|
213
|
+
false
|
214
|
+
end
|
215
|
+
|
216
|
+
def gem_installed?(name)
|
217
|
+
regex = /^[^#]*gem\s+['"]#{name}['"]/
|
218
|
+
File.read(file_path('Gemfile')).match?(regex)
|
219
|
+
end
|
220
|
+
|
221
|
+
def application_layout
|
222
|
+
@application_layout ||= Pathname.new(file_path('app/views/layouts/application.html.erb'))
|
223
|
+
end
|
224
|
+
|
225
|
+
def ruby_vite?
|
226
|
+
file?('config/vite.json') && vite_config_path
|
227
|
+
end
|
228
|
+
|
229
|
+
def package_manager
|
230
|
+
@package_manager ||= JSPackageManager.new(self)
|
231
|
+
end
|
232
|
+
|
233
|
+
def add_dependencies(*packages)
|
234
|
+
package_manager.add_dependencies(*packages)
|
235
|
+
end
|
236
|
+
|
237
|
+
def vite_config_path
|
238
|
+
@vite_config_path ||= Dir.glob(file_path('vite.config.{ts,js,mjs,cjs,mts,cts}')).first
|
239
|
+
end
|
240
|
+
|
241
|
+
def install_vite?
|
242
|
+
return @install_vite if defined?(@install_vite)
|
243
|
+
|
244
|
+
@install_vite = options[:vite] || yes?('Would you like to install Vite Ruby? (y/n)', :green)
|
245
|
+
end
|
246
|
+
|
247
|
+
def install_tailwind?
|
248
|
+
return @install_tailwind if defined?(@install_tailwind)
|
249
|
+
|
250
|
+
@install_tailwind = options[:tailwind] || yes?('Would you like to install Tailwind CSS? (y/n)', :green)
|
251
|
+
end
|
252
|
+
|
253
|
+
def typescript?
|
254
|
+
return @typescript if defined?(@typescript)
|
255
|
+
|
256
|
+
@typescript = options[:typescript] || yes?('Would you like to use TypeScript? (y/n)', :green)
|
257
|
+
end
|
258
|
+
|
259
|
+
def inertia_entrypoint
|
260
|
+
"inertia.#{typescript? ? 'ts' : 'js'}"
|
261
|
+
end
|
262
|
+
|
263
|
+
def vite_tag
|
264
|
+
typescript? ? 'vite_typescript_tag' : 'vite_javascript_tag'
|
265
|
+
end
|
266
|
+
|
267
|
+
def inertia_resolved_version
|
268
|
+
@inertia_resolved_version ||= Gem::Version.new(
|
269
|
+
`npm show @inertiajs/core@#{options[:inertia_version]} version`.strip
|
270
|
+
)
|
271
|
+
end
|
272
|
+
|
273
|
+
def verbose?
|
274
|
+
options[:verbose]
|
275
|
+
end
|
276
|
+
|
277
|
+
def svelte?
|
278
|
+
framework.start_with? 'svelte'
|
279
|
+
end
|
280
|
+
|
281
|
+
def inertia_package
|
282
|
+
"#{FRAMEWORKS[framework]['inertia_package']}@#{options[:inertia_version]}"
|
283
|
+
end
|
284
|
+
|
285
|
+
def framework
|
286
|
+
@framework ||= options[:framework] || ask('What framework do you want to use with Inertia?', :green,
|
287
|
+
limited_to: FRAMEWORKS.keys, default: 'react')
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Inertia
|
4
|
+
module Generators
|
5
|
+
class JSPackageManager
|
6
|
+
def self.package_managers
|
7
|
+
%w[npm yarn bun pnpm]
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(generator)
|
11
|
+
@generator = generator
|
12
|
+
end
|
13
|
+
|
14
|
+
def present?
|
15
|
+
package_manager.present?
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_dependencies(*dependencies)
|
19
|
+
options = @generator.options[:verbose] ? '' : ' --silent'
|
20
|
+
@generator.in_root do
|
21
|
+
@generator.run "#{package_manager} add #{dependencies.join(' ')}#{options}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def package_manager
|
28
|
+
@package_manager ||= @generator.options[:package_manager] || detect_package_manager
|
29
|
+
end
|
30
|
+
|
31
|
+
def detect_package_manager
|
32
|
+
return nil unless file?('package.json')
|
33
|
+
|
34
|
+
if file?('package-lock.json')
|
35
|
+
'npm'
|
36
|
+
elsif file?('bun.lockb')
|
37
|
+
'bun'
|
38
|
+
elsif file?('pnpm-lock.yaml')
|
39
|
+
'pnpm'
|
40
|
+
else
|
41
|
+
'yarn'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def file?(*relative_path)
|
46
|
+
@generator.file?(*relative_path)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg width="100%" height="100%" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg"><linearGradient id="a" x1="0" y1="200" x2="400" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#9653ea"/><stop offset="1" stop-color="#6e74ef"/></linearGradient><path fill="url(#a)" fill-rule="evenodd" d="M400 200C400 89.543 310.457 0 200 0S0 89.543 0 200s89.543 200 200 200 200-89.543 200-200Z"/><path fill="#fff" d="M137.331 117.6H52.4l82.069 82.069L52.4 281.737h84.931L219.4 199.67Z"/><path fill="#fff" d="M265.231 117.6H180.3l82.069 82.069-82.069 82.068h84.931L347.3 199.67Z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg viewBox="-10.5 -9.45 21 18.9" fill="none" xmlns="http://www.w3.org/2000/svg" class="uwu-hidden mt-4 mb-3 text-brand dark:text-brand-dark w-24 lg:w-28 self-center text-sm me-0 flex origin-center transition-all ease-in-out"><circle r="2" fill="#58C4DC"/><g stroke="#58C4DC"><ellipse rx="10" ry="4.5"/><ellipse rx="10" ry="4.5" transform="rotate(60)"/><ellipse rx="10" ry="4.5" transform="rotate(120)"/></g></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="iconify iconify--logos" width="26.6" height="32" viewBox="0 0 256 308"><path fill="#FF3E00" d="M239.682 40.707C211.113-.182 154.69-12.301 113.895 13.69L42.247 59.356a82.198 82.198 0 0 0-37.135 55.056 86.566 86.566 0 0 0 8.536 55.576 82.425 82.425 0 0 0-12.296 30.719 87.596 87.596 0 0 0 14.964 66.244c28.574 40.893 84.997 53.007 125.787 27.016l71.648-45.664a82.182 82.182 0 0 0 37.135-55.057 86.601 86.601 0 0 0-8.53-55.577 82.409 82.409 0 0 0 12.29-30.718 87.573 87.573 0 0 0-14.963-66.244"/><path fill="#FFF" d="M106.889 270.841c-23.102 6.007-47.497-3.036-61.103-22.648a52.685 52.685 0 0 1-9.003-39.85 49.978 49.978 0 0 1 1.713-6.693l1.35-4.115 3.671 2.697a92.447 92.447 0 0 0 28.036 14.007l2.663.808-.245 2.659a16.067 16.067 0 0 0 2.89 10.656 17.143 17.143 0 0 0 18.397 6.828 15.786 15.786 0 0 0 4.403-1.935l71.67-45.672a14.922 14.922 0 0 0 6.734-9.977 15.923 15.923 0 0 0-2.713-12.011 17.156 17.156 0 0 0-18.404-6.832 15.78 15.78 0 0 0-4.396 1.933l-27.35 17.434a52.298 52.298 0 0 1-14.553 6.391c-23.101 6.007-47.497-3.036-61.101-22.649a52.681 52.681 0 0 1-9.004-39.849 49.428 49.428 0 0 1 22.34-33.114l71.664-45.677a52.218 52.218 0 0 1 14.563-6.398c23.101-6.007 47.497 3.036 61.101 22.648a52.685 52.685 0 0 1 9.004 39.85 50.559 50.559 0 0 1-1.713 6.692l-1.35 4.116-3.67-2.693a92.373 92.373 0 0 0-28.037-14.013l-2.664-.809.246-2.658a16.099 16.099 0 0 0-2.89-10.656 17.143 17.143 0 0 0-18.398-6.828 15.786 15.786 0 0 0-4.402 1.935l-71.67 45.674a14.898 14.898 0 0 0-6.73 9.975 15.9 15.9 0 0 0 2.709 12.012 17.156 17.156 0 0 0 18.404 6.832 15.841 15.841 0 0 0 4.402-1.935l27.345-17.427a52.147 52.147 0 0 1 14.552-6.397c23.101-6.006 47.497 3.037 61.102 22.65a52.681 52.681 0 0 1 9.003 39.848 49.453 49.453 0 0 1-22.34 33.12l-71.664 45.673a52.218 52.218 0 0 1-14.563 6.398"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 366 304" fill="none"><path d="M91.95 46.973a5.5 5.5 0 0 0-.401.722l-59.724 69.638a5.5 5.5 0 0 0 .003 7.165l147 171.086a5.502 5.502 0 0 0 8.344 0l147-171.084a5.5 5.5 0 0 0 .003-7.165l-59.723-69.637a5.5 5.5 0 0 0-4.996-3.198H96.543a5.5 5.5 0 0 0-4.592 2.473z" fill="url(#a)" stroke="url(#b)" stroke-width="11" stroke-linecap="round" stroke-linejoin="round"/><path d="m265.857 19.004-116.154 5.598a4.346 4.346 0 0 0-3.643 3.885v109.121c-.267 2.885 2.326 5.217 5.182 4.659l20.815-4.659c3.114-.608 5.819 2.194 5.082 5.268l-8.01 45.423c-.767 3.199 2.18 6.052 5.371 5.201l17.232-3.395c3.195-.852 6.144 2.01 5.369 5.211l-18.069 74.653c-1.13 4.67 5.068 7.44 7.82 3.495l1.838-2.635L291.703 81.887c1.725-3.163-.947-6.923-4.518-6.357l-34.224 5.417c-3.217.508-5.839-2.544-4.834-5.627l22.576-50.691c1.006-3.088-1.626-6.144-4.846-5.625z" fill="url(#c)"/><defs><linearGradient id="a" x1="28.5" y1="34" x2="246.355" y2="194.428" gradientUnits="userSpaceOnUse"><stop stop-color="#FF006B"/><stop offset=".364" stop-color="#C00"/><stop offset="1" stop-color="#980D03"/></linearGradient><linearGradient id="b" x1="28.5" y1="34" x2="246.355" y2="194.428" gradientUnits="userSpaceOnUse"><stop stop-color="#FF006B"/><stop offset=".364" stop-color="#C00"/><stop offset="1" stop-color="#980D03"/></linearGradient><linearGradient id="c" x1="183.666" y1="-5.499" x2="211.353" y2="242.278" gradientUnits="userSpaceOnUse"><stop stop-color="#FFDD35"/><stop offset=".083" stop-color="#FFD233"/><stop offset=".594" stop-color="#FFA800"/><stop offset=".839" stop-color="#F90"/></linearGradient></defs></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="iconify iconify--logos" width="37.07" height="36" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8 0 0h97.92L128 51.2 157.44 0h47.36Z"/><path fill="#41B883" d="m0 0 128 220.8L256 0h-51.2L128 132.48 50.56 0H0Z"/><path fill="#35495E" d="M50.56 0 128 133.12 204.8 0h-47.36L128 51.2 97.92 0H50.56Z"/></svg>
|