This is a quick guide to get the project up and running for local development.
Ensure you have the following installed:
Clone this repository
git clone https://github.com/RVRENTPRO/rv-rent-pro-application rv-rent-pro-application
Move to the folder just cloned:
cd rv-rent-pro-application
Set this repository as your upstream fork, so you can pull updates when needed:
git remote add upstream https://github.com/RVRENTPRO/rv-rent-pro-application
To pull the latest updates, use:
git pull upstream main
Please, always pull the latest updates and resolve the differences locally before pushing changes to avoid merge conflicts.
Install the Node modules with one of the two following commands:
npm i
or
yarn install
Start by running the Supabase stack:
npm run supabase:start
or
yarn supabase:start
Remember: This does not connect to our remote Supabase project, but a local instance using Docker. This is useful for development and testing.
The tests include some operations that like deleting an accepting team invites that would be a hassle to re-prepare. This is avoided by having a local seed.sql final we can instead use as a reset point.
Please do not push database migrations to our remote instance without explicit permission.
Recommendation: Please set up the local instance first before attempting to pulldown the production instance, so that you can test our application locally and familiarise yourself first.
The seed.sql file will not always be up-to-date, but will always be sufficient for dev purposes as Cypress checks the web components before depoloyment.
For devolpment purposes we add Supabase test keys to the environment variables, so we can run Supabase locally without complication.
When you start Supabase for the first time, you will see a message like this:
> supabase start
Applying migration 20240718065238_remote_schema.sql...
Seeding data supabase/seed.sql...
Started supabase local development setup.
API URL: http://127.0.0.1:54321
GraphQL URL: http://127.0.0.1:54321/graphql/v1
S3 Storage URL: http://127.0.0.1:54321/storage/v1/s3
DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
Studio URL: http://127.0.0.1:54323
Inbucket URL: http://127.0.0.1:54324
JWT secret: super-secret-jwt-token-with-at-least-32-characters-long
JWT secret: super-secret-jwt-token-with-at-least-32-characters-long
anon key: ****************************************************
service_role key: ****************************************************
Only if the values above are different than the ones already setup in .env. development
and .env.test
, we need to copy the anon key
and
service_role key
values and add them to the .env.local
file:
NEXT_PUBLIC_SUPABASE_ANON_KEY=****************************************************
SUPABASE_SERVICE_ROLE_KEY=****************************************************
We have already setup some default database types for TypeScript.
If add/update new tables or columns to our database, you will want to generate new types, you can do so with the following command:
npm run typegen
This should be ran after any addition or update to the tables.
After you have Supbase running locally, then you can run the Next.js development server using any of the commands below:
npm run dev
or
yarn dev
or
pnpm dev
If you're testing Stripe, then you'll also need to run the Stripe server (requires Docker running):
npm run stripe:listen
or
yarn stripe:listen
Then, copy the printed webhook key and add it to our environment files if it's not there. This webhook key can also be used for running the Cypress E2E tests.
The environment variable name is STRIPE_WEBHOOK_SECRET
.
STRIPE_WEBHOOK_SECRET=whsec_***********************
You should now be able to sign in. To quickly get started, use the following credentials:
email = testing@rvrentpro.com
password = testonly
When signing up, Supabase sends an email confirmation to the testing account. Locally, the email wouldn't actually be sent. Instead, you can access the InBucket testing emails using the following link, and can click the link to complete the sign up process.
To customize the testing environment, add the required environment variables to
our .env.test
file.
You'll also want to update the Secrets and Variables in Github because they are used in the YAML we leverage for testing the commits.
...
...