Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions lib/generators/inertia/install/frameworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ react:
vite_plugin_call: "react()"
copy_files_ts:
"InertiaExample.tsx": "%{js_destination_path}/pages/inertia_example/index.tsx"
"tsconfig.json": "tsconfig.json"
"tsconfig.app.json": "tsconfig.app.json"
"tsconfig.node.json": "tsconfig.node.json"
"types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
"types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
"types/index.ts": "%{js_destination_path}/types/index.ts"
copy_files_js:
"InertiaExample.jsx": "%{js_destination_path}/pages/inertia_example/index.jsx"
copy_files:
Expand All @@ -44,12 +38,6 @@ vue:
"../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
copy_files_ts:
"InertiaExample.ts.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
"tsconfig.json": "tsconfig.json"
"tsconfig.app.json": "tsconfig.app.json"
"tsconfig.node.json": "tsconfig.node.json"
"types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
"types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
"types/index.ts": "%{js_destination_path}/types/index.ts"
copy_files_js:
"InertiaExample.vue": "%{js_destination_path}/pages/inertia_example/index.vue"

Expand All @@ -68,11 +56,6 @@ svelte:
vite_plugin_call: "svelte()"
copy_files_ts:
"InertiaExample.ts.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
"tsconfig.json": "tsconfig.json"
"tsconfig.node.json": "tsconfig.node.json"
"types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
"types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
"types/index.ts": "%{js_destination_path}/types/index.ts"
copy_files_js:
"InertiaExample.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
copy_files:
Expand Down
32 changes: 26 additions & 6 deletions lib/generators/inertia/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def install_inertia
ERB
insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n"

if framework == 'react' && !application_layout.read.include?('vite_react_refresh_tag')
if react? && !application_layout.read.include?('vite_react_refresh_tag')
say 'Adding Vite React Refresh tag to the application layout'
insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ",
before: '<%= vite_client_tag %>'
Expand All @@ -130,7 +130,7 @@ def install_inertia
say_error '- <title>...</title>'
say_error '+ <title data-inertia>...</title>'
say_error '+ <%= inertia_ssr_head %>'
say_error '+ <%= vite_react_refresh_tag %>' if framework == 'react'
say_error '+ <%= vite_react_refresh_tag %>' if react?
say_error "+ <%= #{vite_tag} %>"
end
end
Expand All @@ -148,14 +148,30 @@ def install_typescript

add_dependencies(*FRAMEWORKS[framework]['packages_ts'])

say 'Copying adding scripts to package.json'
say 'Copying tsconfig and types'

# Copy tsconfig files
tsconfig_files = %w[tsconfig.json tsconfig.node.json]
tsconfig_files << 'tsconfig.app.json' unless svelte?

tsconfig_files.each do |file|
template "#{framework}/#{file}", file_path(file)
end

# Copy type definition files
types_files = %w[types/vite-env.d.ts types/globals.d.ts types/index.ts]
types_files.each do |file|
template "#{framework}/#{file}", file_path("#{js_destination_path}/#{file}")
end

say 'Adding TypeScript check scripts to package.json'
if svelte?
run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"'
end
if framework == 'vue'
elsif react?
run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
elsif vue?
run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
end
run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'react'
end

def install_example_page
Expand Down Expand Up @@ -327,6 +343,10 @@ def react?
framework.start_with? 'react'
end

def vue?
framework.start_with? 'vue'
end

def inertia_package
"#{FRAMEWORKS[framework]['inertia_package']}@#{options[:inertia_version]}"
end
Expand Down