From 224a5aabf39088177b3a65aa2509ea240c9643f9 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Wed, 11 Sep 2024 23:24:10 -0700 Subject: [PATCH] More template improvements (#1355) --- .changeset/seven-peaches-battle.md | 5 ++ .changeset/smart-boxes-travel.md | 5 ++ packages/create-houdini/bin.js | 47 ------------------- .../react-typescript/src/api/+schema.ts | 4 +- .../react-typescript/src/routes/+page.tsx | 4 +- .../localSchema/react/src/api/+schema.js | 4 +- .../localSchema/react/src/routes/+page.jsx | 4 +- .../templates/react-typescript/src/+index.tsx | 2 +- 8 files changed, 19 insertions(+), 56 deletions(-) create mode 100644 .changeset/seven-peaches-battle.md create mode 100644 .changeset/smart-boxes-travel.md diff --git a/.changeset/seven-peaches-battle.md b/.changeset/seven-peaches-battle.md new file mode 100644 index 0000000000..ac1753b3e4 --- /dev/null +++ b/.changeset/seven-peaches-battle.md @@ -0,0 +1,5 @@ +--- +'create-houdini': patch +--- + +More improvements to create template diff --git a/.changeset/smart-boxes-travel.md b/.changeset/smart-boxes-travel.md new file mode 100644 index 0000000000..77a5a449c5 --- /dev/null +++ b/.changeset/smart-boxes-travel.md @@ -0,0 +1,5 @@ +--- +'create-houdini': patch +--- + +More template improvements for create diff --git a/packages/create-houdini/bin.js b/packages/create-houdini/bin.js index f300aa1fe0..dfacae75bf 100755 --- a/packages/create-houdini/bin.js +++ b/packages/create-houdini/bin.js @@ -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 @@ -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 -} diff --git a/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts b/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts index 9875af5e66..4c90c3be59 100644 --- a/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts +++ b/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts @@ -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 👋', }, }, }) diff --git a/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx b/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx index 356a706682..4805ac27e8 100644 --- a/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx +++ b/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx @@ -1,11 +1,11 @@ import { PageProps } from './$types' -export default function ({ Hello }: PageProps) { +export default function ({ HelloHoudini }: PageProps) { return (

Home

-

{Hello.message}

+

{HelloHoudini.message}

) } diff --git a/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js b/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js index 9875af5e66..4c90c3be59 100644 --- a/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js +++ b/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js @@ -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 👋', }, }, }) diff --git a/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx b/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx index cee4147c46..cf283ab02f 100644 --- a/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx +++ b/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx @@ -1,9 +1,9 @@ -export default function ({ Hello }) { +export default function ({ HelloHoudini }) { return (

Home

-

{Hello.message}

+

{HelloHoudini.message}

) } diff --git a/packages/create-houdini/templates/react-typescript/src/+index.tsx b/packages/create-houdini/templates/react-typescript/src/+index.tsx index d3b2ac928a..4bff9f660a 100644 --- a/packages/create-houdini/templates/react-typescript/src/+index.tsx +++ b/packages/create-houdini/templates/react-typescript/src/+index.tsx @@ -1,6 +1,6 @@ import React from 'react' -export default function App({ children }) { +export default function App({ children }: { children: React.ReactNode }) { return (