@@ -6,9 +6,84 @@ import spawn from "@npmcli/promise-spawn";
6
6
import ora from "ora" ;
7
7
import { rm } from "fs/promises" ;
8
8
import { join } from "path" ;
9
+ import chalk from "chalk" ;
9
10
10
11
const contextIsNpmCreate = process . env . npm_command === "init" ;
11
12
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
+
12
87
// npm/10.1.0 node/v20.9.0 darwin x64 workspaces/false
13
88
// pnpm/9.1.0 npm/? node/v20.9.0 darwin x64
14
89
// yarn/1.7.0 npm/? node/v8.9.4 darwin x64
@@ -44,6 +119,20 @@ program
44
119
] ,
45
120
} ) ;
46
121
}
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
+ } );
47
136
// TODO DRY up validation and error message, move to commander parse
48
137
let packageManagerVersion = "*";
49
138
if (packageManager) {
@@ -74,9 +163,8 @@ program
74
163
} ) ;
75
164
}
76
165
const cloneSpinner = ora("Cloning template...").start();
77
- // TODO allow different templates
78
166
await downloadTemplate(
79
- `gh:FirebaseExtended/firebase-framework-tools/starters/${ framework } /basic ` ,
167
+ `gh:FirebaseExtended/firebase-framework-tools/starters/${ framework } /$ { example } `,
80
168
{ dir : directory , force : true } ,
81
169
);
82
170
cloneSpinner.succeed();
0 commit comments