Skip to content

Commit b9889b8

Browse files
committed
feat(firebase): setup firebase hosting and firestore
Add Firebase SDK and configure hosting, Firestore, and Remote Config. Include GitHub Actions workflows for automated deployment to Firebase Hosting on merge and pull requests. Setup Firestore security rules, indexes, and initialization module with environment-based configuration.
1 parent c3fc74a commit b9889b8

13 files changed

Lines changed: 480 additions & 3 deletions

.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "super-agent-cli"
4+
}
5+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file was auto-generated by the Firebase CLI
2+
# https://github.com/firebase/firebase-tools
3+
4+
name: Deploy to Firebase Hosting on merge
5+
on:
6+
push:
7+
branches:
8+
- main
9+
jobs:
10+
build_and_deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- run: bun i && bun run build
15+
- uses: FirebaseExtended/action-hosting-deploy@v0
16+
with:
17+
repoToken: ${{ secrets.GITHUB_TOKEN }}
18+
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SUPER_AGENT_CLI }}
19+
channelId: live
20+
projectId: super-agent-cli
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file was auto-generated by the Firebase CLI
2+
# https://github.com/firebase/firebase-tools
3+
4+
name: Deploy to Firebase Hosting on PR
5+
on: pull_request
6+
permissions:
7+
checks: write
8+
contents: read
9+
pull-requests: write
10+
jobs:
11+
build_and_preview:
12+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- run: bun i && bun run build
17+
- uses: FirebaseExtended/action-hosting-deploy@v0
18+
with:
19+
repoToken: ${{ secrets.GITHUB_TOKEN }}
20+
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SUPER_AGENT_CLI }}
21+
projectId: super-agent-cli

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,4 @@ tsc_output.txt
114114

115115
.hintrc
116116
index.md
117+
.firebase/hosting.cHVibGlj.cache

bun.lock

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firebase.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hosting": {
3+
"public": "public",
4+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
5+
"rewrites": [
6+
{
7+
"source": "**",
8+
"destination": "/index.html"
9+
}
10+
]
11+
},
12+
"remoteconfig": {
13+
"template": "remoteconfig.template.json"
14+
}
15+
}

firestore.indexes.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
// Example (Standard Edition):
3+
//
4+
// "indexes": [
5+
// {
6+
// "collectionGroup": "widgets",
7+
// "queryScope": "COLLECTION",
8+
// "fields": [
9+
// { "fieldPath": "foo", "arrayConfig": "CONTAINS" },
10+
// { "fieldPath": "bar", "mode": "DESCENDING" }
11+
// ]
12+
// },
13+
//
14+
// "fieldOverrides": [
15+
// {
16+
// "collectionGroup": "widgets",
17+
// "fieldPath": "baz",
18+
// "indexes": [
19+
// { "order": "ASCENDING", "queryScope": "COLLECTION" }
20+
// ]
21+
// },
22+
// ]
23+
// ]
24+
//
25+
// Example (Enterprise Edition):
26+
//
27+
// "indexes": [
28+
// {
29+
// "collectionGroup": "reviews",
30+
// "queryScope": "COLLECTION_GROUP",
31+
// "apiScope": "MONGODB_COMPATIBLE_API",
32+
// "density": "DENSE",
33+
// "multikey": false,
34+
// "fields": [
35+
// { "fieldPath": "baz", "mode": "ASCENDING" }
36+
// ]
37+
// },
38+
// {
39+
// "collectionGroup": "items",
40+
// "queryScope": "COLLECTION_GROUP",
41+
// "apiScope": "MONGODB_COMPATIBLE_API",
42+
// "density": "SPARSE_ANY",
43+
// "multikey": true,
44+
// "fields": [
45+
// { "fieldPath": "baz", "mode": "ASCENDING" }
46+
// ]
47+
// },
48+
// ]
49+
"indexes": [],
50+
"fieldOverrides": []
51+
}

firestore.rules

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
rules_version='2'
2+
3+
service cloud.firestore {
4+
match /databases/{database}/documents {
5+
match /{document=**} {
6+
// This rule allows anyone with your database reference to view, edit,
7+
// and delete all data in your database. It is useful for getting
8+
// started, but it is configured to expire after 30 days because it
9+
// leaves your app open to attackers. At that time, all client
10+
// requests to your database will be denied.
11+
//
12+
// Make sure to write security rules for your app before that time, or
13+
// else all client requests to your database will be denied until you
14+
// update your rules.
15+
allow read, write: if request.time < timestamp.date(2026, 3, 2);
16+
}
17+
}
18+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"conventional-changelog-cli": "^5.0.0",
7070
"dotenv": "^17.2.3",
7171
"enquirer": "^2.4.1",
72+
"firebase": "^12.8.0",
7273
"fs-extra": "^11.3.3",
7374
"ignore": "^7.0.5",
7475
"ink": "^6.6.0",

public/index.html

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Welcome to Firebase Hosting</title>
7+
8+
<!-- update the version number as needed -->
9+
<script defer src="/__/firebase/12.8.0/firebase-app-compat.js"></script>
10+
<!-- include only the Firebase features as you need -->
11+
<script defer src="/__/firebase/12.8.0/firebase-auth-compat.js"></script>
12+
<script
13+
defer
14+
src="/__/firebase/12.8.0/firebase-database-compat.js"
15+
></script>
16+
<script
17+
defer
18+
src="/__/firebase/12.8.0/firebase-firestore-compat.js"
19+
></script>
20+
<script
21+
defer
22+
src="/__/firebase/12.8.0/firebase-functions-compat.js"
23+
></script>
24+
<script
25+
defer
26+
src="/__/firebase/12.8.0/firebase-messaging-compat.js"
27+
></script>
28+
<script defer src="/__/firebase/12.8.0/firebase-storage-compat.js"></script>
29+
<script
30+
defer
31+
src="/__/firebase/12.8.0/firebase-analytics-compat.js"
32+
></script>
33+
<script
34+
defer
35+
src="/__/firebase/12.8.0/firebase-remote-config-compat.js"
36+
></script>
37+
<script
38+
defer
39+
src="/__/firebase/12.8.0/firebase-performance-compat.js"
40+
></script>
41+
<!--
42+
initialize the SDK after all desired features are loaded, set useEmulator to false
43+
to avoid connecting the SDK to running emulators.
44+
-->
45+
<script defer src="/__/firebase/init.js?useEmulator=true"></script>
46+
47+
<style media="screen">
48+
body {
49+
background: #eceff1;
50+
color: rgba(0, 0, 0, 0.87);
51+
font-family: Roboto, Helvetica, Arial, sans-serif;
52+
margin: 0;
53+
padding: 0;
54+
}
55+
#message {
56+
background: white;
57+
max-width: 360px;
58+
margin: 100px auto 16px;
59+
padding: 32px 24px;
60+
border-radius: 3px;
61+
}
62+
#message h2 {
63+
color: #ffa100;
64+
font-weight: bold;
65+
font-size: 16px;
66+
margin: 0 0 8px;
67+
}
68+
#message h1 {
69+
font-size: 22px;
70+
font-weight: 300;
71+
color: rgba(0, 0, 0, 0.6);
72+
margin: 0 0 16px;
73+
}
74+
#message p {
75+
line-height: 140%;
76+
margin: 16px 0 24px;
77+
font-size: 14px;
78+
}
79+
#message a {
80+
display: block;
81+
text-align: center;
82+
background: #039be5;
83+
text-transform: uppercase;
84+
text-decoration: none;
85+
color: white;
86+
padding: 16px;
87+
border-radius: 4px;
88+
}
89+
#message,
90+
#message a {
91+
box-shadow:
92+
0 1px 3px rgba(0, 0, 0, 0.12),
93+
0 1px 2px rgba(0, 0, 0, 0.24);
94+
}
95+
#load {
96+
color: rgba(0, 0, 0, 0.4);
97+
text-align: center;
98+
font-size: 13px;
99+
}
100+
@media (max-width: 600px) {
101+
body,
102+
#message {
103+
margin-top: 0;
104+
background: white;
105+
box-shadow: none;
106+
}
107+
body {
108+
border-top: 16px solid #ffa100;
109+
}
110+
}
111+
</style>
112+
</head>
113+
<body>
114+
<div id="message">
115+
<h2>Welcome</h2>
116+
<h1>Firebase Hosting Setup Complete</h1>
117+
<p>
118+
You're seeing this because you've successfully setup Firebase Hosting.
119+
Now it's time to go build something extraordinary!
120+
</p>
121+
<a
122+
rel="noopener"
123+
target="_blank"
124+
href="https://firebase.google.com/docs/hosting/"
125+
>Open Hosting Documentation</a
126+
>
127+
</div>
128+
<p id="load">Firebase SDK Loading&hellip;</p>
129+
130+
<script>
131+
document.addEventListener("DOMContentLoaded", function () {
132+
const loadEl = document.querySelector("#load");
133+
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
134+
// // The Firebase SDK is initialized and available here!
135+
//
136+
// firebase.auth().onAuthStateChanged(user => { });
137+
// firebase.database().ref('/path/to/ref').on('value', snapshot => { });
138+
// firebase.firestore().doc('/foo/bar').get().then(() => { });
139+
// firebase.functions().httpsCallable('yourFunction')().then(() => { });
140+
// firebase.messaging().requestPermission().then(() => { });
141+
// firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { });
142+
// firebase.analytics(); // call to activate
143+
// firebase.analytics().logEvent('tutorial_completed');
144+
// firebase.performance(); // call to activate
145+
//
146+
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
147+
148+
try {
149+
let app = firebase.app();
150+
let features = [
151+
"auth",
152+
"database",
153+
"firestore",
154+
"functions",
155+
"messaging",
156+
"storage",
157+
"analytics",
158+
"remoteConfig",
159+
"performance",
160+
].filter(feature => typeof app[feature] === "function");
161+
loadEl.textContent = `Firebase SDK loaded with ${features.join(", ")}`;
162+
} catch (e) {
163+
console.error(e);
164+
loadEl.textContent =
165+
"Error loading the Firebase SDK, check the console.";
166+
}
167+
});
168+
</script>
169+
</body>
170+
</html>

0 commit comments

Comments
 (0)