Skip to content

Commit ce6bdc0

Browse files
committed
refactor: improve TypeScript setup for non-interactive installs
1 parent d06b45e commit ce6bdc0

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

lib/generators/inertia/install/frameworks.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ react:
1313
vite_plugin_call: "react()"
1414
copy_files_ts:
1515
"InertiaExample.tsx": "%{js_destination_path}/pages/inertia_example/index.tsx"
16-
"tsconfig.json": "tsconfig.json"
17-
"tsconfig.app.json": "tsconfig.app.json"
18-
"tsconfig.node.json": "tsconfig.node.json"
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"
2216
copy_files_js:
2317
"InertiaExample.jsx": "%{js_destination_path}/pages/inertia_example/index.jsx"
2418
copy_files:
@@ -44,12 +38,6 @@ vue:
4438
"../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
4539
copy_files_ts:
4640
"InertiaExample.ts.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
47-
"tsconfig.json": "tsconfig.json"
48-
"tsconfig.app.json": "tsconfig.app.json"
49-
"tsconfig.node.json": "tsconfig.node.json"
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"
5341
copy_files_js:
5442
"InertiaExample.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
5543

@@ -68,11 +56,6 @@ svelte:
6856
vite_plugin_call: "svelte()"
6957
copy_files_ts:
7058
"InertiaExample.ts.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
71-
"tsconfig.json": "tsconfig.json"
72-
"tsconfig.node.json": "tsconfig.node.json"
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"
7659
copy_files_js:
7760
"InertiaExample.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
7861
copy_files:

lib/generators/inertia/install/install_generator.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,30 @@ def install_typescript
148148

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

151-
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+
copy_file "#{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+
copy_file "#{framework}/#{file}", file_path("#{js_destination_path}/#{file}")
165+
end
166+
167+
say 'Adding TypeScript check scripts to package.json'
152168
if svelte?
153169
run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"'
154-
end
155-
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 framework == 'vue'
156173
run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
157174
end
158-
run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'react'
159175
end
160176

161177
def install_example_page

0 commit comments

Comments
 (0)