Skip to content

Commit

Permalink
Merge pull request #2 from theHandsomestNerd/sanity-upgrade
Browse files Browse the repository at this point in the history
Sanity upgrade
  • Loading branch information
tmanundercover committed Sep 26, 2023
2 parents c108030 + 7e06f7b commit b26bc46
Show file tree
Hide file tree
Showing 119 changed files with 22,673 additions and 39,453 deletions.
8 changes: 5 additions & 3 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"projects": {
"default": "the-handsomest-nerd-internal"
}
}
"the-handsomest-nerd-internal": "the-handsomest-nerd-internal"
},
"targets": {},
"etags": {}
}
33 changes: 6 additions & 27 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,17 @@ name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- master
- master

jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checking out code
uses: actions/checkout@v2
- name: Setting up CI Env variables
run: |
set -e
# Put your environment variables here. Don't forget
# to create secrets for them on GitHub:
# https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
cat << EOF > .env
REACT_APP_SANITY_PROJECTID="${{ secrets.REACT_APP_SANITY_PROJECTID }}"
REACT_APP_SANITY_DB="${{ secrets.REACT_APP_SANITY_DB }}"
REACT_APP_API_KEY="${{ secrets.REACT_APP_API_KEY }}"
REACT_APP_AUTH_DOMAIN="${{ secrets.REACT_APP_AUTH_DOMAIN }}"
REACT_APP_PROJECT_ID="${{ secrets.REACT_APP_PROJECT_ID }}"
REACT_APP_STORAGE_BUCKET="${{ secrets.REACT_APP_STORAGE_BUCKET }}"
REACT_APP_MESSAGING_SENDER_ID="${{ secrets.REACT_APP_MESSAGING_SENDER_ID }}"
REACT_APP_APP_ID="${{ secrets.REACT_APP_APP_ID }}"
REACT_APP_FIREBASE_ANALYTICS_TRACKING_ID="${{ secrets.REACT_APP_FIREBASE_ANALYTICS_TRACKING_ID }}"
EOF
- name: Building production code
run: unset CI && npm ci && npm run build

- name: Deploying to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
- uses: actions/checkout@v2
- run: npm ci && tsc && yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_ST_JOSEPH_FWBC }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_THE_HANDSOMEST_NERD }}'
channelId: live
projectId: st-joseph-fwbc
projectId: the-handsomest-nerd-internal
20 changes: 4 additions & 16 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Creating env file
run: |
set -e
# Put your environment variables here. Don't forget
# to create secrets for them on GitHub:
# https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
cat << EOF > .env.production
REACT_APP_SANITY_PROJECTID="${{ secrets.REACT_APP_SANITY_PROJECTID }}"
REACT_APP_SANITY_DB="${{ secrets.REACT_APP_SANITY_DB }}"
EOF
- name: Building code
run: unset CI && npm ci && npm run build
- name: Deploying to hosting
uses: FirebaseExtended/action-hosting-deploy@v0
- run: npm ci && tsc && yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_ST_JOSEPH_FWBC }}'
projectId: st-joseph-fwbc
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_THE_HANDSOMEST_NERD }}'
projectId: the-handsomest-nerd-internal
26 changes: 13 additions & 13 deletions functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@sanity/types": "^2.34.0",
"@sendgrid/mail": "^7.7.0",
"@shopify/shopify-api": "^2.0.0",
"@sendgrid/mail": "^7.7.0",
"axios": "^0.24.0",
"dotenv": "^16.0.3",
"es6-promise": "^4.2.8",
Expand Down
2 changes: 1 addition & 1 deletion functions/src/cmsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const fetchPage = async (pageSlug:string)=>{
`*[slug.current == $pageSlug]{
${groqQueries.HOMEPAGE}
}`, {pageSlug})
.then((data:any) => {
.then((data: any[]) => {
log("fetchPage", "NOTICE", "fetched page", {pageSlug, page: data[0]});
return data[0];
})
Expand Down
1 change: 1 addition & 0 deletions functions/src/groqQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const HOMEPAGE = `_type,
"cvFile": cvFile.asset->
}
},
isFabActivated,
"servicesAvailable": servicesAvailable[]->{
${SERVICE}
},
Expand Down
15 changes: 8 additions & 7 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import * as cmsClient from "./cmsClient";
import * as Promise from "es6-promise";
import * as path from "path";
import * as fs from "fs";
import imageUrlBuilder from "@sanity/image-url";
import sanityClient from "./sanityClient";

// import {SanityColdLead, SanityTransformHwHomePage}
// from "../../src/common/sanityIo/Types";
// import {urlFor} from
// "../../src/components/block-content-ui/static-pages/cmsStaticPagesClient";
import sendGridClient from "./sendGridClient";
import imageUrlBuilder from "@sanity/image-url";
// import {SanityImageSource} from "@sanity/asset-utils";
import {sanityClient} from "./sanityClient";
// To Throttle requests to sanity

Promise.polyfill();
Expand Down Expand Up @@ -94,6 +95,7 @@ const indexPath = path.resolve(__dirname, ...indexPathParts, "index.html");

console.log(path.resolve(__dirname, ...indexPathParts), files);


const serveIndexFile = (req: any, res: any) => {
fs.readFile(indexPath, "utf8", async (err, htmlData) => {
if (err) {
Expand Down Expand Up @@ -121,7 +123,7 @@ const serveIndexFile = (req: any, res: any) => {
ogTitle: pageFromSanity?.title,
description: pageFromSanity?.description,
ogDescription: pageFromSanity?.description,
ogImage: pageFromSanity?.metaImage && urlFor(pageFromSanity?.metaImage).url()?.replace("undefined", process.env.SANITY_DB ?? "development"),
ogImage: pageFromSanity.metaImage && builder.image(pageFromSanity.metaImage).url()?.replace("undefined", process.env.SANITY_DB ?? "development"),
};

logClient.log("server-side", "NOTICE",
Expand Down Expand Up @@ -181,7 +183,7 @@ app.post("/send-email-resume",

app.post("/collect-email-address",
async (req: any, functionRes: any) => {
const reqBody: any = JSON.parse(req.body);
const reqBody = JSON.parse(req.body);

logClient.log("collect-email-address", "NOTICE",
"Request to collect an email address", reqBody.email);
Expand All @@ -194,15 +196,14 @@ app.post("/collect-email-address",
leadName: reqBody.leadName,
source: reqBody.source,
});
functionRes.send({status: "200", response, email: reqBody.email, message: "Thank you! We will talk soon."});
functionRes.send({status: "200", response, email: reqBody.email});
} catch (e) {
logClient.log("collect-email-address", "ERROR",
"Could not create Lead", {email: reqBody.email});
functionRes.send({status: "400", e});
functionRes.error({status: "400", e});
}
});


app.use(express.static(
path.resolve(__dirname, "../../../../", "build"),
{maxAge: "30d", index: "blah.txt"},
Expand Down
2 changes: 1 addition & 1 deletion functions/src/sanityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const sanityClient = client({
token: process.env.SANITY_API_TOKEN,
useCdn: false,
});

export default sanityClient;
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"react-syntax-highlighter": "^15.4.3",
"storybook-addon-material-ui": "^0.9.0-alpha.24",
"ts-node": "^10.1.0",
"typescript": "^4.5.4",
"typescript": "^4.9.5",
"uuid": "^9.0.0",
"validator": "^13.7.0",
"web-vitals": "^1.0.1"
Expand Down
11 changes: 11 additions & 0 deletions sanityIo/.sanity/runtime/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

// This file is auto-generated on 'sanity dev'
// Modifications to this file is automatically discarded
import {renderStudio} from "sanity"
import studioConfig from "../../sanity.config.js"

renderStudio(
document.getElementById("sanity"),
studioConfig,
{reactStrictMode: false, basePath: "/"}
)
Loading

0 comments on commit b26bc46

Please sign in to comment.