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

added support for generating streaming template

parent 2244da07
No related branches found
No related tags found
No related merge requests found
......@@ -12,18 +12,18 @@ import type { TemplateFramework, TemplateType } from "./templates";
import { installTemplate } from "./templates";
export async function createApp({
template,
framework,
appPath,
packageManager,
eslint,
}: {
template: TemplateType;
framework: TemplateFramework;
appPath: string;
packageManager: PackageManager;
eslint: boolean;
}): Promise<void> {
const template: TemplateType = "simple";
const root = path.resolve(appPath);
if (!(await isWriteable(path.dirname(root)))) {
......
......@@ -177,12 +177,40 @@ async function run(): Promise<void> {
>;
const defaults: typeof preferences = {
template: "simple",
framework: "nextjs",
eslint: true,
};
const getPrefOrDefault = (field: string) =>
preferences[field] ?? defaults[field];
if (!program.template) {
if (ciInfo.isCI) {
program.template = getPrefOrDefault("template");
} else {
const { template } = await prompts(
{
type: "select",
name: "template",
message: "Which template would you like to use?",
choices: [
{ title: "Simple chat without streaming", value: "simple" },
{ title: "Simple chat with streaming", value: "streaming" },
],
initial: 0,
},
{
onCancel: () => {
console.error("Exiting.");
process.exit(1);
},
},
);
program.template = template;
preferences.template = template;
}
}
if (!program.framework) {
if (ciInfo.isCI) {
program.framework = getPrefOrDefault("framework");
......@@ -233,6 +261,7 @@ async function run(): Promise<void> {
}
await createApp({
template: program.template,
framework: program.framework,
appPath: resolvedProjectPath,
packageManager,
......
import { PackageManager } from "../helpers/get-pkg-manager";
export type TemplateType = "simple";
export type TemplateType = "simple" | "streaming";
export type TemplateFramework = "nextjs" | "express";
export interface InstallTemplateArgs {
......
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