Skip to content
Snippets Groups Projects
Commit cd6ebf72 authored by Marcus Schiesser's avatar Marcus Schiesser
Browse files

dx: add hint if tool config is needed

parent 50b2ddbb
No related branches found
No related tags found
No related merge requests found
...@@ -173,9 +173,15 @@ export const getTools = (toolsName: string[]): Tool[] => { ...@@ -173,9 +173,15 @@ export const getTools = (toolsName: string[]): Tool[] => {
return tools; return tools;
}; };
export const toolRequiresConfig = (tool: Tool): boolean => {
const hasConfig = Object.keys(tool.config || {}).length > 0;
const hasEmptyEnvVar = tool.envVars?.some((envVar) => !envVar.value) ?? false;
return hasConfig || hasEmptyEnvVar;
};
export const toolsRequireConfig = (tools?: Tool[]): boolean => { export const toolsRequireConfig = (tools?: Tool[]): boolean => {
if (tools) { if (tools) {
return tools?.some((tool) => Object.keys(tool.config || {}).length > 0); return tools?.some(toolRequiresConfig);
} }
return false; return false;
}; };
......
...@@ -16,7 +16,11 @@ import { templatesDir } from "./helpers/dir"; ...@@ -16,7 +16,11 @@ import { templatesDir } from "./helpers/dir";
import { getAvailableLlamapackOptions } from "./helpers/llama-pack"; import { getAvailableLlamapackOptions } from "./helpers/llama-pack";
import { askModelConfig } from "./helpers/providers"; import { askModelConfig } from "./helpers/providers";
import { getProjectOptions } from "./helpers/repo"; import { getProjectOptions } from "./helpers/repo";
import { supportedTools, toolsRequireConfig } from "./helpers/tools"; import {
supportedTools,
toolRequiresConfig,
toolsRequireConfig,
} from "./helpers/tools";
export type QuestionArgs = Omit< export type QuestionArgs = Omit<
InstallAppArgs, InstallAppArgs,
...@@ -652,7 +656,7 @@ export const askQuestions = async ( ...@@ -652,7 +656,7 @@ export const askQuestions = async (
t.supportedFrameworks?.includes(program.framework), t.supportedFrameworks?.includes(program.framework),
); );
const toolChoices = options.map((tool) => ({ const toolChoices = options.map((tool) => ({
title: tool.display, title: `${tool.display}${toolRequiresConfig(tool) ? "" : " (no config needed)"}`,
value: tool.name, value: tool.name,
})); }));
const { toolsName } = await prompts({ const { toolsName } = await prompts({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment