Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions packages/openui-cli/src/commands/create-chat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,47 @@ export async function runCreateChatApp(options: CreateChatAppOptions): Promise<v
? "bun"
: "npm";

console.info(getStartedMessage(name, devCmd, installSkill));
let apiKeyWritten = false;
if (!options.noInteractive) {
const { input } = await import("@inquirer/prompts");
const apiKey = (
await input({ message: "Enter your OpenAI API key (leave blank to skip):" })
).trim();

if (apiKey) {
fs.writeFileSync(path.join(targetDir, ".env"), `OPENAI_API_KEY=${apiKey}\n`);
apiKeyWritten = true;
}
}

console.info(getStartedMessage(name, devCmd, installSkill, apiKeyWritten));
}

const getStartedMessage = (name: string, devCmd: string, skillInstalled: boolean) =>
`
Done!
Get started:
const getStartedMessage = (
name: string,
devCmd: string,
skillInstalled: boolean,
apiKeyWritten: boolean,
) => {
const envInstructions = apiKeyWritten
? "✅ .env file created with your API key."
: `touch .env

cd ${name}
Add your API key to .env:
OPENAI_API_KEY=sk-your-key-here`;

touch .env
const skillMessage = skillInstalled
? "The OpenUI agent skill was installed.\nAI coding assistants will use it to help you build with OpenUI."
: "";

Add your API key to .env:
OPENAI_API_KEY=sk-your-key-here
return `${skillMessage}

Done!
Get started:

${envInstructions}

${devCmd} run dev
${skillInstalled ? "\nThe OpenUI agent skill was installed.\nAI coding assistants will use it to help you build with OpenUI.\n" : ""}`;
> cd ${name}
> ${devCmd} run dev
`;
};
Loading