create-fuse-app
Advanced tools
Comparing version 0.3.0 to 0.4.0
# create-fuse-app | ||
## 0.4.0 | ||
### Minor Changes | ||
- 2b4073e: Add support for generating a fuse-app without being in Next.JS | ||
### Patch Changes | ||
- 0a58c27: Check for `src` when looking for the `/app` directory | ||
## 0.3.0 | ||
@@ -4,0 +14,0 @@ |
@@ -139,2 +139,9 @@ #!/usr/bin/env node | ||
prompts.intro(kl.trueColor(219, 254, 1)("Fuse - Your new datalayer")); | ||
s.start("Installing fuse..."); | ||
await install(packageManager, "prod", ["fuse"]); | ||
await install(packageManager, "dev", [ | ||
"@0no-co/graphqlsp", | ||
"@graphql-typed-document-node/core" | ||
]); | ||
s.stop(kl.green("Installed fuse!")); | ||
const targetDir = resolve(process.cwd()); | ||
@@ -151,16 +158,34 @@ const packageJson = await fs.readFile( | ||
if (!nextVersion) { | ||
throw new Error( | ||
'Could not find "next" as a dependency in your package.json. Please install Next.js first.' | ||
s.start("Creating Base files.."); | ||
const contextCopy = `import { GetContext, InitialContext } from 'fuse' | ||
export const getContext = ( | ||
ctx: InitialContext, | ||
): GetContext<{ ua: string | null }> => { | ||
return { | ||
ua: ctx.request.headers.get('user-agent'), | ||
} | ||
} | ||
`; | ||
await fs.writeFile(resolve(targetDir, "_context.ts"), contextCopy); | ||
if (!existsSync(resolve(targetDir, "types"))) { | ||
await fs.mkdir(resolve(targetDir, "types")); | ||
} | ||
await fs.writeFile( | ||
resolve(targetDir, "types", "User.ts"), | ||
initialTypeSnippet | ||
); | ||
await writeGraphQLSP(targetDir); | ||
await updateTSConfig(targetDir); | ||
s.stop("Created Base files!"); | ||
prompts.outro( | ||
kl.trueColor(219, 254, 1)("You're all set to work with your datalayer!") | ||
); | ||
return; | ||
} | ||
s.start("Installing fuse..."); | ||
await install(packageManager, "prod", ["fuse"]); | ||
await install(packageManager, "dev", [ | ||
"@0no-co/graphqlsp", | ||
"@graphql-typed-document-node/core" | ||
]); | ||
s.stop(kl.green("Installed fuse!")); | ||
s.start("Creating API Route..."); | ||
const isUsingSrc = existsSync(resolve(targetDir, "src")); | ||
const shouldUseAppDir = existsSync(resolve(targetDir, "app")); | ||
const shouldUseAppDir = existsSync( | ||
isUsingSrc ? resolve(targetDir, "src", "app") : resolve(targetDir, "app") | ||
); | ||
const apiRouteSnippet = createSnippet(shouldUseAppDir); | ||
@@ -257,2 +282,11 @@ if (isUsingSrc) { | ||
} | ||
await writeGraphQLSP(targetDir); | ||
await updateTSConfig(targetDir); | ||
s.stop(kl.green("Added Fuse plugin to next config!")); | ||
prompts.outro( | ||
kl.trueColor(219, 254, 1)("You're all set to work with your datalayer!") | ||
); | ||
} | ||
createFuseApp().catch(console.error); | ||
var writeGraphQLSP = async (targetDir) => { | ||
if (existsSync(resolve(targetDir, ".vscode", "settings.json"))) { | ||
@@ -281,2 +315,4 @@ const vscodeSettingsFile = await fs.readFile( | ||
} | ||
}; | ||
var updateTSConfig = async (targetDir) => { | ||
if (existsSync(resolve(targetDir, "tsconfig.json"))) { | ||
@@ -314,8 +350,3 @@ const tsConfigFile = await fs.readFile( | ||
} | ||
s.stop(kl.green("Added Fuse plugin to next config!")); | ||
prompts.outro( | ||
kl.trueColor(219, 254, 1)("You're all set to work with your datalayer!") | ||
); | ||
} | ||
createFuseApp().catch(console.error); | ||
}; | ||
var initialTypeSnippet = `import { node } from 'fuse' | ||
@@ -322,0 +353,0 @@ |
{ | ||
"name": "create-fuse-app", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "The magical GraphQL framework", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/StellateHQ/fuse.js", |
15275
384