Skip to content

Commit 86f275c

Browse files
authored
Add all starters to create (#339)
1 parent f1f97fd commit 86f275c

File tree

3 files changed

+91
-4
lines changed

3 files changed

+91
-4
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: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,84 @@ 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+
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

Comments
 (0)