inertia_rails 3.12.1 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/lib/generators/inertia/controller/templates/controller.rb.tt +1 -1
  4. data/lib/generators/inertia/install/frameworks.yml +10 -45
  5. data/lib/generators/inertia/install/install_generator.rb +102 -14
  6. data/lib/generators/inertia/install/js_package_manager.rb +6 -6
  7. data/lib/generators/inertia/install/templates/assets/rails.svg +9 -0
  8. data/lib/generators/inertia/install/templates/controller.rb +6 -3
  9. data/lib/generators/inertia/install/templates/inertia_controller.rb +5 -0
  10. data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +43 -47
  11. data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +63 -41
  12. data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +46 -47
  13. data/lib/generators/inertia/install/templates/react/inertia.jsx +65 -0
  14. data/lib/generators/inertia/install/templates/react/inertia.tsx +65 -0
  15. data/lib/generators/inertia/install/templates/react/tsconfig.app.json +7 -0
  16. data/lib/generators/inertia/install/templates/react/types/globals.d.ts +8 -0
  17. data/lib/generators/inertia/install/templates/react/types/index.ts +8 -0
  18. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +103 -69
  19. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +104 -69
  20. data/lib/generators/inertia/install/templates/svelte/inertia.js +14 -3
  21. data/lib/generators/inertia/install/templates/svelte/{inertia.ts.tt → inertia.ts} +12 -2
  22. data/lib/generators/inertia/install/templates/svelte/tsconfig.json +8 -0
  23. data/lib/generators/inertia/install/templates/svelte/types/globals.d.ts +8 -0
  24. data/lib/generators/inertia/install/templates/svelte/types/index.ts +8 -0
  25. data/lib/generators/inertia/install/templates/tailwind/application.css +3 -3
  26. data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +107 -70
  27. data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +129 -92
  28. data/lib/generators/inertia/install/templates/vue/inertia.js +30 -3
  29. data/lib/generators/inertia/install/templates/vue/inertia.ts +31 -3
  30. data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +9 -1
  31. data/lib/generators/inertia/install/templates/vue/types/globals.d.ts +8 -0
  32. data/lib/generators/inertia/install/templates/vue/types/index.ts +8 -0
  33. data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +4 -0
  34. data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +7 -5
  35. data/lib/generators/inertia_templates/scaffold/templates/react/{Edit.jsx.tt → edit.jsx.tt} +5 -8
  36. data/lib/generators/inertia_templates/scaffold/templates/react/{Edit.tsx.tt → edit.tsx.tt} +7 -9
  37. data/lib/generators/inertia_templates/scaffold/templates/react/form.jsx.tt +94 -0
  38. data/lib/generators/inertia_templates/scaffold/templates/react/form.tsx.tt +109 -0
  39. data/lib/generators/inertia_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt} +1 -1
  40. data/lib/generators/inertia_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt} +1 -1
  41. data/lib/generators/inertia_templates/scaffold/templates/react/{New.jsx.tt → new.jsx.tt} +3 -5
  42. data/lib/generators/inertia_templates/scaffold/templates/react/{New.tsx.tt → new.tsx.tt} +5 -6
  43. data/lib/generators/inertia_templates/scaffold/templates/react/{Show.jsx.tt → show.jsx.tt} +1 -1
  44. data/lib/generators/inertia_templates/scaffold/templates/react/{Show.tsx.tt → show.tsx.tt} +1 -1
  45. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt} +9 -13
  46. data/lib/generators/inertia_templates/scaffold/templates/{svelte4/Edit.svelte.tt → svelte/edit.ts.svelte.tt} +11 -15
  47. data/lib/generators/inertia_templates/scaffold/templates/svelte/form.svelte.tt +96 -0
  48. data/lib/generators/inertia_templates/scaffold/templates/svelte/form.ts.svelte.tt +103 -0
  49. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt} +1 -1
  50. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.ts.svelte.tt → index.ts.svelte.tt} +1 -1
  51. data/lib/generators/inertia_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt} +4 -7
  52. data/lib/generators/inertia_templates/scaffold/templates/{svelte4/New.svelte.tt → svelte/new.ts.svelte.tt} +6 -9
  53. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt} +1 -1
  54. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.ts.svelte.tt → show.ts.svelte.tt} +1 -1
  55. data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt} +11 -15
  56. data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.vue.tt → edit.vue.tt} +9 -13
  57. data/lib/generators/inertia_templates/scaffold/templates/vue/form.ts.vue.tt +102 -0
  58. data/lib/generators/inertia_templates/scaffold/templates/vue/form.vue.tt +98 -0
  59. data/lib/generators/inertia_templates/scaffold/templates/vue/{Index.ts.vue.tt → index.ts.vue.tt} +1 -1
  60. data/lib/generators/inertia_templates/scaffold/templates/vue/{Index.vue.tt → index.vue.tt} +1 -1
  61. data/lib/generators/inertia_templates/scaffold/templates/vue/{New.ts.vue.tt → new.ts.vue.tt} +6 -9
  62. data/lib/generators/inertia_templates/scaffold/templates/vue/{New.vue.tt → new.vue.tt} +4 -7
  63. data/lib/generators/inertia_templates/scaffold/templates/vue/{Show.ts.vue.tt → show.ts.vue.tt} +1 -1
  64. data/lib/generators/inertia_templates/scaffold/templates/vue/{Show.vue.tt → show.vue.tt} +1 -1
  65. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Edit.jsx.tt → edit.jsx.tt} +5 -8
  66. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Edit.tsx.tt → edit.tsx.tt} +6 -9
  67. data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.jsx.tt +106 -0
  68. data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.tsx.tt +122 -0
  69. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt} +1 -1
  70. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt} +1 -1
  71. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{New.jsx.tt → new.jsx.tt} +3 -5
  72. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{New.tsx.tt → new.tsx.tt} +4 -6
  73. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Show.jsx.tt → show.jsx.tt} +1 -1
  74. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Show.tsx.tt → show.tsx.tt} +1 -1
  75. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt} +9 -13
  76. data/lib/generators/inertia_tw_templates/scaffold/templates/{svelte4/Edit.svelte.tt → svelte/edit.ts.svelte.tt} +11 -15
  77. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.svelte.tt +109 -0
  78. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.ts.svelte.tt +115 -0
  79. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt} +1 -1
  80. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Index.ts.svelte.tt → index.ts.svelte.tt} +1 -1
  81. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt} +4 -7
  82. data/lib/generators/inertia_tw_templates/scaffold/templates/{svelte4/New.svelte.tt → svelte/new.ts.svelte.tt} +6 -9
  83. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt} +1 -1
  84. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Show.ts.svelte.tt → show.ts.svelte.tt} +1 -1
  85. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt} +10 -15
  86. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Edit.vue.tt → edit.vue.tt} +8 -13
  87. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.ts.vue.tt → form.ts.vue.tt} +19 -42
  88. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.vue.tt → form.vue.tt} +18 -38
  89. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Index.ts.vue.tt → index.ts.vue.tt} +1 -1
  90. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Index.vue.tt → index.vue.tt} +1 -1
  91. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{New.ts.vue.tt → new.ts.vue.tt} +6 -9
  92. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{New.vue.tt → new.vue.tt} +4 -7
  93. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Show.ts.vue.tt → show.ts.vue.tt} +1 -1
  94. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Show.vue.tt → show.vue.tt} +1 -1
  95. data/lib/inertia_rails/generators/controller_template_base.rb +1 -1
  96. data/lib/inertia_rails/generators/helper.rb +2 -3
  97. data/lib/inertia_rails/generators/scaffold_template_base.rb +3 -3
  98. data/lib/inertia_rails/version.rb +1 -1
  99. data/lib/inertia_rails.rb +1 -0
  100. metadata +88 -116
  101. data/lib/generators/inertia/install/templates/react/inertia.js +0 -45
  102. data/lib/generators/inertia/install/templates/react/inertia.ts +0 -51
  103. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +0 -116
  104. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +0 -116
  105. data/lib/generators/inertia/install/templates/svelte4/inertia.js +0 -43
  106. data/lib/generators/inertia/install/templates/svelte4/inertia.ts.tt +0 -44
  107. data/lib/generators/inertia/install/templates/svelte4/svelte.config.js +0 -7
  108. data/lib/generators/inertia/install/templates/svelte4/tsconfig.json +0 -21
  109. data/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +0 -12
  110. data/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +0 -2
  111. data/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +0 -2
  112. data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +0 -111
  113. data/lib/generators/inertia_templates/scaffold/templates/react/Form.tsx.tt +0 -130
  114. data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +0 -37
  115. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +0 -97
  116. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.ts.svelte.tt +0 -102
  117. data/lib/generators/inertia_templates/scaffold/templates/svelte/New.ts.svelte.tt +0 -30
  118. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +0 -38
  119. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +0 -96
  120. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +0 -106
  121. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +0 -36
  122. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +0 -37
  123. data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.ts.svelte.tt +0 -31
  124. data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +0 -28
  125. data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.ts.svelte.tt +0 -30
  126. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +0 -39
  127. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +0 -40
  128. data/lib/generators/inertia_templates/scaffold/templates/svelte4/types.ts.tt +0 -19
  129. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.ts.vue.tt +0 -101
  130. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +0 -94
  131. data/lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt +0 -2
  132. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +0 -122
  133. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.tsx.tt +0 -142
  134. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +0 -45
  135. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +0 -118
  136. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.ts.svelte.tt +0 -123
  137. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.ts.svelte.tt +0 -33
  138. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +0 -46
  139. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt +0 -120
  140. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +0 -130
  141. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt +0 -43
  142. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +0 -44
  143. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.ts.svelte.tt +0 -34
  144. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt +0 -28
  145. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.ts.svelte.tt +0 -30
  146. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt +0 -51
  147. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +0 -52
  148. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/types.ts.tt +0 -19
  149. /data/lib/generators/inertia/install/templates/react/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
  150. /data/lib/generators/inertia/install/templates/svelte/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
  151. /data/lib/generators/inertia/install/templates/vue/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
  152. /data/lib/generators/inertia_templates/scaffold/templates/react/{One.jsx.tt → one.jsx.tt} +0 -0
  153. /data/lib/generators/inertia_templates/scaffold/templates/react/{One.tsx.tt → one.tsx.tt} +0 -0
  154. /data/lib/generators/inertia_templates/scaffold/templates/svelte/{One.svelte.tt → one.svelte.tt} +0 -0
  155. /data/lib/generators/inertia_templates/scaffold/templates/svelte/{One.ts.svelte.tt → one.ts.svelte.tt} +0 -0
  156. /data/lib/generators/inertia_templates/scaffold/templates/vue/{One.ts.vue.tt → one.ts.vue.tt} +0 -0
  157. /data/lib/generators/inertia_templates/scaffold/templates/vue/{One.vue.tt → one.vue.tt} +0 -0
  158. /data/lib/generators/inertia_tw_templates/scaffold/templates/react/{One.jsx.tt → one.jsx.tt} +0 -0
  159. /data/lib/generators/inertia_tw_templates/scaffold/templates/react/{One.tsx.tt → one.tsx.tt} +0 -0
  160. /data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{One.svelte.tt → one.svelte.tt} +0 -0
  161. /data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{One.ts.svelte.tt → one.ts.svelte.tt} +0 -0
  162. /data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{One.ts.vue.tt → one.ts.vue.tt} +0 -0
  163. /data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{One.vue.tt → one.vue.tt} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3bde9e557a4d5b76450d4f019ae8461b40a0eb2fda2984d8d5cb32fa58d769c
4
- data.tar.gz: d662136e29e4f72957a6677a74b1c6c29086e8e32056023e5b51fb4b5e70b976
3
+ metadata.gz: 8e02de8da9dda43a24dae17c59496938d35eef2caa4bade2543d4336201baa0e
4
+ data.tar.gz: ae6952effd0e1144dc78f2c7f2a3ae9ccc0f1b6011000ef9a7ecfe9f8d9166aa
5
5
  SHA512:
6
- metadata.gz: 86753985c32f435b2967144c8b88e22984d1999fd0e528ac862d9b2dcc081545d52841d54b984d8184cb7774681576aa03ce244b09016a79b0110067b1d69d7e
7
- data.tar.gz: 22197c8fc07a0f2d25402f04ab9988b3a572bd7c713ef8a391bf95bdb680bfac5a03c65c19796671d7172f921d1fdc900cc9f4f3d41420702e556a1a820a3942
6
+ metadata.gz: 5426c306db138b90256fc924f20f6ce5b68583c431f10f49f1acd5eb64c013b9ed1f4d75472dfab8a971df43a9ad4a03a2854f2a1dff5fbbb4d09748b9b92a0d
7
+ data.tar.gz: f12bd8e51187679c56a6db6e545687d7ac5c795d20e9d74d5865897b61e9d0308480f4dc06a62fca9d32aa1129041977bdf4be2f69061aaccb3b571972d7d6cc
data/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ 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.14.0] - 2025-11-27
8
+
9
+ Lots of quality of life improvements!
10
+
11
+ * OG Pilot in Awesome page (@raulpopadineti)
12
+ * Expose InertiaRails version (@capripot)
13
+ * Svelte improvements to install generators (@alec-c4)
14
+ * Add start kits to docs (@skryukov)
15
+ * Fix types in React install templates (@skryukov)
16
+ * Update docs with new inertia branding (@skryukov)
17
+ * Add protocol diagram (@skryukov)
18
+ * Fix forceIndicesArrayFormatInFormData in install generator (@skryukov)
19
+ * Add Kickstart templates to awesome page (@alec-c4)
20
+ * Improve generators for TypeScript users (@Andy9822)
21
+ * Update example pages to mimic Rails styling and appear at root path by default (@capripot)
22
+ * Update error types in install templates (@skryukov)
23
+
24
+ ## [3.13.0] - 2025-11-19
25
+
26
+ * Update installers (@skryukov)
27
+ * Update scaffolds (@skryukov)
28
+ * Remove Svelte 4 option in installation generators (@skryukov)
29
+
7
30
  ## [3.12.1] - 2025-11-09
8
31
 
9
32
  * Fix scroll props and deferred props for shared data (@bknoles)
@@ -2,7 +2,7 @@
2
2
  class <%= class_name %>Controller < <%= parent_class_name.classify %>
3
3
  <% actions.each do |action| -%>
4
4
  def <%= action %>
5
- render inertia: '<%= "#{inertia_base_path}/#{action.camelize}" %>'
5
+ render inertia: true
6
6
  end
7
7
  <%= "\n" unless action == actions.last -%>
8
8
  <% end -%>
@@ -12,15 +12,12 @@ react:
12
12
  vite_plugin_import: "import react from '@vitejs/plugin-react'"
13
13
  vite_plugin_call: "react()"
14
14
  copy_files_ts:
15
- "InertiaExample.tsx": "%{js_destination_path}/pages/InertiaExample.tsx"
16
- "tsconfig.json": "tsconfig.json"
17
- "tsconfig.app.json": "tsconfig.app.json"
18
- "tsconfig.node.json": "tsconfig.node.json"
19
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
15
+ "InertiaExample.tsx": "%{js_destination_path}/pages/inertia_example/index.tsx"
20
16
  copy_files_js:
21
- "InertiaExample.jsx": "%{js_destination_path}/pages/InertiaExample.jsx"
17
+ "InertiaExample.jsx": "%{js_destination_path}/pages/inertia_example/index.jsx"
22
18
  copy_files:
23
- "InertiaExample.module.css": "%{js_destination_path}/pages/InertiaExample.module.css"
19
+ "InertiaExample.module.css": "%{js_destination_path}/pages/inertia_example/index.module.css"
20
+ "../assets/rails.svg": "%{js_destination_path}/assets/rails.svg"
24
21
  "../assets/react.svg": "%{js_destination_path}/assets/react.svg"
25
22
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
26
23
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
@@ -37,43 +34,14 @@ vue:
37
34
  vite_plugin_import: "import vue from '@vitejs/plugin-vue'"
38
35
  vite_plugin_call: "vue()"
39
36
  copy_files:
37
+ "../assets/rails.svg": "%{js_destination_path}/assets/rails.svg"
40
38
  "../assets/vue.svg": "%{js_destination_path}/assets/vue.svg"
41
39
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
42
40
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
43
41
  copy_files_ts:
44
- "InertiaExample.ts.vue": "%{js_destination_path}/pages/InertiaExample.vue"
45
- "tsconfig.json": "tsconfig.json"
46
- "tsconfig.app.json": "tsconfig.app.json"
47
- "tsconfig.node.json": "tsconfig.node.json"
48
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
42
+ "InertiaExample.ts.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
49
43
  copy_files_js:
50
- "InertiaExample.vue": "%{js_destination_path}/pages/InertiaExample.vue"
51
-
52
- svelte4:
53
- inertia_package: "@inertiajs/svelte"
54
- packages:
55
- - "svelte@4"
56
- - "@sveltejs/vite-plugin-svelte@3"
57
- - "vite@5"
58
- packages_ts:
59
- - "@tsconfig/svelte@4"
60
- - "svelte-check"
61
- - "typescript"
62
- - "tslib"
63
- vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
64
- vite_plugin_call: "svelte()"
65
- copy_files_ts:
66
- "InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
67
- "tsconfig.json": "tsconfig.json"
68
- "tsconfig.node.json": "tsconfig.node.json"
69
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
70
- copy_files_js:
71
- "InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
72
- copy_files:
73
- "svelte.config.js": "svelte.config.js"
74
- "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg"
75
- "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
76
- "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
44
+ "InertiaExample.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
77
45
 
78
46
  svelte:
79
47
  inertia_package: "@inertiajs/svelte"
@@ -89,14 +57,11 @@ svelte:
89
57
  vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
90
58
  vite_plugin_call: "svelte()"
91
59
  copy_files_ts:
92
- "InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
93
- "tsconfig.json": "tsconfig.json"
94
- "tsconfig.node.json": "tsconfig.node.json"
95
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
60
+ "InertiaExample.ts.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
96
61
  copy_files_js:
97
- "InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
62
+ "InertiaExample.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
98
63
  copy_files:
99
- "svelte.config.js": "svelte.config.js"
64
+ "../assets/rails.svg": "%{js_destination_path}/assets/rails.svg"
100
65
  "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg"
101
66
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
102
67
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
@@ -65,9 +65,21 @@ module Inertia
65
65
  install_example_page if options[:example_page]
66
66
 
67
67
  say 'Copying bin/dev'
68
- copy_file "#{__dir__}/templates/dev", 'bin/dev'
68
+ copy_file 'dev', 'bin/dev'
69
69
  chmod 'bin/dev', 0o755, verbose: verbose?
70
70
 
71
+ if install_vite?
72
+ say 'Adding redirect to localhost'
73
+ routing_code = <<~RUBY
74
+ \n # Redirect to localhost from 127.0.0.1 to use same IP address with Vite server
75
+ constraints(host: "127.0.0.1") do
76
+ get "(*path)", to: redirect { |params, req| "\#{req.protocol}localhost:\#{req.port}/\#{params[:path]}" }
77
+ end
78
+ RUBY
79
+
80
+ route routing_code
81
+ end
82
+
71
83
  say "Inertia's Rails adapter successfully installed", :green
72
84
  end
73
85
 
@@ -87,30 +99,39 @@ module Inertia
87
99
  end
88
100
 
89
101
  say "Copying #{inertia_entrypoint} entrypoint"
90
- template "#{framework}/#{inertia_entrypoint}", js_file_path("entrypoints/#{inertia_entrypoint}")
102
+ copy_file "#{framework}/#{inertia_entrypoint}", js_file_path("entrypoints/#{inertia_entrypoint}")
103
+
104
+ # Copy framework-specific config files
105
+ if svelte?
106
+ say 'Copying svelte.config.js'
107
+ copy_file 'svelte/svelte.config.js', file_path('svelte.config.js')
108
+ end
109
+
110
+ say 'Copying InertiaController'
111
+ copy_file 'inertia_controller.rb', file_path('app/controllers/inertia_controller.rb')
91
112
 
92
113
  if application_layout.exist?
93
114
  say "Adding #{inertia_entrypoint} script tag to the application layout"
94
115
  headers = <<-ERB
95
- <%= #{vite_tag} "inertia" %>
116
+ <%= #{vite_tag} %>
96
117
  <%= inertia_ssr_head %>
97
118
  ERB
98
119
  insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n"
99
120
 
100
- if framework == 'react' && !application_layout.read.include?('vite_react_refresh_tag')
121
+ if react? && !application_layout.read.include?('vite_react_refresh_tag')
101
122
  say 'Adding Vite React Refresh tag to the application layout'
102
123
  insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ",
103
124
  before: '<%= vite_client_tag %>'
104
125
  end
105
126
 
106
- gsub_file application_layout.to_s, /<title>/, '<title inertia>' unless svelte?
127
+ gsub_file application_layout.to_s, /<title>/, '<title data-inertia>' unless svelte?
107
128
  else
108
129
  say_error 'Could not find the application layout file. Please add the following tags manually:', :red
109
130
  say_error '- <title>...</title>'
110
- say_error '+ <title inertia>...</title>'
131
+ say_error '+ <title data-inertia>...</title>'
111
132
  say_error '+ <%= inertia_ssr_head %>'
112
- say_error '+ <%= vite_react_refresh_tag %>' if framework == 'react'
113
- say_error "+ <%= #{vite_tag} \"inertia\" %>"
133
+ say_error '+ <%= vite_react_refresh_tag %>' if react?
134
+ say_error "+ <%= #{vite_tag} %>"
114
135
  end
115
136
  end
116
137
 
@@ -127,14 +148,30 @@ module Inertia
127
148
 
128
149
  add_dependencies(*FRAMEWORKS[framework]['packages_ts'])
129
150
 
130
- say 'Copying adding scripts to package.json'
151
+ say 'Copying tsconfig and types'
152
+
153
+ # Copy tsconfig files
154
+ tsconfig_files = %w[tsconfig.json tsconfig.node.json]
155
+ tsconfig_files << 'tsconfig.app.json' unless svelte?
156
+
157
+ tsconfig_files.each do |file|
158
+ template "#{framework}/#{file}", file_path(file)
159
+ end
160
+
161
+ # Copy type definition files
162
+ types_files = %w[types/vite-env.d.ts types/globals.d.ts types/index.ts]
163
+ types_files.each do |file|
164
+ template "#{framework}/#{file}", file_path("#{js_destination_path}/#{file}")
165
+ end
166
+
167
+ say 'Adding TypeScript check scripts to package.json'
131
168
  if svelte?
132
169
  run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"'
133
- end
134
- if framework == 'vue'
170
+ elsif react?
171
+ run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
172
+ elsif vue?
135
173
  run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
136
174
  end
137
- run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'react'
138
175
  end
139
176
 
140
177
  def install_example_page
@@ -143,6 +180,7 @@ module Inertia
143
180
 
144
181
  say 'Adding a route for the example Inertia controller'
145
182
  route "get 'inertia-example', to: 'inertia_example#index'"
183
+ route "root 'inertia_example#index'" unless File.read(file_path('config/routes.rb')).match?(/^\s*root\s+/)
146
184
 
147
185
  say 'Copying page assets'
148
186
  copy_files = FRAMEWORKS[framework]['copy_files'].merge(
@@ -186,16 +224,28 @@ module Inertia
186
224
  exit(false)
187
225
  end
188
226
  if (capture = run('bundle exec vite install', capture: !verbose?))
227
+ rename_application_js_to_ts if typescript?
189
228
  say 'Vite Rails successfully installed', :green
190
229
  else
191
230
  say capture
192
231
  say_error 'Failed to install Vite Rails', :red
193
232
  exit(false)
194
233
  end
234
+
235
+ add_package_manager_to_bin_setup
195
236
  end
196
237
  end
197
238
  end
198
239
 
240
+ def rename_application_js_to_ts
241
+ return unless File.exist?(application_js_path)
242
+ return unless application_layout.read.include?("<%= vite_javascript_tag 'application' %>")
243
+
244
+ FileUtils.mv(application_js_path, application_ts_path)
245
+ gsub_file application_layout.to_s, /<%= vite_javascript_tag 'application' %>/,
246
+ "<%= vite_typescript_tag 'application' %>"
247
+ end
248
+
199
249
  def ruby_vite_installed?
200
250
  return true if package_manager.present? && ruby_vite?
201
251
 
@@ -257,12 +307,22 @@ module Inertia
257
307
  @typescript = options[:typescript] || yes?('Would you like to use TypeScript? (y/n)', :green)
258
308
  end
259
309
 
310
+ def application_js_path
311
+ js_file_path('entrypoints/application.js')
312
+ end
313
+
314
+ def application_ts_path
315
+ js_file_path('entrypoints/application.ts')
316
+ end
317
+
260
318
  def inertia_entrypoint
261
- "inertia.#{typescript? ? 'ts' : 'js'}"
319
+ "inertia.#{typescript? ? 'ts' : 'js'}#{'x' if react?}"
262
320
  end
263
321
 
264
322
  def vite_tag
265
- typescript? ? 'vite_typescript_tag' : 'vite_javascript_tag'
323
+ tag = typescript? ? 'vite_typescript_tag' : 'vite_javascript_tag'
324
+ filename = "\"#{react? ? inertia_entrypoint : 'inertia'}\""
325
+ "#{tag} #{filename}"
266
326
  end
267
327
 
268
328
  def inertia_resolved_version
@@ -280,6 +340,14 @@ module Inertia
280
340
  framework.start_with? 'svelte'
281
341
  end
282
342
 
343
+ def react?
344
+ framework.start_with? 'react'
345
+ end
346
+
347
+ def vue?
348
+ framework.start_with? 'vue'
349
+ end
350
+
283
351
  def inertia_package
284
352
  "#{FRAMEWORKS[framework]['inertia_package']}@#{options[:inertia_version]}"
285
353
  end
@@ -288,6 +356,26 @@ module Inertia
288
356
  @framework ||= options[:framework] || ask('What framework do you want to use with Inertia?', :green,
289
357
  limited_to: FRAMEWORKS.keys, default: 'react')
290
358
  end
359
+
360
+ def add_package_manager_to_bin_setup
361
+ setup_file = file_path('bin/setup')
362
+ return unless File.exist?(setup_file)
363
+
364
+ content = File.read(setup_file)
365
+ pm_name = package_manager.name
366
+
367
+ # Check if package manager install already exists
368
+ return if content.include?("#{pm_name} install")
369
+
370
+ if content.include?('system("bundle check") || system!("bundle install")')
371
+ say 'Adding package manager install to bin/setup'
372
+ cmd = "system! \"#{pm_name} install\""
373
+ insert_into_file setup_file, "\n #{cmd}",
374
+ after: 'system("bundle check") || system!("bundle install")'
375
+ else
376
+ say_status "Couldn't add `#{cmd}` script to bin/setup, add it manually", :red
377
+ end
378
+ end
291
379
  end
292
380
  end
293
381
  end
@@ -12,22 +12,22 @@ module Inertia
12
12
  end
13
13
 
14
14
  def present?
15
- package_manager.present?
15
+ name.present?
16
16
  end
17
17
 
18
18
  def add_dependencies(*dependencies)
19
19
  options = @generator.options[:verbose] ? '' : ' --silent'
20
20
  @generator.in_root do
21
- @generator.run "#{package_manager} add #{dependencies.join(' ')}#{options}"
21
+ @generator.run "#{name} add #{dependencies.join(' ')}#{options}"
22
22
  end
23
23
  end
24
24
 
25
- private
26
-
27
- def package_manager
28
- @package_manager ||= @generator.options[:package_manager] || detect_package_manager
25
+ def name
26
+ @name ||= @generator.options[:package_manager] || detect_package_manager
29
27
  end
30
28
 
29
+ private
30
+
31
31
  def detect_package_manager
32
32
  return nil unless file?('package.json')
33
33
 
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4
+ <g id="rails">
5
+ <path d="M100,50 C100,22.38575 77.61425,0 50,0 C22.38575,0 0,22.38575 0,50 C0,77.61425 22.38575,100 50,100 C77.61425,100 100,77.61425 100,50 Z" id="Path" fill="#D30001"></path>
6
+ <path d="M93.892357,43.4595403 L93.892357,47.5730437 L86.5920182,47.5730437 L86.5920182,49.4715837 L90.2760899,49.4715837 C92.248599,49.4715837 94.348624,50.9380148 94.474087,53.4380961 L94.48,53.6754938 L94.48,55.2576105 C94.392176,58.2655695 91.9368789,59.3966123 90.4084611,59.4587878 L90.2760899,59.4615206 L82.8853448,59.4615206 L82.8853448,55.3706188 L90.3664966,55.3480172 L90.3664966,53.3590705 L86.8858399,53.3590705 C85.1105816,53.3590705 82.8040078,52.0201552 82.6658457,49.4041504 L82.6593281,49.1551604 L82.6593281,47.7312554 C82.6593281,45.0330152 84.937541,43.5484024 86.7247921,43.4634063 L86.8858399,43.4595403 L93.892357,43.4595403 Z M75.200778,43.4595403 L75.200778,55.3254155 L81.3710331,55.3254155 L81.3710331,59.4615206 L70.6352412,59.4615206 L70.6352412,43.4595403 L75.200778,43.4595403 Z M68.7593029,43.4595403 L68.7593029,59.4615206 L64.1711644,59.4615206 L64.1711644,43.4595403 L68.7593029,43.4595403 Z M53.5483809,43.4595403 L57.955706,43.4595403 L58.14343,43.4662215 C58.1772909,43.468495 58.2123757,43.4713714 58.2485901,43.4748858 L58.4786776,43.5039036 C59.7700605,43.7024512 62.0250592,44.6252852 62.1538484,47.4107623 L62.1596161,47.6634504 L62.1596161,59.4615206 L57.887901,59.4615206 L57.887901,56.6363122 L53.7517959,56.6363122 L53.7517959,59.4615206 L49.3444708,59.4615206 L49.3444708,47.6634504 C49.3444708,46.3450198 50.3485534,43.6166009 53.2913698,43.4660394 L53.5483809,43.4595403 Z M33.808529,43.4567822 L42.3887147,43.4573571 L42.6276381,43.4941033 L42.775584,43.5235203 L43.0497001,43.5888785 L43.2622199,43.6487853 L43.4945424,43.7235035 C43.5347217,43.7372739 43.5755826,43.7517236 43.6170534,43.7668839 L43.8726225,43.8666215 L44.1393843,43.9849067 C45.4954358,44.6251933 47.1420698,46.017065 47.1420698,49.0012007 C47.1420698,52.1842788 45.5955457,53.5026906 44.4432336,54.0432484 L44.2322685,54.1357529 L44.0333857,54.2116184 L43.849428,54.272437 L43.6832382,54.3198006 L43.4734874,54.3691007 L43.2138381,54.410937 L48.2195276,59.4615206 L41.8445687,59.4615206 L38.1183604,55.60063 L38.1183604,59.4615206 L33.808529,59.4615206 L33.808529,43.4567822 Z M55.8155893,40.3698629 L56.260581,40.7925436 L56.017613,40.9705317 L55.6693799,41.2398682 L55.4695226,41.4027886 C50.2296259,37.5282171 45.8218772,35.9806477 42.2724036,35.5874349 L41.7464229,35.5369641 C40.7073487,35.4527515 39.7456368,35.467154 38.8619927,35.5485103 L38.4266795,35.5946214 C38.3552127,35.6031876 38.2842888,35.6121822 38.2139083,35.6215867 L37.7981488,35.6827872 L37.3954497,35.7529479 L37.0058303,35.8311894 L36.6293105,35.9166321 C36.5676499,35.9314238 36.5065359,35.9464789 36.445969,35.9617791 L36.0891351,36.0563748 L35.7454497,36.155973 L35.4149323,36.2596943 L35.0976026,36.3666592 L34.7934801,36.4759882 L34.5025845,36.5868019 L34.0910843,36.7538822 L33.5888941,36.9736437 L32.9355205,37.2825393 L32.3254155,37.5831068 C27.6265289,40.2050856 25.4714861,44.4291779 24.5572153,48.4697531 L24.4349052,49.0455369 C24.3968548,49.2369202 24.3614774,49.4276945 24.328632,49.617667 L24.2375516,50.1849866 L24.1608198,50.7463387 L24.0975923,51.3005664 C24.0881329,51.3922798 24.0792009,51.4836481 24.0707789,51.5746472 L24.0262249,52.1160194 L23.9930648,52.647375 C23.9884406,52.7350353 23.9842561,52.8222301 23.9804935,52.9089352 L23.962841,53.423097 L23.9544717,53.9243501 L23.9545413,54.4115377 L23.9686219,55.1134156 L23.9969414,55.7771385 L24.0366503,56.3988022 L24.0848995,56.9745021 L24.1388397,57.5003338 L24.2146878,58.1171217 L24.288834,58.6290587 L24.3688342,59.1074343 L24.4374337,59.4615206 L6.5821167,59.4615206 L6.6406067,59.0197953 L6.6869435,58.7246505 L6.7499641,58.3599263 L6.863246,57.7707194 L6.9726247,57.2556287 L7.1546512,56.4771199 L7.3207888,55.8284427 L7.4467121,55.3668484 L7.6597595,54.6330259 L7.818725,54.1175217 L7.9918978,53.5820518 L8.1798441,53.0275292 L8.3831298,52.4548672 L8.6023211,51.8649789 L8.8379839,51.2587775 L9.0906843,50.6371763 C9.1342523,50.5323435 9.1785537,50.4269072 9.2236005,50.3208862 L9.5029185,49.6778975 L9.8006892,49.0217919 L10.1174786,48.3534827 L10.4538526,47.673883 L10.8103775,46.983906 C11.1771664,46.2890449 11.5750304,45.5799876 12.0065168,44.8608436 C16.7528669,36.9502602 24.8442637,30.9608184 31.4213488,30.373175 C36.4667294,29.8677656 41.3138924,31.3008573 45.3657116,33.2528185 L46.0156974,33.5736767 L46.6511742,33.902286 L47.2715761,34.237301 C47.3736887,34.2935959 47.4751497,34.3501017 47.5759471,34.4067902 L48.1726757,34.7488915 L48.7529147,35.0940354 L49.3160983,35.4408765 L49.8616607,35.7880697 L50.389036,36.1342696 L50.8976583,36.478131 C50.9808345,36.5351716 51.0632058,36.5920587 51.1447603,36.6487643 L51.6241923,36.9865955 L52.0834567,37.3187249 L52.5219877,37.6438074 L52.9392194,37.9604976 L53.523893,38.4168545 L54.0574604,38.8467616 L54.6860841,39.3709795 L55.3324273,39.932381 L55.8155893,40.3698629 Z M25.1154837,54.9411872 L27.5564638,55.8226522 C27.6694721,56.7078841 27.8295672,57.5460293 27.9975102,58.3109283 L28.0989038,58.7608689 L25.3867037,57.7889972 L25.352869,57.5768354 L25.2868269,57.1012511 L25.2256668,56.5600316 C25.1776383,56.0825714 25.1380854,55.5401313 25.1154837,54.9411872 Z M56.6222076,47.279222 L55.1078959,47.279222 C54.1678721,47.279222 53.8687735,47.688994 53.7736058,47.949758 L53.7453792,48.0447919 C53.7421422,48.0588649 53.7395526,48.0719445 53.737481,48.0838651 L53.7293237,48.155389 L53.7291942,52.0707754 L57.8652993,52.0707754 L57.863446,48.136006 L57.8531848,48.0690147 L57.8274641,47.9702906 C57.7439284,47.7111399 57.4765506,47.279222 56.6222076,47.279222 L56.6222076,47.279222 Z M6.1300834,47.618247 L8.7292751,48.567517 L8.3206341,49.5191009 C8.1081459,50.0185653 7.8928545,50.5339151 7.7172766,50.9768459 L7.5991917,51.2797171 L5,50.3304471 L5.1323662,49.9851438 L5.3907551,49.3459404 L5.6964662,48.617743 L6.0219537,47.8641186 C6.0581975,47.7813243 6.0942974,47.6992363 6.1300834,47.618247 L6.1300834,47.618247 Z M41.5752043,47.4748021 L38.1183604,47.4748021 L38.1183604,51.1336694 L41.5527572,51.1336694 L41.6074678,51.1082774 L41.6940662,51.0593791 L41.8088198,50.9806969 C42.1014626,50.7595521 42.5404269,50.2657172 42.5404269,49.2930122 C42.5404269,48.3203072 42.1114391,47.8364488 41.8254472,47.6219549 L41.7133017,47.5458808 L41.6286714,47.4989507 L41.5752043,47.4748021 Z M26.1325587,46.7141803 L27.7598788,48.0024754 C27.5790654,48.7076474 27.4416473,49.4128194 27.3476243,50.1179914 L27.2852437,50.6468704 L25.4545087,49.2003637 C25.6353221,48.3867037 25.8387371,47.550442 26.1325587,46.7141803 Z M30.1330538,40.4083152 L31.1501288,41.9452286 C30.7523395,42.3610993 30.3834803,42.7769699 30.0551233,43.2159847 L29.8166305,43.549947 L28.7317504,41.9226269 C29.1385804,41.4027886 29.6132155,40.8829502 30.1330538,40.4083152 L30.1330538,40.4083152 Z M13.9502602,37.0632685 L15.5549785,38.4645719 C15.1481485,38.8883531 14.754032,39.3375613 14.3821639,39.7931261 L14.0180652,40.2501036 L12.2777368,38.7583935 C12.7975751,38.1933519 13.3626168,37.6283102 13.9502602,37.0632685 L13.9502602,37.0632685 Z M36.3485123,36.9728618 L36.8457489,38.4645719 C36.3213903,38.6273039 35.7970316,38.8334311 35.2726729,39.0713814 L34.8794039,39.2556302 L34.3595655,37.6961152 C34.9246072,37.4474968 35.5800556,37.1988785 36.3485123,36.9728618 L36.3485123,36.9728618 Z M41.6373023,36.4304218 C42.215905,36.4665845 42.8089728,36.5316773 43.4165056,36.6372723 L43.8748674,36.7242435 L43.7844607,38.1255469 C43.1877767,37.9989775 42.5910927,37.9158034 41.9944087,37.8760245 L41.5468957,37.8543269 L41.6373023,36.4304218 Z M23.0813337,30.1923617 L24.0984087,31.7518767 C23.6576762,31.972243 23.2296571,32.2180361 22.7952813,32.479721 L22.3580803,32.7463501 L21.3184036,31.1642334 C21.9286486,30.8026067 22.516292,30.4861834 23.0813337,30.1923617 L23.0813337,30.1923617 Z M41.592099,30.8252084 L41.6825057,29.3334984 L42.126013,29.4640548 L42.5099933,29.58438 L42.8385391,29.6942879 L43.1157428,29.7935927 L43.4442343,29.9222617 L43.7407223,30.0549729 L43.8748674,30.1245567 L43.7844607,31.6388684 C43.3022918,31.4429873 42.8201229,31.2571514 42.3312572,31.0813606 L41.592099,30.8252084 Z M33.0486689,28 L33.5007022,29.3787017 L33.2746855,29.3787017 C32.7830993,29.3787017 32.291513,29.3914151 31.7999267,29.4263771 L31.3083405,29.4691084 L30.8789088,28.13561 C31.6247638,28.0452033 32.3480172,28 33.0486689,28 L33.0486689,28 Z" id="Shape" fill="#FFFFFF" fill-rule="nonzero"></path>
7
+ </g>
8
+ </g>
9
+ </svg>
@@ -1,9 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class InertiaExampleController < ApplicationController
3
+ class InertiaExampleController < InertiaController
4
4
  def index
5
- render inertia: 'InertiaExample', props: {
6
- name: params.fetch(:name, 'World'),
5
+ render inertia: {
6
+ rails_version: Rails.version,
7
+ ruby_version: RUBY_DESCRIPTION,
8
+ rack_version: Rack.release,
9
+ inertia_rails_version: InertiaRails::VERSION,
7
10
  }
8
11
  end
9
12
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class InertiaController < ApplicationController
4
+ inertia_share flash: -> { flash.to_hash }
5
+ end
@@ -1,60 +1,56 @@
1
1
  import { Head } from '@inertiajs/react'
2
- import { useState } from 'react'
2
+ import { version as react_version } from 'react'
3
3
 
4
+ import railsSvg from '/assets/rails.svg'
4
5
  import inertiaSvg from '/assets/inertia.svg'
5
6
  import reactSvg from '/assets/react.svg'
6
- import viteRubySvg from '/assets/vite_ruby.svg'
7
7
 
8
- import cs from './InertiaExample.module.css'
9
-
10
- export default function InertiaExample({ name }) {
11
- const [count, setCount] = useState(0)
8
+ import cs from './index.module.css'
12
9
 
10
+ export default function InertiaExample({ rails_version, ruby_version, rack_version, inertia_rails_version }) {
13
11
  return (
14
- <>
15
- <Head title="Inertia + Vite Ruby + React Example" />
16
-
17
- <div className={cs.root}>
18
- <h1 className={cs.h1}>Hello {name}!</h1>
19
-
20
- <div>
21
- <a href="https://inertia-rails.dev" target="_blank">
22
- <img className={cs.logo} src={inertiaSvg} alt="Inertia logo" />
23
- </a>
24
- <a href="https://vite-ruby.netlify.app" target="_blank">
25
- <img
26
- className={`${cs.logo} ${cs.vite}`}
27
- src={viteRubySvg}
28
- alt="Vite Ruby logo"
29
- />
30
- </a>
31
- <a href="https://react.dev" target="_blank">
32
- <img
33
- className={`${cs.logo} ${cs.react}`}
34
- src={reactSvg}
35
- alt="React logo"
36
- />
37
- </a>
38
- </div>
39
-
40
- <h2 className={cs.h2}>Inertia + Vite Ruby + React</h2>
41
-
42
- <div className="card">
43
- <button
44
- className={cs.button}
45
- onClick={() => setCount((count) => count + 1)}
46
- >
47
- count is {count}
48
- </button>
12
+ <div className={cs.root}>
13
+ <Head title="Ruby on Rails + Inertia + React" />
14
+
15
+ <nav className={cs.subNav}>
16
+ <a href="https://rubyonrails.org" target="_blank">
17
+ <img className={`${cs.logo} ${cs.rails}`} alt="Ruby on Rails Logo" src={railsSvg} />
18
+ </a>
19
+ <a href="https://inertia-rails.dev" target="_blank">
20
+ <img className={`${cs.logo} ${cs.inertia}`} src={inertiaSvg} alt="Inertia logo" />
21
+ </a>
22
+ <a href="https://react.dev" target="_blank">
23
+ <img
24
+ className={`${cs.logo} ${cs.react}`}
25
+ src={reactSvg}
26
+ alt="React logo"
27
+ />
28
+ </a>
29
+ </nav>
30
+
31
+ <div className={cs.footer}>
32
+ <div className={cs.card}>
49
33
  <p>
50
- Edit <code>app/frontend/pages/InertiaExample.jsx</code> and save to
51
- test HMR
34
+ Edit <code><%= js_destination_path %>/pages/inertia_example/index.jsx</code> and save to test <abbr title="Hot Module Replacement">HMR</abbr>.
52
35
  </p>
53
36
  </div>
54
- <p className={cs.readTheDocs}>
55
- Click on the Inertia, Vite Ruby, and React logos to learn more
56
- </p>
37
+
38
+ <ul>
39
+ <li>
40
+ <ul>
41
+ <li><strong>Rails version:</strong> {rails_version}</li>
42
+ <li><strong>Rack version:</strong> {rack_version}</li>
43
+ </ul>
44
+ </li>
45
+ <li><strong>Ruby version:</strong> {ruby_version}</li>
46
+ <li>
47
+ <ul>
48
+ <li><strong>Inertia Rails version:</strong> {inertia_rails_version}</li>
49
+ <li><strong>React version:</strong> {react_version}</li>
50
+ </ul>
51
+ </li>
52
+ </ul>
57
53
  </div>
58
- </>
54
+ </div>
59
55
  )
60
56
  }
@@ -1,60 +1,52 @@
1
1
  .root {
2
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
2
+ box-sizing: border-box;
3
+ margin: 0;
4
+ padding: 0;
5
+ align-items: center;
6
+ background-color: #F0E7E9;
7
+ background-image: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjEwMjQiIHZpZXdCb3g9IjAgMCAxNDQwIDEwMjQiIHdpZHRoPSIxNDQwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Im0xNDQwIDUxMC4wMDA2NDh2LTUxMC4wMDA2NDhoLTE0NDB2Mzg0LjAwMDY0OGM0MTcuMzExOTM5IDEzMS4xNDIxNzkgODkxIDE3MS41MTMgMTQ0MCAxMjZ6IiBmaWxsPSIjZmZmIi8+PC9zdmc+);
8
+ background-position: center center;
9
+ background-repeat: no-repeat;
10
+ background-size: cover;
11
+ color: #261B23;
12
+ display: flex;
13
+ flex-direction: column;
14
+ font-family: Sans-Serif;
15
+ font-size: calc(0.9em + 0.5vw);
16
+ font-style: normal;
4
17
  font-weight: 400;
5
- color: #213547;
6
- background-color: #ffffff;
7
- max-width: 1280px;
8
- margin: 0 auto;
9
- padding: 2rem;
18
+ justify-content: center;
19
+ line-height: 1.25;
20
+ min-height: 100vh;
10
21
  text-align: center;
11
22
  }
12
23
 
13
- .h1 {
14
- font-size: 3.2em;
15
- line-height: 1.1;
16
- }
17
-
18
- .h2 {
19
- font-size: 2.6em;
20
- line-height: 1.1;
21
- }
22
-
23
- .button {
24
- border-radius: 8px;
25
- border: 1px solid transparent;
26
- padding: 0.6em 1.2em;
27
- font-size: 1em;
28
- font-weight: 500;
29
- font-family: inherit;
30
- background-color: #f9f9f9;
31
- cursor: pointer;
32
- transition: border-color 0.25s;
33
- }
34
- .button:hover {
35
- border-color: #646cff;
36
- }
37
- .button:focus,
38
- .button:focus-visible {
39
- outline: 4px auto -webkit-focus-ring-color;
24
+ @media (prefers-color-scheme: dark) {
25
+ .root {
26
+ background-color: #1a1a1a;
27
+ background-image: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjEwMjQiIHZpZXdCb3g9IjAgMCAxNDQwIDEwMjQiIHdpZHRoPSIxNDQwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Im0xNDQwIDUxMC4wMDA2NDh2LTUxMC4wMDA2NDhoLTE0NDB2Mzg0LjAwMDY0OGM0MTcuMzExOTM5IDEzMS4xNDIxNzkgODkxIDE3MS41MTMgMTQ0MCAxMjZ6IiBmaWxsPSIjMzMzIi8+PC9zdmc+);
28
+ color: #e0e0e0;
29
+ }
40
30
  }
41
31
 
42
32
  .logo {
43
33
  display: inline-block;
44
- height: 6em;
34
+ height: 9.8vw;
35
+ min-height: 130px;
45
36
  padding: 1.5em;
46
37
  will-change: filter;
47
38
  transition: filter 300ms;
39
+ filter: drop-shadow(0 20px 13px rgb(0 0 0 / 0.03)) drop-shadow(0 8px 5px rgb(0 0 0 / 0.08));
48
40
  }
49
- .logo:hover {
41
+ .logo.inertia:hover {
50
42
  filter: drop-shadow(0 0 2em #646cffaa);
51
43
  }
52
- .logo.vite:hover {
53
- filter: drop-shadow(0 0 2em #e4023baa);
54
- }
55
44
  .logo.react:hover {
56
45
  filter: drop-shadow(0 0 2em #61dafbaa);
57
46
  }
47
+ .logo.rails:hover {
48
+ filter: drop-shadow(0 0 2em rgb(211 0 1 / 0.6));
49
+ }
58
50
 
59
51
  @keyframes logo-spin {
60
52
  from {
@@ -71,10 +63,40 @@
71
63
  }
72
64
  }
73
65
 
66
+ @media (prefers-color-scheme: dark) {
67
+ .logo {
68
+ filter: drop-shadow(0 20px 13px rgb(255 255 255 / 0.03)) drop-shadow(0 8px 5px rgb(255 255 255 / 0.08));
69
+ }
70
+ }
71
+
74
72
  .card {
75
73
  padding: 2em;
74
+ font-size: 0.7em;
75
+ color: #948e90;
76
+ }
77
+
78
+ .footer {
79
+ bottom: 0;
80
+ left: 0;
81
+ margin: 0 2rem 2rem 2rem;
82
+ position: absolute;
83
+ right: 0;
84
+ }
85
+
86
+ .footer ul {
87
+ list-style: none;
88
+ }
89
+
90
+ .footer ul li {
91
+ display: inline;
92
+ }
93
+
94
+ .footer ul ul li:after {
95
+ content: " | ";
96
+ font-weight: 300;
97
+ color: #948e90;
76
98
  }
77
99
 
78
- .read-the-docs {
79
- color: #888;
100
+ .footer ul ul li:last-child:after {
101
+ content: "";
80
102
  }