Skip to content

Commit

Permalink
Merge pull request #412 from scottbenton/feat/homebrew-sharing
Browse files Browse the repository at this point in the history
feat(homebrew sharing): Begin working on adding functions for sharing…
  • Loading branch information
scottbenton authored Apr 26, 2024
2 parents 2811386 + ef149a1 commit 0cb6b0c
Show file tree
Hide file tree
Showing 79 changed files with 10,604 additions and 859 deletions.
5 changes: 3 additions & 2 deletions .firebaserc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"projects": {
"iron-fellowship-prod": "iron-journal-1ac32",
"iron-fellowship-dev": "iron-fellowship-dev",
"crew-link-prod":"starforged-crew-link",
"crew-link-dev":"crew-link-dev"
"crew-link-prod": "starforged-crew-link",
"crew-link-dev": "crew-link-dev",
"default": "iron-fellowship-dev"
},
"targets": {},
"etags": {}
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/firebase-hosting-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ jobs:
env:
GCP_SA_KEY: ${{ secrets.IRON_FELLOWSHIP_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.IRON_FELLOWSHIP_FIREBASE_PROJECTID}}"
deploy_functions_iron_fellowship:
name: Deploy Firebase Functions to Iron Fellowship
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v2
- run: cd functions && npm ci && npm run build
- uses: w9jds/[email protected]
with:
args: deploy --only functions
env:
GCP_SA_KEY: ${{ secrets.IRON_FELLOWSHIP_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.IRON_FELLOWSHIP_FIREBASE_PROJECTID}}"

build_and_deploy_crew_link:
name: Build and Deploy Crew Link to Firebase Hosting
runs-on: ubuntu-latest
Expand Down Expand Up @@ -105,3 +119,16 @@ jobs:
env:
GCP_SA_KEY: ${{ secrets.CREW_LINK_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.CREW_LINK_FIREBASE_PROJECTID}}"
deploy_functions_crew_link:
name: Deploy Firebase Functions to Crew Link
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v2
- run: cd functions && npm ci && npm run build
- uses: w9jds/[email protected]
with:
args: deploy --only functions
env:
GCP_SA_KEY: ${{ secrets.CREW_LINK_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.CREW_LINK_FIREBASE_PROJECTID}}"
13 changes: 13 additions & 0 deletions .github/workflows/firebase-hosting-pull-request-crew-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,16 @@ jobs:
env:
GCP_SA_KEY: ${{ secrets.CREW_LINK_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.CREW_LINK_FIREBASE_PROJECTID}}"
deploy_functions_crew_link:
name: Deploy Firebase Functions to Crew Link
runs-on: ubuntu-latest
environment: Dev
steps:
- uses: actions/checkout@v2
- run: cd functions && npm ci && npm run build
- uses: w9jds/[email protected]
with:
args: deploy --only functions
env:
GCP_SA_KEY: ${{ secrets.CREW_LINK_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.CREW_LINK_FIREBASE_PROJECTID}}"
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,16 @@ jobs:
env:
GCP_SA_KEY: ${{ secrets.IRON_FELLOWSHIP_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.IRON_FELLOWSHIP_FIREBASE_PROJECTID}}"
deploy_functions_iron_fellowship:
name: Deploy Firebase Functions to Iron Fellowship
runs-on: ubuntu-latest
environment: Dev
steps:
- uses: actions/checkout@v2
- run: cd functions && npm ci && npm run build
- uses: w9jds/[email protected]
with:
args: deploy --only functions
env:
GCP_SA_KEY: ${{ secrets.IRON_FELLOWSHIP_FIREBASE_SERVICE_ACCOUNT }}
PROJECT_ID: "${{secrets.IRON_FELLOWSHIP_FIREBASE_PROJECTID}}"
18 changes: 17 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,21 @@
},
"storage": {
"rules": "storage.rules"
}
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
]
}
30 changes: 17 additions & 13 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -109,76 +109,80 @@ service cloud.firestore {
}

match /collections/{homebrewId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if request.auth.uid in resource.data.editors;
allow update: if (request.auth.uid in resource.data.editors && !request.resource.data.diff(resource.data).affectedKeys().hasAny(["creator", "editors"])) || (request.auth.uid != null && request.resource.data.diff(resource.data).affectedKeys().hasOnly(["viewers"]));
allow delete: if (request.auth.uid == resource.data.creator);
}

match /stats/{statId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /condition_meters/{conditionMeterId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /non_linear_meters/{meterId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /impacts/{impactCategoryId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /legacy_tracks/{legacyTrackId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /oracle_tables/{oracleTableId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /oracle_collections/{oracleCollectionId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /move_categories/{moveCategoryId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /moves/{moveId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /asset_collections/{assetCollectionId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /assets/{assetId} {
allow read: if request.auth.uid != null;
allow read: if true;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}
match /editorInviteKeys/{inviteKeyId} {
allow read, write: if false;
}
}
match /users/{userId} {
allow read: if true;
Expand Down
28 changes: 28 additions & 0 deletions functions/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
],
plugins: ["@typescript-eslint", "import"],
rules: {
quotes: ["error", "double"],
"import/no-unresolved": 0,
indent: ["error", 2],
},
};
9 changes: 9 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Compiled JavaScript files
lib/**/*.js
lib/**/*.js.map

# TypeScript v1 declaration files
typings/

# Node.js dependency directory
node_modules/
Loading

0 comments on commit 0cb6b0c

Please sign in to comment.