From b87c77376b085a1270ca300e472092f9d3a1a694 Mon Sep 17 00:00:00 2001 From: Marcus Schiesser <mail@marcusschiesser.de> Date: Wed, 27 Dec 2023 11:39:22 +0700 Subject: [PATCH] fix: don't allow frontend for non-streaming --- index.ts | 6 ++++++ questions.ts | 24 +++++++----------------- templates/types.ts | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/index.ts b/index.ts index 84396fa5..ebdcd1ee 100644 --- a/index.ts +++ b/index.ts @@ -121,6 +121,12 @@ Select external port. ) .allowUnknownOption() .parse(process.argv); +if (process.argv.includes("--no-frontend")) { + program.frontend = false; +} +if (process.argv.includes("--no-eslint")) { + program.eslint = false; +} const packageManager = !!program.useNpm ? "npm" diff --git a/questions.ts b/questions.ts index 5b4a9ca2..a1517dc3 100644 --- a/questions.ts +++ b/questions.ts @@ -89,14 +89,8 @@ export const askQuestions = async ( })), initial: 0, }, - { - onCancel: () => { - console.error("Exiting."); - process.exit(1); - }, - }, + handlers, ); - program.communityProjectPath = communityProjectPath; preferences.communityProjectPath = communityProjectPath; return; // early return - no further questions needed for community projects @@ -130,11 +124,12 @@ export const askQuestions = async ( } } - if (program.framework === "express" || program.framework === "fastapi") { - if (process.argv.includes("--no-frontend")) { - program.frontend = false; - } + if ( + program.template === "streaming" && + (program.framework === "express" || program.framework === "fastapi") + ) { // if a backend-only framework is selected, ask whether we should create a frontend + // (only for streaming backends) if (program.frontend === undefined) { if (ciInfo.isCI) { program.frontend = getPrefOrDefault("frontend"); @@ -161,7 +156,6 @@ export const askQuestions = async ( } } } else { - // single project if framework is nextjs program.frontend = false; } @@ -283,11 +277,7 @@ export const askQuestions = async ( preferences.openAiKey = key; } - if ( - program.framework !== "fastapi" && - !process.argv.includes("--eslint") && - !process.argv.includes("--no-eslint") - ) { + if (program.framework !== "fastapi" && program.eslint === undefined) { if (ciInfo.isCI) { program.eslint = getPrefOrDefault("eslint"); } else { diff --git a/templates/types.ts b/templates/types.ts index 6fc7b47c..a0567e10 100644 --- a/templates/types.ts +++ b/templates/types.ts @@ -13,7 +13,7 @@ export interface InstallTemplateArgs { isOnline: boolean; template: TemplateType; framework: TemplateFramework; - engine?: TemplateEngine; + engine: TemplateEngine; ui: TemplateUI; eslint: boolean; customApiPath?: string; -- GitLab