Skip to content

Commit

Permalink
Update init command to latest template (#527)
Browse files Browse the repository at this point in the history
* vite config is now a typescript file

* added changeset
  • Loading branch information
AlecAivazis authored Sep 9, 2022
1 parent 4925344 commit 9b87678
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-cups-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

Update init command to work with latest file template
24 changes: 15 additions & 9 deletions src/cmd/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default async function init(
} else if (framework === 'svelte') {
await updateSvelteMainJs(targetPath)
}
await updateViteConfig(targetPath, framework)
await updateViteConfig(targetPath, framework, typescript)
await tjsConfig(targetPath, framework)

// we're done!
Expand Down Expand Up @@ -300,8 +300,12 @@ async function tjsConfig(targetPath: string, framework: 'kit' | 'svelte') {
return false
}

async function updateViteConfig(targetPath: string, framework: 'kit' | 'svelte') {
const viteConfigPath = path.join(targetPath, 'vite.config.js')
async function updateViteConfig(
targetPath: string,
framework: 'kit' | 'svelte',
typescript: boolean
) {
const viteConfigPath = path.join(targetPath, 'vite.config' + typescript ? '.ts' : '.js')

const oldViteConfig1 = `import { sveltekit } from '@sveltejs/kit/vite';
Expand All @@ -313,13 +317,15 @@ const config = {
export default config;
`

const oldViteConfig2 = `import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
const oldViteConfig2 = `import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig } from 'vite';
const config: UserConfig = {
plugins: [sveltekit()]
};
export default config;
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()]
})
`

const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite';
Expand Down

2 comments on commit 9b87678

@vercel
Copy link

@vercel vercel bot commented on 9b87678 Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-next – ./site

docs-next-git-main-houdinigraphql.vercel.app
docs-next-houdinigraphql.vercel.app
docs-next-kohl.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 9b87678 Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.