inertia_rails 3.12.1 → 3.13.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 (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/generators/inertia/controller/templates/controller.rb.tt +1 -1
  4. data/lib/generators/inertia/install/frameworks.yml +16 -36
  5. data/lib/generators/inertia/install/install_generator.rb +51 -8
  6. data/lib/generators/inertia/install/js_package_manager.rb +6 -6
  7. data/lib/generators/inertia/install/templates/controller.rb +2 -4
  8. data/lib/generators/inertia/install/templates/inertia_controller.rb +5 -0
  9. data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +2 -2
  10. data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +2 -2
  11. data/lib/generators/inertia/install/templates/react/inertia.jsx +65 -0
  12. data/lib/generators/inertia/install/templates/react/inertia.tsx +65 -0
  13. data/lib/generators/inertia/install/templates/react/tsconfig.app.json +7 -0
  14. data/lib/generators/inertia/install/templates/react/types/globals.d.ts +8 -0
  15. data/lib/generators/inertia/install/templates/react/types/index.ts +8 -0
  16. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +1 -1
  17. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +1 -1
  18. data/lib/generators/inertia/install/templates/svelte/inertia.js +14 -3
  19. data/lib/generators/inertia/install/templates/svelte/{inertia.ts.tt → inertia.ts} +12 -2
  20. data/lib/generators/inertia/install/templates/svelte/tsconfig.json +8 -0
  21. data/lib/generators/inertia/install/templates/svelte/types/globals.d.ts +8 -0
  22. data/lib/generators/inertia/install/templates/svelte/types/index.ts +8 -0
  23. data/lib/generators/inertia/install/templates/tailwind/application.css +3 -3
  24. data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +1 -1
  25. data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +1 -1
  26. data/lib/generators/inertia/install/templates/vue/inertia.js +30 -3
  27. data/lib/generators/inertia/install/templates/vue/inertia.ts +31 -3
  28. data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +9 -1
  29. data/lib/generators/inertia/install/templates/vue/types/globals.d.ts +8 -0
  30. data/lib/generators/inertia/install/templates/vue/types/index.ts +8 -0
  31. data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +4 -0
  32. data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +7 -5
  33. data/lib/generators/inertia_templates/scaffold/templates/react/{Edit.jsx.tt → edit.jsx.tt} +5 -8
  34. data/lib/generators/inertia_templates/scaffold/templates/react/{Edit.tsx.tt → edit.tsx.tt} +7 -9
  35. data/lib/generators/inertia_templates/scaffold/templates/react/form.jsx.tt +94 -0
  36. data/lib/generators/inertia_templates/scaffold/templates/react/form.tsx.tt +109 -0
  37. data/lib/generators/inertia_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt} +1 -1
  38. data/lib/generators/inertia_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt} +1 -1
  39. data/lib/generators/inertia_templates/scaffold/templates/react/{New.jsx.tt → new.jsx.tt} +3 -5
  40. data/lib/generators/inertia_templates/scaffold/templates/react/{New.tsx.tt → new.tsx.tt} +5 -6
  41. data/lib/generators/inertia_templates/scaffold/templates/react/{Show.jsx.tt → show.jsx.tt} +1 -1
  42. data/lib/generators/inertia_templates/scaffold/templates/react/{Show.tsx.tt → show.tsx.tt} +1 -1
  43. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt} +9 -13
  44. data/lib/generators/inertia_templates/scaffold/templates/{svelte4/Edit.svelte.tt → svelte/edit.ts.svelte.tt} +11 -15
  45. data/lib/generators/inertia_templates/scaffold/templates/svelte/form.svelte.tt +96 -0
  46. data/lib/generators/inertia_templates/scaffold/templates/svelte/form.ts.svelte.tt +103 -0
  47. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt} +1 -1
  48. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.ts.svelte.tt → index.ts.svelte.tt} +1 -1
  49. data/lib/generators/inertia_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt} +4 -7
  50. data/lib/generators/inertia_templates/scaffold/templates/{svelte4/New.svelte.tt → svelte/new.ts.svelte.tt} +6 -9
  51. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt} +1 -1
  52. data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.ts.svelte.tt → show.ts.svelte.tt} +1 -1
  53. data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt} +11 -15
  54. data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.vue.tt → edit.vue.tt} +9 -13
  55. data/lib/generators/inertia_templates/scaffold/templates/vue/form.ts.vue.tt +102 -0
  56. data/lib/generators/inertia_templates/scaffold/templates/vue/form.vue.tt +98 -0
  57. data/lib/generators/inertia_templates/scaffold/templates/vue/{Index.ts.vue.tt → index.ts.vue.tt} +1 -1
  58. data/lib/generators/inertia_templates/scaffold/templates/vue/{Index.vue.tt → index.vue.tt} +1 -1
  59. data/lib/generators/inertia_templates/scaffold/templates/vue/{New.ts.vue.tt → new.ts.vue.tt} +6 -9
  60. data/lib/generators/inertia_templates/scaffold/templates/vue/{New.vue.tt → new.vue.tt} +4 -7
  61. data/lib/generators/inertia_templates/scaffold/templates/vue/{Show.ts.vue.tt → show.ts.vue.tt} +1 -1
  62. data/lib/generators/inertia_templates/scaffold/templates/vue/{Show.vue.tt → show.vue.tt} +1 -1
  63. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Edit.jsx.tt → edit.jsx.tt} +5 -8
  64. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Edit.tsx.tt → edit.tsx.tt} +6 -9
  65. data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.jsx.tt +106 -0
  66. data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.tsx.tt +122 -0
  67. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt} +1 -1
  68. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt} +1 -1
  69. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{New.jsx.tt → new.jsx.tt} +3 -5
  70. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{New.tsx.tt → new.tsx.tt} +4 -6
  71. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Show.jsx.tt → show.jsx.tt} +1 -1
  72. data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Show.tsx.tt → show.tsx.tt} +1 -1
  73. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt} +9 -13
  74. data/lib/generators/inertia_tw_templates/scaffold/templates/{svelte4/Edit.svelte.tt → svelte/edit.ts.svelte.tt} +11 -15
  75. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.svelte.tt +109 -0
  76. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.ts.svelte.tt +115 -0
  77. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt} +1 -1
  78. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Index.ts.svelte.tt → index.ts.svelte.tt} +1 -1
  79. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt} +4 -6
  80. data/lib/generators/inertia_tw_templates/scaffold/templates/{svelte4/New.svelte.tt → svelte/new.ts.svelte.tt} +6 -9
  81. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt} +1 -1
  82. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Show.ts.svelte.tt → show.ts.svelte.tt} +1 -1
  83. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt} +10 -15
  84. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Edit.vue.tt → edit.vue.tt} +8 -13
  85. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.ts.vue.tt → form.ts.vue.tt} +19 -42
  86. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.vue.tt → form.vue.tt} +18 -38
  87. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Index.ts.vue.tt → index.ts.vue.tt} +1 -1
  88. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Index.vue.tt → index.vue.tt} +1 -1
  89. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{New.ts.vue.tt → new.ts.vue.tt} +6 -9
  90. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{New.vue.tt → new.vue.tt} +4 -7
  91. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Show.ts.vue.tt → show.ts.vue.tt} +1 -1
  92. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Show.vue.tt → show.vue.tt} +1 -1
  93. data/lib/inertia_rails/generators/controller_template_base.rb +1 -1
  94. data/lib/inertia_rails/generators/helper.rb +2 -3
  95. data/lib/inertia_rails/generators/scaffold_template_base.rb +3 -3
  96. data/lib/inertia_rails/version.rb +1 -1
  97. metadata +87 -116
  98. data/lib/generators/inertia/install/templates/react/inertia.js +0 -45
  99. data/lib/generators/inertia/install/templates/react/inertia.ts +0 -51
  100. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +0 -116
  101. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +0 -116
  102. data/lib/generators/inertia/install/templates/svelte4/inertia.js +0 -43
  103. data/lib/generators/inertia/install/templates/svelte4/inertia.ts.tt +0 -44
  104. data/lib/generators/inertia/install/templates/svelte4/svelte.config.js +0 -7
  105. data/lib/generators/inertia/install/templates/svelte4/tsconfig.json +0 -21
  106. data/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +0 -12
  107. data/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +0 -2
  108. data/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +0 -2
  109. data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +0 -111
  110. data/lib/generators/inertia_templates/scaffold/templates/react/Form.tsx.tt +0 -130
  111. data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +0 -37
  112. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +0 -97
  113. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.ts.svelte.tt +0 -102
  114. data/lib/generators/inertia_templates/scaffold/templates/svelte/New.ts.svelte.tt +0 -30
  115. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +0 -38
  116. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +0 -96
  117. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +0 -106
  118. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +0 -36
  119. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +0 -37
  120. data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.ts.svelte.tt +0 -31
  121. data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +0 -28
  122. data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.ts.svelte.tt +0 -30
  123. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +0 -39
  124. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +0 -40
  125. data/lib/generators/inertia_templates/scaffold/templates/svelte4/types.ts.tt +0 -19
  126. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.ts.vue.tt +0 -101
  127. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +0 -94
  128. data/lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt +0 -2
  129. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +0 -122
  130. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.tsx.tt +0 -142
  131. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +0 -45
  132. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +0 -118
  133. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.ts.svelte.tt +0 -123
  134. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.ts.svelte.tt +0 -33
  135. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +0 -46
  136. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt +0 -120
  137. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +0 -130
  138. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt +0 -43
  139. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +0 -44
  140. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.ts.svelte.tt +0 -34
  141. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt +0 -28
  142. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.ts.svelte.tt +0 -30
  143. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt +0 -51
  144. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +0 -52
  145. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/types.ts.tt +0 -19
  146. /data/lib/generators/inertia/install/templates/react/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
  147. /data/lib/generators/inertia/install/templates/svelte/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
  148. /data/lib/generators/inertia/install/templates/vue/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
  149. /data/lib/generators/inertia_templates/scaffold/templates/react/{One.jsx.tt → one.jsx.tt} +0 -0
  150. /data/lib/generators/inertia_templates/scaffold/templates/react/{One.tsx.tt → one.tsx.tt} +0 -0
  151. /data/lib/generators/inertia_templates/scaffold/templates/svelte/{One.svelte.tt → one.svelte.tt} +0 -0
  152. /data/lib/generators/inertia_templates/scaffold/templates/svelte/{One.ts.svelte.tt → one.ts.svelte.tt} +0 -0
  153. /data/lib/generators/inertia_templates/scaffold/templates/vue/{One.ts.vue.tt → one.ts.vue.tt} +0 -0
  154. /data/lib/generators/inertia_templates/scaffold/templates/vue/{One.vue.tt → one.vue.tt} +0 -0
  155. /data/lib/generators/inertia_tw_templates/scaffold/templates/react/{One.jsx.tt → one.jsx.tt} +0 -0
  156. /data/lib/generators/inertia_tw_templates/scaffold/templates/react/{One.tsx.tt → one.tsx.tt} +0 -0
  157. /data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{One.svelte.tt → one.svelte.tt} +0 -0
  158. /data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{One.ts.svelte.tt → one.ts.svelte.tt} +0 -0
  159. /data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{One.ts.vue.tt → one.ts.vue.tt} +0 -0
  160. /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: 611e06ee0f1697740744921528223e862a4d4f7533fe195c40cfd5cdc8f6b7b4
4
+ data.tar.gz: 97f4302df2a4b8b1e09d36ae9f375942ce672079e247e7694f535fe1e5128206
5
5
  SHA512:
6
- metadata.gz: 86753985c32f435b2967144c8b88e22984d1999fd0e528ac862d9b2dcc081545d52841d54b984d8184cb7774681576aa03ce244b09016a79b0110067b1d69d7e
7
- data.tar.gz: 22197c8fc07a0f2d25402f04ab9988b3a572bd7c713ef8a391bf95bdb680bfac5a03c65c19796671d7172f921d1fdc900cc9f4f3d41420702e556a1a820a3942
6
+ metadata.gz: 4aeb2fa0fc8bc672d74ab72c702706a9ddc0a98d7e0f224a3a933d9b66173c6232e125f2cca76a6b43c6e85c8fd1d12aaaee2ff203f85ce2a64476c01f2e9ce7
7
+ data.tar.gz: 6f8b818fb214b5f0ea18cc0c3930bd35587dd5a7b310e66e86dd4cbde5add15654ef26280427890182b12fc09f23e71bc5e5e4467c46a46ed0f68c2f23028d66
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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.13.0] - 2025-11-19
8
+
9
+ * Update installers (@skryukov)
10
+ * Update scaffolds (@skryukov)
11
+ * Remove Svelte 4 option in installation generators (@skryukov)
12
+
7
13
  ## [3.12.1] - 2025-11-09
8
14
 
9
15
  * 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,17 @@ 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"
15
+ "InertiaExample.tsx": "%{js_destination_path}/pages/inertia_example/index.tsx"
16
16
  "tsconfig.json": "tsconfig.json"
17
17
  "tsconfig.app.json": "tsconfig.app.json"
18
18
  "tsconfig.node.json": "tsconfig.node.json"
19
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
19
+ "types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
20
+ "types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
21
+ "types/index.ts": "%{js_destination_path}/types/index.ts"
20
22
  copy_files_js:
21
- "InertiaExample.jsx": "%{js_destination_path}/pages/InertiaExample.jsx"
23
+ "InertiaExample.jsx": "%{js_destination_path}/pages/inertia_example/index.jsx"
22
24
  copy_files:
23
- "InertiaExample.module.css": "%{js_destination_path}/pages/InertiaExample.module.css"
25
+ "InertiaExample.module.css": "%{js_destination_path}/pages/inertia_example/index.module.css"
24
26
  "../assets/react.svg": "%{js_destination_path}/assets/react.svg"
25
27
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
26
28
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
@@ -41,39 +43,15 @@ vue:
41
43
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
42
44
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
43
45
  copy_files_ts:
44
- "InertiaExample.ts.vue": "%{js_destination_path}/pages/InertiaExample.vue"
46
+ "InertiaExample.ts.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
45
47
  "tsconfig.json": "tsconfig.json"
46
48
  "tsconfig.app.json": "tsconfig.app.json"
47
49
  "tsconfig.node.json": "tsconfig.node.json"
48
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
50
+ "types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
51
+ "types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
52
+ "types/index.ts": "%{js_destination_path}/types/index.ts"
49
53
  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"
54
+ "InertiaExample.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
77
55
 
78
56
  svelte:
79
57
  inertia_package: "@inertiajs/svelte"
@@ -89,12 +67,14 @@ svelte:
89
67
  vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
90
68
  vite_plugin_call: "svelte()"
91
69
  copy_files_ts:
92
- "InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
70
+ "InertiaExample.ts.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
93
71
  "tsconfig.json": "tsconfig.json"
94
72
  "tsconfig.node.json": "tsconfig.node.json"
95
- "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
73
+ "types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
74
+ "types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
75
+ "types/index.ts": "%{js_destination_path}/types/index.ts"
96
76
  copy_files_js:
97
- "InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
77
+ "InertiaExample.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
98
78
  copy_files:
99
79
  "svelte.config.js": "svelte.config.js"
100
80
  "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.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,12 +99,15 @@ 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
+ say 'Copying InertiaController'
105
+ copy_file 'inertia_controller.rb', file_path('app/controllers/inertia_controller.rb')
91
106
 
92
107
  if application_layout.exist?
93
108
  say "Adding #{inertia_entrypoint} script tag to the application layout"
94
109
  headers = <<-ERB
95
- <%= #{vite_tag} "inertia" %>
110
+ <%= #{vite_tag} %>
96
111
  <%= inertia_ssr_head %>
97
112
  ERB
98
113
  insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n"
@@ -103,14 +118,14 @@ module Inertia
103
118
  before: '<%= vite_client_tag %>'
104
119
  end
105
120
 
106
- gsub_file application_layout.to_s, /<title>/, '<title inertia>' unless svelte?
121
+ gsub_file application_layout.to_s, /<title>/, '<title data-inertia>' unless svelte?
107
122
  else
108
123
  say_error 'Could not find the application layout file. Please add the following tags manually:', :red
109
124
  say_error '- <title>...</title>'
110
- say_error '+ <title inertia>...</title>'
125
+ say_error '+ <title data-inertia>...</title>'
111
126
  say_error '+ <%= inertia_ssr_head %>'
112
127
  say_error '+ <%= vite_react_refresh_tag %>' if framework == 'react'
113
- say_error "+ <%= #{vite_tag} \"inertia\" %>"
128
+ say_error "+ <%= #{vite_tag} %>"
114
129
  end
115
130
  end
116
131
 
@@ -192,6 +207,8 @@ module Inertia
192
207
  say_error 'Failed to install Vite Rails', :red
193
208
  exit(false)
194
209
  end
210
+
211
+ add_package_manager_to_bin_setup
195
212
  end
196
213
  end
197
214
  end
@@ -258,11 +275,13 @@ module Inertia
258
275
  end
259
276
 
260
277
  def inertia_entrypoint
261
- "inertia.#{typescript? ? 'ts' : 'js'}"
278
+ "inertia.#{typescript? ? 'ts' : 'js'}#{'x' if react?}"
262
279
  end
263
280
 
264
281
  def vite_tag
265
- typescript? ? 'vite_typescript_tag' : 'vite_javascript_tag'
282
+ tag = typescript? ? 'vite_typescript_tag' : 'vite_javascript_tag'
283
+ filename = "\"#{react? ? inertia_entrypoint : 'inertia'}\""
284
+ "#{tag} #{filename}"
266
285
  end
267
286
 
268
287
  def inertia_resolved_version
@@ -280,6 +299,10 @@ module Inertia
280
299
  framework.start_with? 'svelte'
281
300
  end
282
301
 
302
+ def react?
303
+ framework.start_with? 'react'
304
+ end
305
+
283
306
  def inertia_package
284
307
  "#{FRAMEWORKS[framework]['inertia_package']}@#{options[:inertia_version]}"
285
308
  end
@@ -288,6 +311,26 @@ module Inertia
288
311
  @framework ||= options[:framework] || ask('What framework do you want to use with Inertia?', :green,
289
312
  limited_to: FRAMEWORKS.keys, default: 'react')
290
313
  end
314
+
315
+ def add_package_manager_to_bin_setup
316
+ setup_file = file_path('bin/setup')
317
+ return unless File.exist?(setup_file)
318
+
319
+ content = File.read(setup_file)
320
+ pm_name = package_manager.name
321
+
322
+ # Check if package manager install already exists
323
+ return if content.include?("#{pm_name} install")
324
+
325
+ if content.include?('system("bundle check") || system!("bundle install")')
326
+ say 'Adding package manager install to bin/setup'
327
+ cmd = "system! \"#{pm_name} install\""
328
+ insert_into_file setup_file, "\n #{cmd}",
329
+ after: 'system("bundle check") || system!("bundle install")'
330
+ else
331
+ say_status "Couldn't add `#{cmd}` script to bin/setup, add it manually", :red
332
+ end
333
+ end
291
334
  end
292
335
  end
293
336
  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
 
@@ -1,9 +1,7 @@
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'),
7
- }
5
+ render inertia: { name: params.fetch(:name, 'World') }
8
6
  end
9
7
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class InertiaController < ApplicationController
4
+ inertia_share flash: -> { flash.to_hash }
5
+ end
@@ -5,7 +5,7 @@ import inertiaSvg from '/assets/inertia.svg'
5
5
  import reactSvg from '/assets/react.svg'
6
6
  import viteRubySvg from '/assets/vite_ruby.svg'
7
7
 
8
- import cs from './InertiaExample.module.css'
8
+ import cs from './index.module.css'
9
9
 
10
10
  export default function InertiaExample({ name }) {
11
11
  const [count, setCount] = useState(0)
@@ -47,7 +47,7 @@ export default function InertiaExample({ name }) {
47
47
  count is {count}
48
48
  </button>
49
49
  <p>
50
- Edit <code>app/frontend/pages/InertiaExample.jsx</code> and save to
50
+ Edit <code>app/frontend/pages/inertia_example/index.jsx</code> and save to
51
51
  test HMR
52
52
  </p>
53
53
  </div>
@@ -5,7 +5,7 @@ import inertiaSvg from '/assets/inertia.svg'
5
5
  import reactSvg from '/assets/react.svg'
6
6
  import viteRubySvg from '/assets/vite_ruby.svg'
7
7
 
8
- import cs from './InertiaExample.module.css'
8
+ import cs from './index.module.css'
9
9
 
10
10
  export default function InertiaExample({ name }: { name: string }) {
11
11
  const [count, setCount] = useState(0)
@@ -47,7 +47,7 @@ export default function InertiaExample({ name }: { name: string }) {
47
47
  count is {count}
48
48
  </button>
49
49
  <p>
50
- Edit <code>app/frontend/pages/InertiaExample.jsx</code> and save to
50
+ Edit <code>app/frontend/pages/inertia_example/index.tsx</code> and save to
51
51
  test HMR
52
52
  </p>
53
53
  </div>
@@ -0,0 +1,65 @@
1
+ import { createInertiaApp } from '@inertiajs/react'
2
+ import { StrictMode } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+
5
+ createInertiaApp({
6
+ // Set default page title
7
+ // see https://inertia-rails.dev/guide/title-and-meta
8
+ //
9
+ // title: title => title ? `${title} - App` : 'App',
10
+
11
+ // Disable progress bar
12
+ //
13
+ // see https://inertia-rails.dev/guide/progress-indicators
14
+ // progress: false,
15
+
16
+ resolve: (name) => {
17
+ const pages = import.meta.glob('../pages/**/*.jsx', {
18
+ eager: true,
19
+ })
20
+ const page = pages[`../pages/${name}.jsx`]
21
+ if (!page) {
22
+ console.error(`Missing Inertia page component: '${name}.jsx'`)
23
+ }
24
+
25
+ // To use a default layout, import the Layout component
26
+ // and use the following lines.
27
+ // see https://inertia-rails.dev/guide/pages#default-layouts
28
+ //
29
+ // page.default.layout ||= (page) => (<Layout>{page}</Layout>)
30
+
31
+ return page
32
+ },
33
+
34
+ setup({ el, App, props }) {
35
+ createRoot(el).render(
36
+ <StrictMode>
37
+ <App {...props} />
38
+ </StrictMode>
39
+ )
40
+ },
41
+
42
+ defaults: {
43
+ form: {
44
+ forceIndicesArrayFormatInFormData: true,
45
+ },
46
+ future: {
47
+ useDataInertiaHeadAttribute: true,
48
+ useDialogForErrorModal: true,
49
+ preserveEqualProps: true,
50
+ },
51
+ },
52
+ }).catch((error) => {
53
+ // This ensures this entrypoint is only loaded on Inertia pages
54
+ // by checking for the presence of the root element (#app by default).
55
+ // Feel free to remove this `catch` if you don't need it.
56
+ if (document.getElementById("app")) {
57
+ throw error
58
+ } else {
59
+ console.error(
60
+ "Missing root element.\n\n" +
61
+ "If you see this error, it probably means you loaded Inertia.js on non-Inertia pages.\n" +
62
+ 'Consider moving <%= vite_javascript_tag "inertia.jsx" %> to the Inertia-specific layout instead.',
63
+ )
64
+ }
65
+ })
@@ -0,0 +1,65 @@
1
+ import { createInertiaApp, type ResolvedComponent } from '@inertiajs/react'
2
+ import { StrictMode } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+
5
+ void createInertiaApp({
6
+ // Set default page title
7
+ // see https://inertia-rails.dev/guide/title-and-meta
8
+ //
9
+ // title: title => title ? `${title} - App` : 'App',
10
+
11
+ // Disable progress bar
12
+ //
13
+ // see https://inertia-rails.dev/guide/progress-indicators
14
+ // progress: false,
15
+
16
+ resolve: (name) => {
17
+ const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.tsx', {
18
+ eager: true,
19
+ })
20
+ const page = pages[`../pages/${name}.tsx`]
21
+ if (!page) {
22
+ console.error(`Missing Inertia page component: '${name}.tsx'`)
23
+ }
24
+
25
+ // To use a default layout, import the Layout component
26
+ // and use the following line.
27
+ // see https://inertia-rails.dev/guide/pages#default-layouts
28
+ //
29
+ // page.default.layout ||= (page) => (<Layout>{page}</Layout>)
30
+
31
+ return page
32
+ },
33
+
34
+ setup({ el, App, props }) {
35
+ createRoot(el).render(
36
+ <StrictMode>
37
+ <App {...props} />
38
+ </StrictMode>
39
+ )
40
+ },
41
+
42
+ defaults: {
43
+ form: {
44
+ forceIndicesArrayFormatInFormData: true,
45
+ },
46
+ future: {
47
+ useDataInertiaHeadAttribute: true,
48
+ useDialogForErrorModal: true,
49
+ preserveEqualProps: true,
50
+ },
51
+ },
52
+ }).catch((error) => {
53
+ // This ensures this entrypoint is only loaded on Inertia pages
54
+ // by checking for the presence of the root element (#app by default).
55
+ // Feel free to remove this `catch` if you don't need it.
56
+ if (document.getElementById("app")) {
57
+ throw error
58
+ } else {
59
+ console.error(
60
+ "Missing root element.\n\n" +
61
+ "If you see this error, it probably means you loaded Inertia.js on non-Inertia pages.\n" +
62
+ 'Consider moving <%= vite_typescript_tag "inertia.tsx" %> to the Inertia-specific layout instead.',
63
+ )
64
+ }
65
+ })
@@ -22,6 +22,13 @@
22
22
  "noUnusedLocals": true,
23
23
  "noUnusedParameters": true,
24
24
  "noFallthroughCasesInSwitch": true,
25
+
26
+ /* Aliases */
27
+ "baseUrl": ".",
28
+ "paths": {
29
+ "@/*": ["<%= js_destination_path %>/*"],
30
+ "~/*": ["<%= js_destination_path %>/*"]
31
+ }
25
32
  },
26
33
  "include": ["<%= js_destination_path %>"]
27
34
  }
@@ -0,0 +1,8 @@
1
+ import type { SharedProps } from '@/types'
2
+
3
+ declare module '@inertiajs/core' {
4
+ export interface InertiaConfig {
5
+ sharedPageProps: SharedProps
6
+ errorValueType: string[]
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ export type Flash = {
2
+ notice?: string
3
+ alert?: string
4
+ }
5
+
6
+ export type SharedProps = {
7
+ flash: Flash
8
+ }
@@ -34,7 +34,7 @@
34
34
  count is {count}
35
35
  </button>
36
36
  <p>
37
- Edit <code>app/frontend/pages/InertiaExample.svelte</code> and save to test
37
+ Edit <code>app/frontend/pages/inertia_example/index.svelte</code> and save to test
38
38
  HMR
39
39
  </p>
40
40
  </div>
@@ -34,7 +34,7 @@
34
34
  count is {count}
35
35
  </button>
36
36
  <p>
37
- Edit <code>app/frontend/pages/InertiaExample.svelte</code> and save to test
37
+ Edit <code>app/frontend/pages/inertia_example/index.svelte</code> and save to test
38
38
  HMR
39
39
  </p>
40
40
  </div>
@@ -30,10 +30,21 @@ createInertiaApp({
30
30
  mount(App, { target: el, props })
31
31
  } else {
32
32
  console.error(
33
- 'Missing root element.\n\n' +
34
- 'If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n' +
35
- 'Consider moving <%%= vite_javascript_tag "inertia" %> to the Inertia-specific layout instead.',
33
+ "Missing root element.\n\n" +
34
+ "If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n" +
35
+ 'Consider moving <%= vite_javascript_tag "inertia" %> to the Inertia-specific layout instead.',
36
36
  )
37
37
  }
38
38
  },
39
+
40
+ defaults: {
41
+ form: {
42
+ forceIndicesArrayFormatInFormData: true,
43
+ },
44
+ future: {
45
+ useDataInertiaHeadAttribute: true,
46
+ useDialogForErrorModal: true,
47
+ preserveEqualProps: true,
48
+ },
49
+ },
39
50
  })
@@ -27,14 +27,24 @@ createInertiaApp({
27
27
 
28
28
  setup({ el, App, props }) {
29
29
  if (el) {
30
- <%= " // @ts-expect-error 1.3.0 contains types mismatch\n" if inertia_resolved_version.release == Gem::Version.new('1.3.0') -%>
31
30
  mount(App, { target: el, props })
32
31
  } else {
33
32
  console.error(
34
33
  'Missing root element.\n\n' +
35
34
  'If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n' +
36
- 'Consider moving <%%= vite_typescript_tag "inertia" %> to the Inertia-specific layout instead.',
35
+ 'Consider moving <%= vite_typescript_tag "inertia" %> to the Inertia-specific layout instead.',
37
36
  )
38
37
  }
39
38
  },
39
+
40
+ defaults: {
41
+ form: {
42
+ forceIndicesArrayFormatInFormData: true,
43
+ },
44
+ future: {
45
+ useDataInertiaHeadAttribute: true,
46
+ useDialogForErrorModal: true,
47
+ preserveEqualProps: true,
48
+ },
49
+ },
40
50
  })
@@ -15,7 +15,15 @@
15
15
  "checkJs": true,
16
16
  "isolatedModules": true,
17
17
  "moduleDetection": "force",
18
+
19
+ /* Aliases */
20
+ "baseUrl": ".",
21
+ "paths": {
22
+ "@/*": ["<%= js_destination_path %>/*"],
23
+ "~/*": ["<%= js_destination_path %>/*"]
24
+ }
18
25
  },
26
+
19
27
  "include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.js", "<%= js_destination_path %>/**/*.svelte"],
20
28
  "references": [{ "path": "./tsconfig.node.json" }]
21
29
  }
@@ -0,0 +1,8 @@
1
+ import type { SharedProps } from '@/types'
2
+
3
+ declare module '@inertiajs/core' {
4
+ export interface InertiaConfig {
5
+ sharedPageProps: SharedProps
6
+ errorValueType: string[]
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ export type Flash = {
2
+ notice?: string
3
+ alert?: string
4
+ }
5
+
6
+ export type SharedProps = {
7
+ flash: Flash
8
+ }
@@ -1,4 +1,4 @@
1
- @import "tailwindcss";
1
+ @import 'tailwindcss';
2
2
 
3
- @plugin "@tailwindcss/typography";
4
- @plugin "@tailwindcss/forms";
3
+ @plugin '@tailwindcss/typography';
4
+ @plugin '@tailwindcss/forms';
@@ -23,7 +23,7 @@
23
23
  count is {{ count }}
24
24
  </button>
25
25
  <p>
26
- Edit <code>app/frontend/pages/InertiaExample.vue</code> and save to test
26
+ Edit <code>app/frontend/pages/inertia_example/index.vue</code> and save to test
27
27
  HMR
28
28
  </p>
29
29
  </div>
@@ -23,7 +23,7 @@
23
23
  count is {{ count }}
24
24
  </button>
25
25
  <p>
26
- Edit <code>app/frontend/pages/InertiaExample.vue</code> and save to test
26
+ Edit <code>app/frontend/pages/inertia_example/index.vue</code> and save to test
27
27
  HMR
28
28
  </p>
29
29
  </div>