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"; ...@@ -12,18 +12,18 @@ import type { TemplateFramework, TemplateType } from "./templates";
import { installTemplate } from "./templates"; import { installTemplate } from "./templates";
export async function createApp({ export async function createApp({
template,
framework, framework,
appPath, appPath,
packageManager, packageManager,
eslint, eslint,
}: { }: {
template: TemplateType;
framework: TemplateFramework; framework: TemplateFramework;
appPath: string; appPath: string;
packageManager: PackageManager; packageManager: PackageManager;
eslint: boolean; eslint: boolean;
}): Promise<void> { }): Promise<void> {
const template: TemplateType = "simple";
const root = path.resolve(appPath); const root = path.resolve(appPath);
if (!(await isWriteable(path.dirname(root)))) { if (!(await isWriteable(path.dirname(root)))) {
......
...@@ -177,12 +177,40 @@ async function run(): Promise<void> { ...@@ -177,12 +177,40 @@ async function run(): Promise<void> {
>; >;
const defaults: typeof preferences = { const defaults: typeof preferences = {
template: "simple",
framework: "nextjs", framework: "nextjs",
eslint: true, eslint: true,
}; };
const getPrefOrDefault = (field: string) => const getPrefOrDefault = (field: string) =>
preferences[field] ?? defaults[field]; 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 (!program.framework) {
if (ciInfo.isCI) { if (ciInfo.isCI) {
program.framework = getPrefOrDefault("framework"); program.framework = getPrefOrDefault("framework");
...@@ -233,6 +261,7 @@ async function run(): Promise<void> { ...@@ -233,6 +261,7 @@ async function run(): Promise<void> {
} }
await createApp({ await createApp({
template: program.template,
framework: program.framework, framework: program.framework,
appPath: resolvedProjectPath, appPath: resolvedProjectPath,
packageManager, packageManager,
......
import { PackageManager } from "../helpers/get-pkg-manager"; import { PackageManager } from "../helpers/get-pkg-manager";
export type TemplateType = "simple"; export type TemplateType = "simple" | "streaming";
export type TemplateFramework = "nextjs" | "express"; export type TemplateFramework = "nextjs" | "express";
export interface InstallTemplateArgs { 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