Skip to content

Commit

Permalink
🎨 Add Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
homostellaris committed Feb 11, 2024
1 parent db30b4b commit 20a2a9a
Show file tree
Hide file tree
Showing 31 changed files with 706 additions and 742 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "lts/gallium"
cache: "npm"
node-version: 'lts/gallium'
cache: 'npm'
- run: npm ci
- run: cp .env.template .env
- run: cat .env >> $GITHUB_ENV
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
arrowParens: avoid
bracketSpacing: false
trailingComma: all
tabWidth: 2
semi: false
singleQuote: true
38 changes: 19 additions & 19 deletions cypress/integration/index.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
it("should work", () => {
cy.visit("/");
cy.get("#name").should("be.focused").type("Dan");
cy.contains("button", "NEXT").click();
it('should work', () => {
cy.visit('/')
cy.get('#name').should('be.focused').type('Dan')
cy.contains('button', 'NEXT').click()

cy.url().should("include", "/you");
cy.get(".calendar-date").last().click();
cy.contains("button", "NEXT").click();
cy.url().should('include', '/you')
cy.get('.calendar-date').last().click()
cy.contains('button', 'NEXT').click()

cy.url().should("include", "/everyone");
cy.get(".invitee").should("contain.text", "Dan");
cy.get(".streaming-status").should("contain.text", "Live-streaming updates");
cy.url().should('include', '/everyone')
cy.get('.invitee').should('contain.text', 'Dan')
cy.get('.streaming-status').should('contain.text', 'Live-streaming updates')

cy.task("updateSocial");
cy.reload(); // This shouldn't be necessary but HTTP2 isn't supported by Cypress so streaming doesn't work
cy.get(".invitee").should("contain.text", "Max");
cy.task('updateSocial')
cy.reload() // This shouldn't be necessary but HTTP2 isn't supported by Cypress so streaming doesn't work
cy.get('.invitee').should('contain.text', 'Max')

cy.wait(1000); // Fix weird re-render that changes date format and resets checked state
cy.get('#best-dates [type="radio"]').first().check();
cy.contains("button", "NEXT").click();
cy.wait(1000) // Fix weird re-render that changes date format and resets checked state
cy.get('#best-dates [type="radio"]').first().check()
cy.contains('button', 'NEXT').click()

cy.url().should("include", "/decision");
cy.contains("Your social is on");
});
cy.url().should('include', '/decision')
cy.contains('Your social is on')
})
34 changes: 17 additions & 17 deletions cypress/plugins/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

require("dotenv").config();
require('dotenv').config()

/**
* @type {Cypress.PluginConfig}
Expand All @@ -23,44 +23,44 @@ require("dotenv").config();
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
const faunadb = require("faunadb");
const faunadb = require('faunadb')

console.log({
domain: process.env.FAUNADB_DOMAIN,
port: process.env.FAUNADB_PORT,
scheme: process.env.FAUNADB_SCHEME,
secret: process.env.FAUNADB_SERVER_SECRET,
});
})

const q = faunadb.query;
const q = faunadb.query
const client = new faunadb.Client({
domain: process.env.FAUNADB_DOMAIN,
port: process.env.FAUNADB_PORT,
scheme: process.env.FAUNADB_SCHEME,
secret: process.env.FAUNADB_SERVER_SECRET,
});
})

on("task", {
on('task', {
async updateSocial(data) {
// Not figured out how to pass fauna expressions like q.Date to task yet so hard-coding an update for now.
const allDocuments = await client.query(
q.Max(q.Paginate(q.Documents(q.Collection("social"))))
);
const socialUnderTestId = allDocuments.data[0].id;
q.Max(q.Paginate(q.Documents(q.Collection('social')))),
)
const socialUnderTestId = allDocuments.data[0].id

const response = await client.query(
q.Update(q.Ref(q.Collection("social"), socialUnderTestId), {
q.Update(q.Ref(q.Collection('social'), socialUnderTestId), {
data: {
invitees: {
fakeId: {
name: "Max",
dates: [q.Date(new Date().toISOString().split("T")[0])],
name: 'Max',
dates: [q.Date(new Date().toISOString().split('T')[0])],
},
},
},
})
);
return response;
}),
)
return response
},
});
};
})
}
96 changes: 36 additions & 60 deletions db/createSocial.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,50 @@
import faunadb from 'faunadb'
import { toSocialId } from '../src/lib/id.js'
import {toSocialId} from '../src/lib/id.js'

const q = faunadb.query

const client = new faunadb.Client({
domain: process.env.FAUNADB_DOMAIN,
port: process.env.FAUNADB_PORT,
scheme: process.env.FAUNADB_SCHEME,
secret: process.env.FAUNADB_SERVER_SECRET,
domain: process.env.FAUNADB_DOMAIN,
port: process.env.FAUNADB_PORT,
scheme: process.env.FAUNADB_SCHEME,
secret: process.env.FAUNADB_SERVER_SECRET,
})

function todayPlus(days) {
return q.TimeAdd(q.ToDate(q.Now()), days, "days")
return q.TimeAdd(q.ToDate(q.Now()), days, 'days')
}

const response = await client.query(
q.Create(
q.Collection('social'),
{
data: {
invitees: {
"cbc9de47-185b-4115-a2a5-e4e8dbe6e249": {
name: "Dan",
dates: [
todayPlus(1),
todayPlus(5),
todayPlus(6),
]
},
"d742dc09-c309-4f2c-9b33-c817b51c1537": {
name: "Max",
dates: [
todayPlus(2),
todayPlus(6),
]
},
"5c15e5ec-3a5c-4518-9224-591635a38bb8": {
name: "Tom",
dates: [
todayPlus(8),
todayPlus(6),
todayPlus(10),
]
},
"9d5c15e5-ec3a-4c35-98d2-24591635a38b": {
name: "King Daddy Sexy Robo III",
dates: [
todayPlus(1),
todayPlus(6),
]
},
"6bb56257-f312-484f-ac7b-458bcaa76b5f": {
name: "Jim",
dates: [
todayPlus(5),
todayPlus(6),
]
},
"fe9d5c15-e5ec-4a5c-b518-d224591635a3": {
name: "Mike",
dates: [
todayPlus(15),
todayPlus(3),
todayPlus(6),
]
}
}
}
}
)
q.Create(q.Collection('social'), {
data: {
invitees: {
'cbc9de47-185b-4115-a2a5-e4e8dbe6e249': {
name: 'Dan',
dates: [todayPlus(1), todayPlus(5), todayPlus(6)],
},
'd742dc09-c309-4f2c-9b33-c817b51c1537': {
name: 'Max',
dates: [todayPlus(2), todayPlus(6)],
},
'5c15e5ec-3a5c-4518-9224-591635a38bb8': {
name: 'Tom',
dates: [todayPlus(8), todayPlus(6), todayPlus(10)],
},
'9d5c15e5-ec3a-4c35-98d2-24591635a38b': {
name: 'King Daddy Sexy Robo III',
dates: [todayPlus(1), todayPlus(6)],
},
'6bb56257-f312-484f-ac7b-458bcaa76b5f': {
name: 'Jim',
dates: [todayPlus(5), todayPlus(6)],
},
'fe9d5c15-e5ec-4a5c-b518-d224591635a3': {
name: 'Mike',
dates: [todayPlus(15), todayPlus(3), todayPlus(6)],
},
},
},
}),
)
const socialId = toSocialId(response.ref.id)
console.info(`http://localhost:6602/${socialId}/everyone`)
44 changes: 22 additions & 22 deletions db/social.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[
{
"invitees": {
"cbc9de47-185b-4115-a2a5-e4e8dbe6e249": {
"name": "Dan"
},
"d742dc09-c309-4f2c-9b33-c817b51c1537": {
"name": "Max"
},
"5c15e5ec-3a5c-4518-9224-591635a38bb8": {
"name": "Tom"
},
"9d5c15e5-ec3a-4c35-98d2-24591635a38b": {
"name": "King Daddy Sexy Robo III"
},
"6bb56257-f312-484f-ac7b-458bcaa76b5f": {
"name": "Jim"
},
"fe9d5c15-e5ec-4a5c-b518-d224591635a3": {
"name": "Mike"
}
}
}
{
"invitees": {
"cbc9de47-185b-4115-a2a5-e4e8dbe6e249": {
"name": "Dan"
},
"d742dc09-c309-4f2c-9b33-c817b51c1537": {
"name": "Max"
},
"5c15e5ec-3a5c-4518-9224-591635a38bb8": {
"name": "Tom"
},
"9d5c15e5-ec3a-4c35-98d2-24591635a38b": {
"name": "King Daddy Sexy Robo III"
},
"6bb56257-f312-484f-ac7b-458bcaa76b5f": {
"name": "Jim"
},
"fe9d5c15-e5ec-4a5c-b518-d224591635a3": {
"name": "Mike"
}
}
}
]
39 changes: 22 additions & 17 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="description"
content="Trying to find a date when friends are free can be a painful process, especially over text. We save you time by collecting everyone's availability and presenting you with the best dates with a minimum of fuss."
/>
<link rel="icon" href="/favicon.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@400;700&family=Port+Lligat+Slab&display=swap"
rel="stylesheet"
/>
%svelte.head%
</head>

<head>
<meta charset="utf-8" />
<meta name="description"
content="Trying to find a date when friends are free can be a painful process, especially over text. We save you time by collecting everyone's availability and presenting you with the best dates with a minimum of fuss.">
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@400;700&family=Port+Lligat+Slab&display=swap"
rel="stylesheet" />
%svelte.head%
</head>

<body>
<div id="svelte">%svelte.body%</div>
</body>

<body>
<div id="svelte">%svelte.body%</div>
</body>
</html>
Loading

0 comments on commit 20a2a9a

Please sign in to comment.