inertia_rails 3.6.0 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE.txt +1 -1
  4. data/lib/generators/inertia/install/install_generator.rb +5 -8
  5. data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +1 -1
  6. data/lib/generators/inertia/install/templates/react/inertia.ts +3 -3
  7. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +1 -1
  8. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +1 -1
  9. data/lib/generators/inertia/install/templates/svelte/inertia.js +3 -3
  10. data/lib/generators/inertia/install/templates/svelte/inertia.ts.tt +4 -4
  11. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +1 -1
  12. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +1 -1
  13. data/lib/generators/inertia/install/templates/svelte4/inertia.js +3 -3
  14. data/lib/generators/inertia/install/templates/svelte4/inertia.ts.tt +4 -4
  15. data/lib/generators/inertia/install/templates/tailwind/application.css +3 -12
  16. data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +1 -1
  17. data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +1 -1
  18. data/lib/generators/inertia/install/templates/vue/inertia.ts +3 -3
  19. data/lib/inertia_rails/generators/helper.rb +9 -7
  20. data/lib/inertia_rails/renderer.rb +1 -1
  21. data/lib/inertia_rails/rspec.rb +5 -6
  22. data/lib/inertia_rails/version.rb +1 -1
  23. metadata +3 -8
  24. data/lib/generators/inertia/install/templates/tailwind/postcss.config.js +0 -6
  25. data/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1703f19fcb6d8f3d2c580e6e7bd80ff999cda8f55f72f7ea915001279577386c
4
- data.tar.gz: d5ff27be81328583e03aa7eb4473f1a4a966139993a3d856c54c0b6ae447b122
3
+ metadata.gz: 9d06f57228ce3ff3b4dba1d2b7bdf99deaa110c8b85c474c106baa989dd1bf8c
4
+ data.tar.gz: ec01c88da7419b8dbf1cc1243eced6fd38c10a7fba1c21d75def08ae1516cf01
5
5
  SHA512:
6
- metadata.gz: 9cdd9eebf261e555bc09d237272852c4c59cf08618462f5deb5aaa314e09538e121a8c116e989c9c66632f38d2bcf14617d0d0f6ca9f5fe152e7b646a5a652f3
7
- data.tar.gz: 4fea8b1605262d6d80ccec45fe68368b9f62ae4cd96cca7768b58b0b65e5a690877216f6f10f7d4e93915cbba8003b4635b99ea4b3af3f2100bceda8c572cd73
6
+ metadata.gz: 6506c7ae154865ed78172e6f6bc2f28ff09cc8ee00faf25cb9d687f53143c9cbe7e105dbc297c028ceb29189070e63ba5484ecdf4c7217115b2d46b090389321
7
+ data.tar.gz: 7891ba539d642509920d1ab0d17c7c79e6bfbb1399c93c1c298a1ed20367b5a758352c644fc2794ea2309053a452643d807a26a1167b67a93e68febeabe9170e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ 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.1] - 2025-02-04
8
+
9
+ * Install generator tweaks @skryukov
10
+ * Performance improvement for oj serialization users @alexspeller
11
+ * Doc updates @youyoumu
12
+ * Doc updates @pedroaugustoramalhoduarte
13
+ * Tailwind v4 support in install generators @arandilopez
14
+ * Various CI fixes @bknoles / @skryukov
15
+
7
16
  ## [3.6.0] - 2024-12-13
8
17
 
9
18
  Support for the v2.0 Inertia.js release! It's a minor bump because there are no breaking changes!
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 TODO: Bellawatt
3
+ Copyright (c) 2025 Bellawatt
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -78,8 +78,7 @@ module Inertia
78
78
  template 'initializer.rb', file_path('config/initializers/inertia_rails.rb')
79
79
 
80
80
  say 'Installing Inertia npm packages'
81
- add_dependencies(*FRAMEWORKS[framework]['packages'])
82
- add_dependencies(inertia_package)
81
+ add_dependencies(inertia_package, *FRAMEWORKS[framework]['packages'])
83
82
 
84
83
  unless File.read(vite_config_path).include?(FRAMEWORKS[framework]['vite_plugin_import'])
85
84
  say "Adding Vite plugin for #{framework}"
@@ -152,11 +151,9 @@ module Inertia
152
151
 
153
152
  def install_tailwind
154
153
  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')
154
+ add_dependencies(%w[tailwindcss @tailwindcss/vite @tailwindcss/forms @tailwindcss/typography])
155
+ prepend_file vite_config_path, "import tailwindcss from '@tailwindcss/vite'\n"
156
+ insert_into_file vite_config_path, "\n tailwindcss(),", after: 'plugins: ['
160
157
  copy_file 'tailwind/application.css', js_file_path('entrypoints/application.css')
161
158
 
162
159
  if application_layout.exist?
@@ -266,7 +263,7 @@ module Inertia
266
263
 
267
264
  def inertia_resolved_version
268
265
  @inertia_resolved_version ||= Gem::Version.new(
269
- `npm show @inertiajs/core@#{options[:inertia_version]} version`.strip
266
+ `npm show @inertiajs/core@#{options[:inertia_version]} version --json | tail -n2 | head -n1 | tr -d '", '`.strip
270
267
  )
271
268
  end
272
269
 
@@ -18,7 +18,7 @@ export default function InertiaExample({ name }: { name: string }) {
18
18
  <h1 className={cs.h1}>Hello {name}!</h1>
19
19
 
20
20
  <div>
21
- <a href="https://inertia-rails.netlify.app" target="_blank">
21
+ <a href="https://inertia-rails.dev" target="_blank">
22
22
  <img className={cs.logo} src={inertiaSvg} alt="Inertia logo" />
23
23
  </a>
24
24
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -10,13 +10,13 @@ type ResolvedComponent = {
10
10
 
11
11
  createInertiaApp({
12
12
  // Set default page title
13
- // see https://inertia-rails.netlify.app/guide/title-and-meta
13
+ // see https://inertia-rails.dev/guide/title-and-meta
14
14
  //
15
15
  // title: title => title ? `${title} - App` : 'App',
16
16
 
17
17
  // Disable progress bar
18
18
  //
19
- // see https://inertia-rails.netlify.app/guide/progress-indicators
19
+ // see https://inertia-rails.dev/guide/progress-indicators
20
20
  // progress: false,
21
21
 
22
22
  resolve: (name) => {
@@ -30,7 +30,7 @@ createInertiaApp({
30
30
 
31
31
  // To use a default layout, import the Layout component
32
32
  // and use the following line.
33
- // see https://inertia-rails.netlify.app/guide/pages#default-layouts
33
+ // see https://inertia-rails.dev/guide/pages#default-layouts
34
34
  //
35
35
  // page.default.layout ||= (page) => createElement(Layout, null, page)
36
36
 
@@ -16,7 +16,7 @@
16
16
  <h1>Hello {name}!</h1>
17
17
 
18
18
  <div>
19
- <a href="https://inertia-rails.netlify.app" target="_blank">
19
+ <a href="https://inertia-rails.dev" target="_blank">
20
20
  <img class="logo" src={inertiaSvg} alt="Inertia logo" />
21
21
  </a>
22
22
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -16,7 +16,7 @@
16
16
  <h1>Hello {name}!</h1>
17
17
 
18
18
  <div>
19
- <a href="https://inertia-rails.netlify.app" target="_blank">
19
+ <a href="https://inertia-rails.dev" target="_blank">
20
20
  <img class="logo" src={inertiaSvg} alt="Inertia logo" />
21
21
  </a>
22
22
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -3,13 +3,13 @@ import { mount } from 'svelte';
3
3
 
4
4
  createInertiaApp({
5
5
  // Set default page title
6
- // see https://inertia-rails.netlify.app/guide/title-and-meta
6
+ // see https://inertia-rails.dev/guide/title-and-meta
7
7
  //
8
8
  // title: title => title ? `${title} - App` : 'App',
9
9
 
10
10
  // Disable progress bar
11
11
  //
12
- // see https://inertia-rails.netlify.app/guide/progress-indicators
12
+ // see https://inertia-rails.dev/guide/progress-indicators
13
13
  // progress: false,
14
14
 
15
15
  resolve: (name) => {
@@ -23,7 +23,7 @@ createInertiaApp({
23
23
 
24
24
  // To use a default layout, import the Layout component
25
25
  // and use the following line.
26
- // see https://inertia-rails.netlify.app/guide/pages#default-layouts
26
+ // see https://inertia-rails.dev/guide/pages#default-layouts
27
27
  //
28
28
  // return { default: page.default, layout: page.layout || Layout }
29
29
 
@@ -3,13 +3,13 @@ import { mount } from 'svelte'
3
3
 
4
4
  createInertiaApp({
5
5
  // Set default page title
6
- // see https://inertia-rails.netlify.app/guide/title-and-meta
6
+ // see https://inertia-rails.dev/guide/title-and-meta
7
7
  //
8
8
  // title: title => title ? `${title} - App` : 'App',
9
9
 
10
10
  // Disable progress bar
11
11
  //
12
- // see https://inertia-rails.netlify.app/guide/progress-indicators
12
+ // see https://inertia-rails.dev/guide/progress-indicators
13
13
  // progress: false,
14
14
 
15
15
  resolve: (name) => {
@@ -23,7 +23,7 @@ createInertiaApp({
23
23
 
24
24
  // To use a default layout, import the Layout component
25
25
  // and use the following line.
26
- // see https://inertia-rails.netlify.app/guide/pages#default-layouts
26
+ // see https://inertia-rails.dev/guide/pages#default-layouts
27
27
  //
28
28
  // return { default: page.default, layout: page.layout || Layout }
29
29
 
@@ -32,7 +32,7 @@ createInertiaApp({
32
32
 
33
33
  setup({ el, App, props }) {
34
34
  if (el) {
35
- <%= " // @ts-expect-error 1.3.0 beta contains types mismatch\n" if inertia_resolved_version == Gem::Version.new('1.3.0-beta.2') -%>
35
+ <%= " // @ts-expect-error 1.3.0 contains types mismatch\n" if inertia_resolved_version.release == Gem::Version.new('1.3.0') -%>
36
36
  mount(App, { target: el, props })
37
37
  } else {
38
38
  console.error(
@@ -20,7 +20,7 @@
20
20
  <h1>Hello {name}!</h1>
21
21
 
22
22
  <div>
23
- <a href="https://inertia-rails.netlify.app" target="_blank">
23
+ <a href="https://inertia-rails.dev/" target="_blank">
24
24
  <img class="logo" src={inertiaSvg} alt="Inertia logo" />
25
25
  </a>
26
26
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -20,7 +20,7 @@
20
20
  <h1>Hello {name}!</h1>
21
21
 
22
22
  <div>
23
- <a href="https://inertia-rails.netlify.app" target="_blank">
23
+ <a href="https://inertia-rails.dev" target="_blank">
24
24
  <img class="logo" src={inertiaSvg} alt="Inertia logo" />
25
25
  </a>
26
26
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -2,13 +2,13 @@ import { createInertiaApp } from '@inertiajs/svelte'
2
2
 
3
3
  createInertiaApp({
4
4
  // Set default page title
5
- // see https://inertia-rails.netlify.app/guide/title-and-meta
5
+ // see https://inertia-rails.dev/guide/title-and-meta
6
6
  //
7
7
  // title: title => title ? `${title} - App` : 'App',
8
8
 
9
9
  // Disable progress bar
10
10
  //
11
- // see https://inertia-rails.netlify.app/guide/progress-indicators
11
+ // see https://inertia-rails.dev/guide/progress-indicators
12
12
  // progress: false,
13
13
 
14
14
  resolve: (name) => {
@@ -22,7 +22,7 @@ createInertiaApp({
22
22
 
23
23
  // To use a default layout, import the Layout component
24
24
  // and use the following lines.
25
- // see https://inertia-rails.netlify.app/guide/pages#default-layouts
25
+ // see https://inertia-rails.dev/guide/pages#default-layouts
26
26
  //
27
27
  // return { default: page.default, layout: page.layout || Layout }
28
28
 
@@ -2,13 +2,13 @@ import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte'
2
2
 
3
3
  createInertiaApp({
4
4
  // Set default page title
5
- // see https://inertia-rails.netlify.app/guide/title-and-meta
5
+ // see https://inertia-rails.dev/guide/title-and-meta
6
6
  //
7
7
  // title: title => title ? `${title} - App` : 'App',
8
8
 
9
9
  // Disable progress bar
10
10
  //
11
- // see https://inertia-rails.netlify.app/guide/progress-indicators
11
+ // see https://inertia-rails.dev/guide/progress-indicators
12
12
  // progress: false,
13
13
 
14
14
  resolve: (name) => {
@@ -22,7 +22,7 @@ createInertiaApp({
22
22
 
23
23
  // To use a default layout, import the Layout component
24
24
  // and use the following line.
25
- // see https://inertia-rails.netlify.app/guide/pages#default-layouts
25
+ // see https://inertia-rails.dev/guide/pages#default-layouts
26
26
  //
27
27
  // return { default: page.default, layout: page.layout || Layout }
28
28
 
@@ -31,7 +31,7 @@ createInertiaApp({
31
31
 
32
32
  setup({ el, App, props }) {
33
33
  if (el) {
34
- <%= "// @ts-expect-error 1.3.0 beta contains types mismatch\n" if inertia_resolved_version == Gem::Version.new('1.3.0-beta.2') -%>
34
+ <%= "// @ts-expect-error 1.3.0 beta contains types mismatch\n" if inertia_resolved_version.release == Gem::Version.new('1.3.0') -%>
35
35
  new App({ target: el, props })
36
36
  } else {
37
37
  console.error(
@@ -1,13 +1,4 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
1
+ @import "tailwindcss";
4
2
 
5
- /*
6
-
7
- @layer components {
8
- .btn-primary {
9
- @apply py-2 px-4 bg-blue-200;
10
- }
11
- }
12
-
13
- */
3
+ @plugin "@tailwindcss/typography";
4
+ @plugin "@tailwindcss/forms";
@@ -5,7 +5,7 @@
5
5
  <h1 class="h1">Hello {{ name }}!</h1>
6
6
 
7
7
  <div>
8
- <a href="https://inertia-rails.netlify.app" target="_blank">
8
+ <a href="https://inertia-rails.dev" target="_blank">
9
9
  <img class="logo" :src="inertiaSvg" alt="Inertia logo" />
10
10
  </a>
11
11
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -5,7 +5,7 @@
5
5
  <h1 class="h1">Hello {{ name }}!</h1>
6
6
 
7
7
  <div>
8
- <a href="https://inertia-rails.netlify.app" target="_blank">
8
+ <a href="https://inertia-rails.dev" target="_blank">
9
9
  <img class="logo" :src="inertiaSvg" alt="Inertia logo" />
10
10
  </a>
11
11
  <a href="https://vite-ruby.netlify.app" target="_blank">
@@ -3,13 +3,13 @@ import { createApp, DefineComponent, h } from 'vue'
3
3
 
4
4
  createInertiaApp({
5
5
  // Set default page title
6
- // see https://inertia-rails.netlify.app/guide/title-and-meta
6
+ // see https://inertia-rails.dev/guide/title-and-meta
7
7
  //
8
8
  // title: title => title ? `${title} - App` : 'App',
9
9
 
10
10
  // Disable progress bar
11
11
  //
12
- // see https://inertia-rails.netlify.app/guide/progress-indicators
12
+ // see https://inertia-rails.dev/guide/progress-indicators
13
13
  // progress: false,
14
14
 
15
15
  resolve: (name) => {
@@ -20,7 +20,7 @@ createInertiaApp({
20
20
 
21
21
  // To use a default layout, import the Layout component
22
22
  // and use the following lines.
23
- // see https://inertia-rails.netlify.app/guide/pages#default-layouts
23
+ // see https://inertia-rails.dev/guide/pages#default-layouts
24
24
  //
25
25
  // const page = pages[`../pages/${name}.vue`]
26
26
  // page.default.layout = page.default.layout || Layout
@@ -4,14 +4,16 @@ module InertiaRails
4
4
  module Generators
5
5
  module Helper
6
6
  class << self
7
- def guess_the_default_framework
8
- package = Rails.root.join('package.json').read
9
- case package
10
- when %r{@inertiajs/react}
7
+ def guess_the_default_framework(package_json_path = Rails.root.join('package.json'))
8
+ package_json = JSON.parse(package_json_path.read)
9
+ dependencies = package_json['dependencies'] || {}
10
+
11
+ if dependencies['@inertiajs/react']
11
12
  'react'
12
- when %r{@inertiajs/svelte}
13
- package.match?(/"svelte": "\^5/) ? 'svelte' : 'svelte4'
14
- when %r{@inertiajs/vue3}
13
+ elsif dependencies['@inertiajs/svelte']
14
+ version = dependencies['svelte'].gsub(/[\^~]/, '') # Remove ^ or ~ from version
15
+ version.start_with?('5') ? 'svelte' : 'svelte4'
16
+ elsif dependencies['@inertiajs/vue3']
15
17
  'vue'
16
18
  else
17
19
  Thor::Shell::Basic.new.say_error 'Could not determine the Inertia.js framework you are using.'
@@ -41,7 +41,7 @@ module InertiaRails
41
41
  end
42
42
  if @request.headers['X-Inertia']
43
43
  @response.set_header('X-Inertia', 'true')
44
- @render_method.call json: page, status: @response.status, content_type: Mime[:json]
44
+ @render_method.call json: page.to_json, status: @response.status, content_type: Mime[:json]
45
45
  else
46
46
  return render_ssr if configuration.ssr_enabled rescue nil
47
47
  @render_method.call template: 'inertia', layout: layout, locals: view_data.merge(page: page)
@@ -32,8 +32,9 @@ module InertiaRails
32
32
  else
33
33
  # Sequential Inertia request
34
34
  @view_data = {}
35
- @props = params[:json][:props]
36
- @component = params[:json][:component]
35
+ json = JSON.parse(params[:json])
36
+ @props = json["props"]
37
+ @component = json["component"]
37
38
  end
38
39
  end
39
40
  end
@@ -81,8 +82,7 @@ end
81
82
 
82
83
  RSpec::Matchers.define :have_exact_props do |expected_props|
83
84
  match do |inertia|
84
- # Computed props have symbolized keys.
85
- expect(inertia.props).to eq expected_props.deep_symbolize_keys
85
+ expect(inertia.props).to eq expected_props
86
86
  end
87
87
 
88
88
  failure_message do |inertia|
@@ -92,8 +92,7 @@ end
92
92
 
93
93
  RSpec::Matchers.define :include_props do |expected_props|
94
94
  match do |inertia|
95
- # Computed props have symbolized keys.
96
- expect(inertia.props).to include expected_props.deep_symbolize_keys
95
+ expect(inertia.props).to include expected_props
97
96
  end
98
97
 
99
98
  failure_message do |inertia|
@@ -1,3 +1,3 @@
1
1
  module InertiaRails
2
- VERSION = "3.6.0"
2
+ VERSION = "3.6.1"
3
3
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inertia_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Knoles
8
8
  - Brandon Shar
9
9
  - Eugene Granovsky
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2024-12-13 00:00:00.000000000 Z
12
+ date: 2025-02-05 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: railties
@@ -81,8 +80,6 @@ files:
81
80
  - lib/generators/inertia/install/templates/svelte4/tsconfig.node.json
82
81
  - lib/generators/inertia/install/templates/svelte4/vite-env.d.ts
83
82
  - lib/generators/inertia/install/templates/tailwind/application.css
84
- - lib/generators/inertia/install/templates/tailwind/postcss.config.js
85
- - lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt
86
83
  - lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue
87
84
  - lib/generators/inertia/install/templates/vue/InertiaExample.vue
88
85
  - lib/generators/inertia/install/templates/vue/inertia.js
@@ -250,7 +247,6 @@ metadata:
250
247
  homepage_uri: https://github.com/inertiajs/inertia-rails
251
248
  source_code_uri: https://github.com/inertiajs/inertia-rails
252
249
  rubygems_mfa_required: 'true'
253
- post_install_message:
254
250
  rdoc_options: []
255
251
  require_paths:
256
252
  - lib
@@ -265,8 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
261
  - !ruby/object:Gem::Version
266
262
  version: '0'
267
263
  requirements: []
268
- rubygems_version: 3.5.22
269
- signing_key:
264
+ rubygems_version: 3.6.2
270
265
  specification_version: 4
271
266
  summary: Inertia.js adapter for Rails
272
267
  test_files: []
@@ -1,6 +0,0 @@
1
- export default {
2
- plugins: {
3
- tailwindcss: {},
4
- autoprefixer: {},
5
- },
6
- }
@@ -1,18 +0,0 @@
1
- /** @type {import('tailwindcss').Config} */
2
-
3
- module.exports = {
4
- content: [
5
- './public/*.html',
6
- './app/helpers/**/*.rb',
7
- './<%= js_destination_path %>/**/*.{js,ts,jsx,tsx,vue,svelte}',
8
- './app/views/**/*.{erb,haml,html,slim}'
9
- ],
10
- theme: {
11
- extend: {},
12
- },
13
- plugins: [
14
- require('@tailwindcss/forms'),
15
- require('@tailwindcss/typography'),
16
- require('@tailwindcss/container-queries'),
17
- ]
18
- }