@@ -6,9 +6,84 @@ import spawn from "@npmcli/promise-spawn";
66import ora from "ora" ;
77import { rm } from "fs/promises" ;
88import { join } from "path" ;
9+ import chalk from "chalk" ;
910
1011const contextIsNpmCreate = process . env . npm_command === "init" ;
1112
13+ type Starter = { name : string ; value: string ; description: string ; products: string [ ] } ;
14+
15+ const STARTERS : Record < string , Array < Starter > > = {
16+ angular : [
17+ {
18+ name : "Basic" ,
19+ value : "basic" ,
20+ description : "A basic Angular starter template." ,
21+ products : [ ] ,
22+ } ,
23+ {
24+ name : "AI chatbot" ,
25+ value : "ai-chatbot" ,
26+ description : "Simple chatbot app that supports multiple chats." ,
27+ products : [ "Gemini" ] ,
28+ } ,
29+ {
30+ name : "AI text editor" ,
31+ value : "ai-text-editor" ,
32+ description :
33+ "AI-powered editor that provides text enhancement tools and supports basic formatting." ,
34+ products : [ "Gemini" ] ,
35+ } ,
36+ {
37+ name : "Dashboard" ,
38+ value : "dashboard" ,
39+ description :
40+ "Dashboard app with a set of configurable visualization widgets and data sources." ,
41+ products : [ ] ,
42+ } ,
43+ {
44+ name : "Ecommerce" ,
45+ value : "ecommerce" ,
46+ description :
47+ "Basic Ecommerce app composed of a landing page, products list and details pages, and a cart." ,
48+ products : [ ] ,
49+ } ,
50+ {
51+ name : "Image Gallery" ,
52+ value : "image-gallery" ,
53+ description : "Optimized image gallery that supports image previews." ,
54+ products : [ ] ,
55+ } ,
56+ {
57+ name : "Kanban Board" ,
58+ value : "kanban" ,
59+ description : "Provides the well-known board UI accompanied by draggable cards." ,
60+ products : [ ] ,
61+ } ,
62+ ] ,
63+ nextjs : [
64+ {
65+ name : "Basic" ,
66+ value : "basic" ,
67+ description : "A basic Next.js starter template." ,
68+ products : [ ] ,
69+ } ,
70+ {
71+ name : "Shopify example" ,
72+ value : "shopify-ecommerce" ,
73+ description :
74+ "A headless Shopify ecommerce template built with Next.js, the Shopify Storefront API, and Firebase Data Connect." ,
75+ products : [ "Data Connect" , "Auth" , "Gemini" , "Shopify" ] ,
76+ } ,
77+ {
78+ name : "Firebase ecommerce" ,
79+ value : "firebase-ecommerce" ,
80+ description :
81+ "A Firebase-based e-commerce application designed for developers to bootstrap their e-commerce projects." ,
82+ products : [ "Data Connect" , "Auth" , "Gemini" , "Stripe" ] ,
83+ } ,
84+ ] ,
85+ } ;
86+
1287// npm/10.1.0 node/v20.9.0 darwin x64 workspaces/false
1388// pnpm/9.1.0 npm/? node/v20.9.0 darwin x64
1489// yarn/1.7.0 npm/? node/v8.9.4 darwin x64
@@ -44,6 +119,20 @@ program
44119 ] ,
45120 } ) ;
46121 }
122+ const example = await select({
123+ message : "Select a starter template" ,
124+ choices : STARTERS [ framework ] . map ( ( starter ) => ( {
125+ name : chalk . bold ( starter . name ) ,
126+ short : starter . name ,
127+ description : `\n${ starter . description } ${
128+ starter . products . length
129+ ? `\nProducts: ${ chalk . italic ( starter . products . join ( ", " ) ) } `
130+ : ""
131+ } `,
132+ value : starter . value ,
133+ default : "basic" ,
134+ } ) ) ,
135+ } );
47136 // TODO DRY up validation and error message, move to commander parse
48137 let packageManagerVersion = "*";
49138 if (packageManager) {
@@ -74,9 +163,8 @@ program
74163 } ) ;
75164 }
76165 const cloneSpinner = ora("Cloning template...").start();
77- // TODO allow different templates
78166 await downloadTemplate(
79- `gh:FirebaseExtended/firebase-framework-tools/starters/${ framework } /basic ` ,
167+ `gh:FirebaseExtended/firebase-framework-tools/starters/${ framework } /$ { example } `,
80168 { dir : directory , force : true } ,
81169 );
82170 cloneSpinner.succeed();
0 commit comments