Skip to content

Commit ed5a209

Browse files
committed
refactor: add inertia detection
1 parent 221fca5 commit ed5a209

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

packages/cli/src/utils/frameworks.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ export const FRAMEWORKS = {
4747
tailwind: 'https://tailwindcss.com/docs/installation',
4848
},
4949
},
50+
inertia: {
51+
name: 'inertia',
52+
label: 'Inertia',
53+
links: {
54+
installation: 'https://shadcn-vue.com/docs/installation/manual',
55+
tailwind: 'https://tailwindcss.com/docs/installation',
56+
},
57+
},
5058
} as const
5159

5260
export type Framework = (typeof FRAMEWORKS)[keyof typeof FRAMEWORKS]

packages/cli/src/utils/get-config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ export async function resolveConfigPaths(
5757
? './.nuxt/tsconfig.app.json'
5858
: detectedFramework?.name === 'nuxt3'
5959
? './.nuxt/tsconfig.json'
60-
: isTypeScript
61-
? './tsconfig.json'
62-
: './jsconfig.json',
60+
: detectedFramework?.name === 'inertia'
61+
? './inertia/tsconfig.json'
62+
: isTypeScript
63+
? './tsconfig.json'
64+
: './jsconfig.json',
6365
)
6466

6567
// Read tsconfig.json.

packages/cli/src/utils/get-project-info.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const TS_CONFIG_SCHEMA = z.object({
3939
})
4040

4141
export async function detectFrameworkConfigFiles(cwd: string): Promise<Framework | null> {
42+
const packageInfo = await getPackageInfo(cwd, false)
4243
const configFiles = await glob('**/{nuxt,vite,astro}.config.*|composer.json', {
4344
cwd,
4445
deep: 3,
@@ -61,6 +62,11 @@ export async function detectFrameworkConfigFiles(cwd: string): Promise<Framework
6162
return FRAMEWORKS.laravel
6263
}
6364

65+
if (packageInfo?.dependencies?.['@inertiajs/vue3']
66+
|| packageInfo?.devDependencies?.['@inertiajs/vue3'] || (await fs.pathExists(path.join(cwd, 'resources/js')))) {
67+
return FRAMEWORKS.inertia
68+
}
69+
6470
// Check for Vite
6571
if (configFiles.find(file => file.startsWith('vite.config.'))) {
6672
return FRAMEWORKS.vite
@@ -101,10 +107,6 @@ export async function getProjectInfo(cwd: string): Promise<ProjectInfo | null> {
101107
getPackageInfo(cwd, false),
102108
])
103109

104-
const isUsingAppDir = await fs.pathExists(
105-
path.resolve(cwd, `app`),
106-
)
107-
108110
const type: ProjectInfo = {
109111
framework: detectedFramework || FRAMEWORKS.manual,
110112
typescript,
@@ -209,9 +211,11 @@ export async function getTsConfigAliasPrefix(cwd: string) {
209211
? './.nuxt/tsconfig.app.json'
210212
: detectedFramework?.name === 'nuxt3'
211213
? './.nuxt/tsconfig.json'
212-
: isTypeScript
213-
? './tsconfig.json'
214-
: './jsconfig.json')
214+
: detectedFramework?.name === 'inertia'
215+
? './inertia/tsconfig.json'
216+
: isTypeScript
217+
? './tsconfig.json'
218+
: './jsconfig.json')
215219

216220
if (
217221
tsConfig === null

0 commit comments

Comments
 (0)