Skip to content

Commit dc40547

Browse files
committed
Add all starters to create
1 parent f1f97fd commit dc40547

File tree

3 files changed

+103
-3
lines changed

3 files changed

+103
-3
lines changed

packages/@apphosting/adapter-nextjs/src/overrides.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export async function validateNextConfigOverride(
151151
*
152152
* It also adds the following headers to all routes for which middleware is enabled:
153153
* - x-fah-middleware: When middleware is enabled.
154-
*
155154
* @param appPath The path to the app directory.
156155
* @param distDir The path to the dist directory.
157156
* @param adapterMetadata The adapter metadata.

packages/@apphosting/create/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apphosting/create",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"main": "dist/index.js",
55
"description": "Experimental addon to the Firebase CLI to add web framework support",
66
"repository": {

packages/@apphosting/create/src/bin/create.ts

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,87 @@ import spawn from "@npmcli/promise-spawn";
66
import ora from "ora";
77
import { rm } from "fs/promises";
88
import { join } from "path";
9+
import chalk from "chalk";
910

1011
const contextIsNpmCreate = process.env.npm_command === "init";
1112

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+
1290
// npm/10.1.0 node/v20.9.0 darwin x64 workspaces/false
1391
// pnpm/9.1.0 npm/? node/v20.9.0 darwin x64
1492
// yarn/1.7.0 npm/? node/v8.9.4 darwin x64
@@ -44,6 +122,20 @@ program
44122
],
45123
});
46124
}
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+
});
47139
// TODO DRY up validation and error message, move to commander parse
48140
let packageManagerVersion = "*";
49141
if (packageManager) {
@@ -76,7 +168,7 @@ program
76168
const cloneSpinner = ora("Cloning template...").start();
77169
// TODO allow different templates
78170
await downloadTemplate(
79-
`gh:FirebaseExtended/firebase-framework-tools/starters/${framework}/basic`,
171+
`gh:FirebaseExtended/firebase-framework-tools/starters/${framework}/${example}`,
80172
{ dir: directory, force: true },
81173
);
82174
cloneSpinner.succeed();
@@ -100,6 +192,15 @@ program
100192
});
101193
await rm(join(directory, "package-lock.json"));
102194
}
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+
*/
103204
},
104205
);
105206

0 commit comments

Comments
 (0)