Skip to content

Commit 6d996a1

Browse files
Add Firebase Cloud Functions infrastructure.
1 parent b1e5f4d commit 6d996a1

File tree

9 files changed

+63
-4
lines changed

9 files changed

+63
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
- name: Deploy to Firebase
5555
run: |
56-
npx firebase-tools@latest deploy --project facorio-blueprints
56+
npm run deploy:all -- --project facorio-blueprints
5757
env:
5858
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.auth.outputs.credentials_file_path }}
5959

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ eslint_report.json
2828

2929
# Firebase export data
3030
factorio-blueprints-export.json
31+
32+
# Ignore compiled JS files in src and public (TypeScript project)
33+
src/**/*.js
34+
public/**/*.js
35+
!public/service-worker.js
36+
37+
# TypeScript build info
38+
tsconfig.tsbuildinfo

eslint.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import type {Linter} from 'eslint';
88

99
const config: Linter.Config[] = [
1010
{ignores: ['dist', 'build', '.llm/**', 'functions/**']},
11+
{
12+
files: ['functions/**/*.js'],
13+
languageOptions: {
14+
ecmaVersion: 2020,
15+
globals: {
16+
...globals.node,
17+
},
18+
sourceType: 'commonjs',
19+
},
20+
rules: {
21+
...js.configs.recommended.rules,
22+
},
23+
},
1124
{
1225
files: ['public/**/*.{ts,tsx}'],
1326
languageOptions: {

functions/.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es6: true,
5+
node: true,
6+
commonjs: true,
7+
},
8+
extends: ['eslint:recommended'],
9+
parserOptions: {
10+
ecmaVersion: 2020,
11+
},
12+
rules: {
13+
quotes: ['error', 'double'],
14+
'object-curly-spacing': ['error', 'never'],
15+
indent: ['error', 2],
16+
},
17+
};

functions/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ lib/**/*.js.map
66
typings/
77

88
node_modules/
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
firebase-debug.log*
13+
firebase-debug.*.log*

functions/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const functions = require('firebase-functions');
2+
const admin = require('firebase-admin');
3+
4+
admin.initializeApp();
5+
6+
exports.helloWorld = functions.https.onRequest((request, response) => {
7+
response.send('Hello from Firebase!');
8+
});

functions/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"name": "functions",
3+
"description": "Cloud Functions for Firebase",
34
"scripts": {
45
"build": "tsc",
56
"build:watch": "tsc --watch",
7+
"lint": "eslint .",
68
"serve": "npm run build && firebase emulators:start --only functions",
79
"shell": "npm run build && firebase functions:shell",
810
"start": "npm run shell",

justfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ build-ci: route-generate-ci install-ci
8282
precommit: format lint typecheck build-no-secrets test
8383
@echo "✅ All pre-commit checks passed!"
8484

85-
# `firebase deploy`
85+
# Deploy all Firebase services
8686
deploy: install
87-
firebase deploy
87+
npm run deploy:all
88+
89+
# Deploy only Cloud Functions
90+
deploy-functions: install
91+
npm run deploy:functions
8892

8993
# `firebase login`
9094
firebase-login: install

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"typecheck": "tsc --noEmit",
2121
"deploy:cloudflare": "wrangler pages deploy dist --project-name=factorio-prints",
2222
"deploy:cloudflare:preview": "wrangler pages deploy dist --project-name=factorio-prints --branch=preview",
23-
"deploy:cloudflare:production": "wrangler pages deploy dist --project-name=factorio-prints --branch=main"
23+
"deploy:cloudflare:production": "wrangler pages deploy dist --project-name=factorio-prints --branch=main",
24+
"deploy:functions": "cd functions && npm install && cd .. && firebase deploy --only functions",
25+
"deploy:all": "cd functions && npm install && cd .. && firebase deploy"
2426
},
2527
"dependencies": {
2628
"@fortawesome/fontawesome-svg-core": "7.0.0",

0 commit comments

Comments
 (0)