Skip to content

Commit 6a06f51

Browse files
committed
fix: correct TypeScript setup in non-interactive installs
1 parent ce6bdc0 commit 6a06f51

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/generators/inertia/install/install_generator.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def install_inertia
118118
ERB
119119
insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n"
120120

121-
if framework == 'react' && !application_layout.read.include?('vite_react_refresh_tag')
121+
if react? && !application_layout.read.include?('vite_react_refresh_tag')
122122
say 'Adding Vite React Refresh tag to the application layout'
123123
insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ",
124124
before: '<%= vite_client_tag %>'
@@ -130,7 +130,7 @@ def install_inertia
130130
say_error '- <title>...</title>'
131131
say_error '+ <title data-inertia>...</title>'
132132
say_error '+ <%= inertia_ssr_head %>'
133-
say_error '+ <%= vite_react_refresh_tag %>' if framework == 'react'
133+
say_error '+ <%= vite_react_refresh_tag %>' if react?
134134
say_error "+ <%= #{vite_tag} %>"
135135
end
136136
end
@@ -155,21 +155,21 @@ def install_typescript
155155
tsconfig_files << 'tsconfig.app.json' unless svelte?
156156

157157
tsconfig_files.each do |file|
158-
copy_file "#{framework}/#{file}", file_path(file)
158+
template "#{framework}/#{file}", file_path(file)
159159
end
160160

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

167167
say 'Adding TypeScript check scripts to package.json'
168168
if svelte?
169169
run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"'
170170
elsif react?
171171
run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
172-
elsif framework == 'vue'
172+
elsif vue?
173173
run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
174174
end
175175
end
@@ -343,6 +343,10 @@ def react?
343343
framework.start_with? 'react'
344344
end
345345

346+
def vue?
347+
framework.start_with? 'vue'
348+
end
349+
346350
def inertia_package
347351
"#{FRAMEWORKS[framework]['inertia_package']}@#{options[:inertia_version]}"
348352
end

0 commit comments

Comments
 (0)