From 60816cc0f5efd15b39fea62833ef24fb7569cb97 Mon Sep 17 00:00:00 2001 From: Marcus Schiesser <mail@marcusschiesser.de> Date: Mon, 13 Nov 2023 17:38:40 +0700 Subject: [PATCH] fix: don't copy backend files for frontend-only --- create-app.ts | 5 +++-- templates/index.ts | 26 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/create-app.ts b/create-app.ts index 9afe5068..4b6fb532 100644 --- a/create-app.ts +++ b/create-app.ts @@ -71,7 +71,7 @@ export async function createApp({ // install backend const backendRoot = path.join(root, "backend"); await makeDir(backendRoot); - await installTemplate({ ...args, root: backendRoot }); + await installTemplate({ ...args, root: backendRoot, backend: true }); // install frontend const frontendRoot = path.join(root, "frontend"); await makeDir(frontendRoot); @@ -80,6 +80,7 @@ export async function createApp({ root: frontendRoot, framework: "nextjs", customApiPath: "http://localhost:8000/api/chat", + backend: false, }); // copy readme for fullstack await fs.promises.copyFile( @@ -87,7 +88,7 @@ export async function createApp({ path.join(root, "README.md"), ); } else { - await installTemplate(args); + await installTemplate({ ...args, backend: true }); } process.chdir(root); diff --git a/templates/index.ts b/templates/index.ts index 9ff80cc0..98eece52 100644 --- a/templates/index.ts +++ b/templates/index.ts @@ -267,7 +267,9 @@ const installPythonTemplate = async ({ ); }; -export const installTemplate = async (props: InstallTemplateArgs) => { +export const installTemplate = async ( + props: InstallTemplateArgs & { backend: boolean }, +) => { process.chdir(props.root); if (props.framework === "fastapi") { await installPythonTemplate(props); @@ -275,16 +277,20 @@ export const installTemplate = async (props: InstallTemplateArgs) => { await installTSTemplate(props); } - // Copy the environment file to the target directory. - await createEnvLocalFile(props.root, props.framework, props.openAIKey); + if (props.backend) { + // This is a backend, so we need to copy the test data and create the env file. - // Copy test pdf file - await copyTestData( - props.root, - props.framework, - props.packageManager, - props.engine, - ); + // Copy the environment file to the target directory. + await createEnvLocalFile(props.root, props.framework, props.openAIKey); + + // Copy test pdf file + await copyTestData( + props.root, + props.framework, + props.packageManager, + props.engine, + ); + } }; export * from "./types"; -- GitLab