@@ -6,9 +6,87 @@ 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
+ const STARTERS : Record <
14
+ string ,
15
+ Array < { name : string ; value: string ; description: string ; products: string [ ] ; init ? : string } >
16
+ > = {
17
+ angular : [
18
+ {
19
+ name : "Basic" ,
20
+ value : "basic" ,
21
+ description : "A basic Angular starter template." ,
22
+ products : [ ] ,
23
+ } ,
24
+ {
25
+ name : "AI chatbot" ,
26
+ value : "ai-chatbot" ,
27
+ description : "Simple chatbot app that supports multiple chats." ,
28
+ products : [ "Gemini" ] ,
29
+ } ,
30
+ {
31
+ name : "AI text editor" ,
32
+ value : "ai-text-editor" ,
33
+ description :
34
+ "AI-powered editor that provides text enhancement tools and supports basic formatting." ,
35
+ products : [ "Gemini" ] ,
36
+ } ,
37
+ {
38
+ name : "Dashboard" ,
39
+ value : "dashboard" ,
40
+ description :
41
+ "Dashboard app with a set of configurable visualization widgets and data sources." ,
42
+ products : [ ] ,
43
+ } ,
44
+ {
45
+ name : "Ecommerce" ,
46
+ value : "ecommerce" ,
47
+ description :
48
+ "Basic Ecommerce app composed of a landing page, products list and details pages, and a cart." ,
49
+ products : [ ] ,
50
+ } ,
51
+ {
52
+ name : "Image Gallery" ,
53
+ value : "image-gallery" ,
54
+ description : "Optimized image gallery that supports image previews." ,
55
+ products : [ ] ,
56
+ } ,
57
+ {
58
+ name : "Kanban Board" ,
59
+ value : "kanban" ,
60
+ description : "Provides the well-known board UI accompanied by draggable cards." ,
61
+ products : [ ] ,
62
+ } ,
63
+ ] ,
64
+ nextjs : [
65
+ {
66
+ name : "Basic" ,
67
+ value : "basic" ,
68
+ description : "A basic Next.js starter template." ,
69
+ products : [ ] ,
70
+ } ,
71
+ {
72
+ name : "Shopify example" ,
73
+ value : "shopify-ecommerce" ,
74
+ description :
75
+ "A headless Shopify ecommerce template built with Next.js, the Shopify Storefront API, and Firebase Data Connect." ,
76
+ products : [ "Data Connect" , "Auth" , "Gemini" , "Shopify" ] ,
77
+ init : "apphosting,dataconnect,auth" ,
78
+ } ,
79
+ {
80
+ name : "Firebase ecommerce" ,
81
+ value : "firebase-ecommerce" ,
82
+ description :
83
+ "A Firebase-based e-commerce application designed for developers to bootstrap their e-commerce projects." ,
84
+ products : [ "Data Connect" , "Auth" , "Gemini" , "Stripe" ] ,
85
+ init : "apphosting,dataconnect,auth" ,
86
+ } ,
87
+ ] ,
88
+ } ;
89
+
12
90
// npm/10.1.0 node/v20.9.0 darwin x64 workspaces/false
13
91
// pnpm/9.1.0 npm/? node/v20.9.0 darwin x64
14
92
// yarn/1.7.0 npm/? node/v8.9.4 darwin x64
@@ -44,6 +122,20 @@ program
44
122
] ,
45
123
} ) ;
46
124
}
125
+ const example = await select ( {
126
+ message : "Select a starter template" ,
127
+ choices : STARTERS [ framework ] . map ( ( starter ) => ( {
128
+ name : chalk . bold ( starter . name ) ,
129
+ short : starter . name ,
130
+ description : `\n${ starter . description } ${
131
+ starter . products . length
132
+ ? `\nProducts: ${ chalk . italic ( starter . products . join ( ", " ) ) } `
133
+ : ""
134
+ } `,
135
+ value : starter . value ,
136
+ default : "basic" ,
137
+ } ) ) ,
138
+ } ) ;
47
139
// TODO DRY up validation and error message, move to commander parse
48
140
let packageManagerVersion = "*" ;
49
141
if ( packageManager ) {
@@ -76,7 +168,7 @@ program
76
168
const cloneSpinner = ora ( "Cloning template..." ) . start ( ) ;
77
169
// TODO allow different templates
78
170
await downloadTemplate (
79
- `gh:FirebaseExtended/firebase-framework-tools/starters/${ framework } /basic ` ,
171
+ `gh:FirebaseExtended/firebase-framework-tools/starters/${ framework } /${ example } ` ,
80
172
{ dir : directory , force : true } ,
81
173
) ;
82
174
cloneSpinner . succeed ( ) ;
@@ -100,6 +192,15 @@ program
100
192
} ) ;
101
193
await rm ( join ( directory , "package-lock.json" ) ) ;
102
194
}
195
+ /*
196
+ const init = STARTERS[framework].find(it => it.value === example)!.init ?? "apphosting";;
197
+ console.log(`> firebase init ${init}`);
198
+ await await spawn("npx", ["-y", "firebase-tools@latest", "init", init], {
199
+ shell: true,
200
+ stdio: "inherit",
201
+ cwd: directory,
202
+ });
203
+ */
103
204
} ,
104
205
) ;
105
206
0 commit comments