Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update init templates #620

Merged
merged 4 commits into from
Oct 21, 2022
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
6 changes: 6 additions & 0 deletions .changeset/young-beans-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'houdini': patch
'houdini-svelte': patch
---

update templates
10 changes: 2 additions & 8 deletions packages/houdini-svelte/src/plugin/fsPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,12 @@ filesystem.statSync = function (filepath: string, options: Parameters<filesystem

// we want to fake +layout.js if there is a +layout.svelte
else if (filepath.endsWith('+layout.js')) {
try {
_statSync(filepath.replace('+layout.js', '+layout.svelte'))
return mock
} catch (e) {}
return mock
}

// we want to fake +page.js if there is a +page.svelte
else if (filepath.endsWith('+page.js')) {
try {
_statSync(filepath.replace('+page.js', '+page.svelte'))
return mock
} catch (e) {}
return mock
}

// if we got this far we didn't fake the file
Expand Down
14 changes: 13 additions & 1 deletion packages/houdini/src/cmd/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export default async function init(
args: { headers?: string[]; yes: boolean },
withRunningCheck = true
): Promise<void> {
// before we start anything, let's make sure they have initialized their project
try {
await fs.stat(path.resolve('./src'))
} catch {
throw new Error(
'Please initialize your project first before running init. For svelte projects, you should follow the instructions here: https://kit.svelte.dev/'
)
}

let headers = {}
if ((args.headers ?? []).length > 0) {
headers = args.headers!.reduce((total, header) => {
Expand Down Expand Up @@ -48,7 +57,7 @@ export default async function init(
message: "What's the URL for your api?",
name: 'url',
type: 'text',
initial: 'http://localhost:4000/api/graphql',
initial: 'http://localhost:4000/graphql',
},
{
onCancel() {
Expand All @@ -75,6 +84,9 @@ export default async function init(
console.log('❌ That URL is not accepting GraphQL queries. Please try again.')
return await init(_path, args, false)
}

// make sure we can parse the response as json
await response.json()
} catch (e) {
console.log('❌ Something went wrong: ' + (e as Error).message)
return await init(_path, args, false)
Expand Down
5 changes: 2 additions & 3 deletions packages/houdini/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,8 @@ export async function getConfig({
// if there is a framework specified, tell them they need to change things
if (!configFile.plugins) {
throw new HoudiniError({
message: 'framework config value has been removed.',
description:
'Please visit the release notes here: http://www.houdinigraphql.com/guide/release-notes#0170',
message:
'Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guide/release-notes#0170',
})
}

Expand Down