From 5b9fe729b7fb2060587e0d26d04eba53194c7a0c Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:23:31 -0700 Subject: [PATCH 1/7] add lint check --- .github/workflows/lint-on-pr.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/lint-on-pr.yml diff --git a/.github/workflows/lint-on-pr.yml b/.github/workflows/lint-on-pr.yml new file mode 100644 index 0000000..2655dfc --- /dev/null +++ b/.github/workflows/lint-on-pr.yml @@ -0,0 +1,32 @@ +name: 'Lint Check' + +on: + pull_request: + branches: [ next ] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.10' + + - name: Cache Node.js modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node- + ${{ runner.OS }}- + + - name: Install Dependencies + run: npm ci + + - name: Run Linter + run: npm run lint From 52c40f9474cc94fa19b9ab60abadd4e5337ecf3e Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:25:48 -0700 Subject: [PATCH 2/7] fail lint --- .github/workflows/lint-on-pr.yml | 2 +- src/app/layout.tsx | 40 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/lint-on-pr.yml b/.github/workflows/lint-on-pr.yml index 2655dfc..4178f10 100644 --- a/.github/workflows/lint-on-pr.yml +++ b/.github/workflows/lint-on-pr.yml @@ -5,7 +5,7 @@ on: branches: [ next ] jobs: - lint: + lint-job: runs-on: ubuntu-latest steps: diff --git a/src/app/layout.tsx b/src/app/layout.tsx index c5f0e1e..5c2ea6b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,12 +1,12 @@ import './globals.css' -import type { Metadata } from 'next' -import { Anton, Courier_Prime, Montserrat } from 'next/font/google' -import { ReactNode, Suspense } from 'react' +import type {Metadata} from 'next' +import {Anton, Courier_Prime, Montserrat} from 'next/font/google' +import {ReactNode, Suspense} from 'react' import {PHProvider, PostHogPageview} from '~/app/providers' -import { meta, Prices } from '~/lib/constants' +import {meta, Prices} from '~/lib/constants' -import { cx } from '../../styled-system/css' +import {cx} from '../../styled-system/css' const montserrat = Montserrat({ subsets: ['latin'], @@ -25,9 +25,9 @@ const courier = Courier_Prime({ weight: '400', }) -export async function generateMetadata (): Promise { +export async function generateMetadata(): Promise { // fetch data - const today: Prices = await fetch(`${ getBaseUrl() }/api/report/now`).then((res) => res.json()) + const today: Prices = await fetch(`${getBaseUrl()}/api/report/now`).then((res) => res.json()) return { title: meta.title, @@ -42,31 +42,31 @@ export async function generateMetadata (): Promise { url: meta.url, type: 'website', siteName: meta.title, - images: [`${ getBaseUrl() }/api/og?price=${ today.banxico.buy }`], + images: [`${getBaseUrl()}/api/og?price=${today.banxico.buy}`], }, } satisfies Metadata } -export default function RootLayout ({ - children, -}: { +export default function RootLayout({ + children, + }: { children: ReactNode }) { return ( - - - - - - {children} - - + + + + + + {children} + + ) } -function getBaseUrl () { +function getBaseUrl() { if (process.env.NODE_ENV === 'development') { return 'http://localhost:3000' } else { From 3ae2d4623f525b70fcc095125b9e776b212e4c36 Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:27:05 -0700 Subject: [PATCH 3/7] fix lint errors --- src/app/layout.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 5c2ea6b..1e75342 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -25,7 +25,7 @@ const courier = Courier_Prime({ weight: '400', }) -export async function generateMetadata(): Promise { +export async function generateMetadata (): Promise { // fetch data const today: Prices = await fetch(`${getBaseUrl()}/api/report/now`).then((res) => res.json()) @@ -47,26 +47,26 @@ export async function generateMetadata(): Promise { } satisfies Metadata } -export default function RootLayout({ - children, - }: { +export default function RootLayout ({ + children, +}: { children: ReactNode }) { return ( - - - - - - {children} - - + + + + + + {children} + + ) } -function getBaseUrl() { +function getBaseUrl () { if (process.env.NODE_ENV === 'development') { return 'http://localhost:3000' } else { From ede1dc2829455aed580fa1ac107e1055871527ed Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:29:53 -0700 Subject: [PATCH 4/7] add husky --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index a67f5cb..ed55ab1 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,10 @@ }, "prisma": { "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" + }, + "husky": { + "hooks": { + "pre-commit": "npm run lint" + } } } From ec1ae4e52cbc54bb819d14f0edcb9976f7eb11a5 Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:30:17 -0700 Subject: [PATCH 5/7] husky should trigger --- src/app/providers.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/providers.tsx b/src/app/providers.tsx index c02f819..b382661 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -11,7 +11,7 @@ if (typeof window !== 'undefined') { }) } -export function PostHogPageview (): JSX.Element { +export function PostHogPageview(): JSX.Element { const pathname = usePathname() const searchParams = useSearchParams() @@ -30,9 +30,9 @@ export function PostHogPageview (): JSX.Element { return <> } -export function PHProvider ({ - children, -}: { +export function PHProvider({ + children, + }: { children: React.ReactNode }) { return {children} From dc82bd236cdd9585cbd4b2986448aeda8955ee0b Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:32:14 -0700 Subject: [PATCH 6/7] husky pre-commit now running --- package-lock.json | 4 ++-- package.json | 9 ++------- src/app/providers.tsx | 8 ++++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index efd7856..df16a68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dolarenbancos", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dolarenbancos", - "version": "0.1.2", + "version": "0.1.3", "dependencies": { "@logtail/next": "^0.1.4", "@prisma/client": "^5.7.1", diff --git a/package.json b/package.json index ed55ab1..050a1d4 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "dolarenbancos", - "version": "0.1.2", + "version": "0.1.3", "private": true, "scripts": { - "prepare": "panda codegen", + "prepare": "panda codegen && husky install", "dev": "rm -rf .next && next dev", "build": "next build", "start": "next start", @@ -39,10 +39,5 @@ }, "prisma": { "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" - }, - "husky": { - "hooks": { - "pre-commit": "npm run lint" - } } } diff --git a/src/app/providers.tsx b/src/app/providers.tsx index b382661..c02f819 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -11,7 +11,7 @@ if (typeof window !== 'undefined') { }) } -export function PostHogPageview(): JSX.Element { +export function PostHogPageview (): JSX.Element { const pathname = usePathname() const searchParams = useSearchParams() @@ -30,9 +30,9 @@ export function PostHogPageview(): JSX.Element { return <> } -export function PHProvider({ - children, - }: { +export function PHProvider ({ + children, +}: { children: React.ReactNode }) { return {children} From a5f739578bb36b64fa416388b0de9e321524ff5b Mon Sep 17 00:00:00 2001 From: Jose Salcido Date: Wed, 27 Dec 2023 19:35:37 -0700 Subject: [PATCH 7/7] update README.md --- README.md | 23 ++++++++++++++++++++--- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2239ee9..7a3d0be 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,19 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). +# Dolar En Bancos + +## Pre-requisites + +- [Doppler (for secrets management)](https://doppler.com/) +- [Node.js](https://nodejs.org/en/) **v20.10** ## Getting Started -First, run the development server: +First, prepare environment running: + +```bash +npm run prepare +``` + +Then run the development server: ```bash npm run dev @@ -12,4 +23,10 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. -This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. +This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and +load Inter, a custom Google Font. + +## Environment Variables + +We use Doppler to manage secrets. Please request access and run the project with `doppler run -- npm` or +add your own token. diff --git a/package-lock.json b/package-lock.json index df16a68..048d3e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dolarenbancos", - "version": "0.1.3", + "version": "0.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dolarenbancos", - "version": "0.1.3", + "version": "0.1.4", "dependencies": { "@logtail/next": "^0.1.4", "@prisma/client": "^5.7.1", diff --git a/package.json b/package.json index 050a1d4..23cdbf4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dolarenbancos", - "version": "0.1.3", + "version": "0.1.4", "private": true, "scripts": { "prepare": "panda codegen && husky install",