Skip to content

Commit

Permalink
More template improvements (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis authored Sep 12, 2024
1 parent 97df62c commit 224a5aa
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-peaches-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-houdini': patch
---

More improvements to create template
5 changes: 5 additions & 0 deletions .changeset/smart-boxes-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-houdini': patch
---

More template improvements for create
47 changes: 0 additions & 47 deletions packages/create-houdini/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,6 @@ if (localSchema) {
copy(sourcePath('./fragments/localSchema/' + template))
}

// If anything goes wrong, we don't want to block the user
let sponsor_msg = ''
try {
const selected = await getSponsors()
sponsor_msg = `🙏 Special thanks to the ${bold(white(selected))} for supporting Houdini!`
} catch (error) {}

p.outro(`🎉 Everything is ready!
👉 Next Steps
Expand Down Expand Up @@ -381,43 +374,3 @@ function pCancel(cancelText = 'Operation cancelled.') {
p.cancel(cancelText)
process.exit(1)
}

async function getSponsors() {
const res = await fetch(
'https://raw.githubusercontent.com/HoudiniGraphql/sponsors/main/generated/sponsors.json'
)
const /**@type {any[]} */ jsonData = await res.json()

/** @returns {[number, string]} */
function getTier(/**@type {number}*/ value) {
if (value >= 1500) {
return [10, 'Wizard']
}
if (value >= 500) {
return [5, 'Mage']
}
if (value >= 25) {
return [2, "Magician's Apprentice"]
}
if (value >= 10) {
return [1, 'Supportive Muggle']
}
// don't display the past sponsors
return [0, 'Past Sponsors']
}

const list = jsonData.flatMap(
(/** @type {{sponsor: {name: string}, monthlyDollars: number}} */ c) => {
const [coef, title] = getTier(c.monthlyDollars)
const names = []
for (let i = 0; i < coef; i++) {
names.push(`${title}, ${c.sponsor.name}`)
}
return names
}
)

const selected_to_display = list[Math.floor(Math.random() * list.length)]

return selected_to_display
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { createSchema } from 'graphql-yoga'
export default createSchema({
typeDefs: /* GraphQL */ `
type Query {
hello: String
message: String
}
`,
resolvers: {
Query: {
hello: () => 'Greetings from your local api 👋',
message: () => 'Greetings from your local api 👋',
},
},
})
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PageProps } from './$types'

export default function ({ Hello }: PageProps) {
export default function ({ HelloHoudini }: PageProps) {
return (
<div className="flex flex-col gap-8">
<h2>Home</h2>

<p>{Hello.message}</p>
<p>{HelloHoudini.message}</p>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { createSchema } from 'graphql-yoga'
export default createSchema({
typeDefs: /* GraphQL */ `
type Query {
hello: String
message: String
}
`,
resolvers: {
Query: {
hello: () => 'Greetings from your local api 👋',
message: () => 'Greetings from your local api 👋',
},
},
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export default function ({ Hello }) {
export default function ({ HelloHoudini }) {
return (
<div className="flex flex-col gap-8">
<h2>Home</h2>

<p>{Hello.message}</p>
<p>{HelloHoudini.message}</p>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

export default function App({ children }) {
export default function App({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
Expand Down

0 comments on commit 224a5aa

Please sign in to comment.