-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
210 changed files
with
5,311 additions
and
14,859 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build DBDev | ||
on: | ||
workflow_call: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- name: Cache dbdev | ||
id: cache-dbdev | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cargo/bin/dbdev | ||
key: ${{ runner.os }}-dbdev | ||
|
||
- name: Install dbdev | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: install | ||
args: --git https://github.com/supabase/dbdev.git dbdev --force | ||
if: steps.cache-dbdev.outputs.cache-hit != 'true' | ||
- name: Create build-output artifact | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: dbdev-output | ||
path: ~/.cargo/bin/dbdev |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,105 @@ | ||
name: Jest Tests and Linting | ||
name: Tests | ||
on: | ||
pull_request: | ||
branches: [ main ] | ||
jobs: | ||
build: | ||
dbdev: | ||
uses: ./.github/workflows/dbdev.yml | ||
pg_tap_tests: | ||
name: PGTap Tests | ||
runs-on: ubuntu-latest | ||
needs: dbdev | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install modules | ||
run: yarn install --frozen-lockfile | ||
- name: Next Linting | ||
run: yarn lint | ||
- name: Run tests | ||
run: yarn test | ||
- name: Download DBDev | ||
uses: actions/download-artifact@master | ||
with: | ||
name: dbdev-output | ||
path: ~/.cargo/bin | ||
- name: Make dbdev executable | ||
run: chmod +x ~/.cargo/bin/dbdev | ||
- uses: actions/checkout@v3 | ||
- uses: supabase/setup-cli@v1 | ||
with: | ||
version: latest | ||
- name: Supabase Start | ||
run: supabase init && supabase start | ||
- name: Install supabase_test_helpers from scripts/install-dbdev-with-test-helpers.sql (remove this once remote install enabled in dbdev CLI) | ||
run: psql -v ON_ERROR_STOP=1 -U postgres -d postgres -h localhost -p 54322 -f ./scripts/install-dbdev-with-test-helpers.sql | ||
env: | ||
PGPASSWORD: postgres | ||
- name: Install core extension using dbdev cli | ||
run: | | ||
~/.cargo/bin/dbdev install --connection postgres://postgres:postgres@localhost:54322/postgres --path . | ||
psql -v ON_ERROR_STOP=1 -U postgres -d postgres -h localhost -p 54322 -c 'CREATE EXTENSION IF NOT EXISTS basejump_core with schema extensions;' | ||
env: | ||
PGPASSWORD: postgres | ||
- name: Run Tests | ||
run: supabase test db | ||
stripe_tests: | ||
name: Stripe Tests | ||
runs-on: ubuntu-latest | ||
needs: dbdev | ||
steps: | ||
- name: Download DBDev | ||
uses: actions/download-artifact@master | ||
with: | ||
name: dbdev-output | ||
path: ~/.cargo/bin | ||
- name: Make dbdev executable | ||
run: chmod +x ~/.cargo/bin/dbdev | ||
- uses: actions/checkout@v3 | ||
- uses: supabase/setup-cli@v1 | ||
with: | ||
version: latest | ||
- name: Install stripe | ||
run: | | ||
# Download linux version as per Stripe documentation | ||
curl -L https://github.com/stripe/stripe-cli/releases/download/v1.18.0/stripe_1.18.0_linux_x86_64.tar.gz --output stripe.tar.gz | ||
# Unzip | ||
tar -xvf stripe.tar.gz | ||
- name: Create supabase/functions/.env including stripe webhook secrets | ||
run: | | ||
echo "STRIPE_WEBHOOK_SIGNING_SECRET=$(./stripe listen --print-secret)" >> supabase/functions/.env | ||
echo "STRIPE_API_KEY=${{ secrets.STRIPE_API_KEY }}" >> supabase/functions/.env | ||
echo "STRIPE_DEFAULT_PLAN_ID=${{ secrets.STRIPE_DEFAULT_PLAN_ID }}" >> supabase/functions/.env | ||
echo "STRIPE_DEFAULT_TRIAL_DAYS=7" >> supabase/functions/.env | ||
env: | ||
STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} | ||
STRIPE_DEFAULT_PLAN_ID: ${{ secrets.STRIPE_DEFAULT_PLAN_ID }} | ||
- name: Setup and start Supabase | ||
run: | | ||
supabase init | ||
echo -e "\n\n[functions.test-stripe-billing-webhooks]\nverify_jwt = false" >> supabase/config.toml | ||
supabase start | ||
- name: Install supabase_test_helpers from scripts/install-dbdev-with-test-helpers.sql (remove this once remote install enabled in dbdev CLI) | ||
run: psql -v ON_ERROR_STOP=1 -U postgres -d postgres -h localhost -p 54322 -f ./scripts/install-dbdev-with-test-helpers.sql | ||
env: | ||
PGPASSWORD: postgres | ||
- name: Install core extension using dbdev cli | ||
run: | | ||
~/.cargo/bin/dbdev install --connection postgres://postgres:postgres@localhost:54322/postgres --path . | ||
psql -v ON_ERROR_STOP=1 -U postgres -d postgres -h localhost -p 54322 -c 'CREATE EXTENSION IF NOT EXISTS basejump_core with schema extensions;' | ||
env: | ||
PGPASSWORD: postgres | ||
- name: Yarn install supabase/tests/integration | ||
run: cd supabase/tests/integration && yarn --frozen-lockfile | ||
- name: Install playwright browsers | ||
run: cd supabase/tests/integration && yarn test:setup | ||
- name: Run tests without webhooks | ||
run: cd supabase/tests/integration && yarn test:invalid && yarn test:stripe-no-webhooks | ||
env: | ||
SUPABASE_URL: http://127.0.0.1:54321 | ||
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | ||
STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} | ||
STRIPE_DEFAULT_PLAN_ID: ${{ secrets.STRIPE_DEFAULT_PLAN_ID }} | ||
STRIPE_DEFAULT_TRIAL_DAYS: 7 | ||
- name: Run tests with webhooks | ||
run: | | ||
./stripe listen --api-key ${{ secrets.STRIPE_API_KEY }} --forward-to http://127.0.0.1:54321/functions/v1/test-stripe-billing-webhooks & | ||
cd supabase/tests/integration && yarn test:stripe-webhooks | ||
env: | ||
SUPABASE_URL: http://127.0.0.1:54321 | ||
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | ||
STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} | ||
STRIPE_DEFAULT_PLAN_ID: ${{ secrets.STRIPE_DEFAULT_PLAN_ID }} | ||
STRIPE_DEFAULT_TRIAL_DAYS: 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,70 @@ | ||
# Basejump SaaS starter for Supabase | ||
# Basejump | ||
|
||
Basejump is an open source starter for Supabase. It provides personal accounts, shared team accounts, billing | ||
subscriptions with Stripe and a dashboard template. | ||
> If you're looking for the original Basejump which included a NextJS SaaS starter | ||
> template, [check out the legacy repo](https://github.com/usebasejump/legacy-basejump-template). | ||
Basejump adds personal accounts, team accounts, permissions and billing support to Supabase Auth. | ||
|
||
[Learn more at usebasejump.com](https://usebasejump.com). | ||
|
||
## Installation | ||
## Features | ||
|
||
```bash | ||
yarn | ||
yarn dev | ||
``` | ||
- **Personal accounts**: Every user that signs up using Supabase auth automatically gets their own personal account. | ||
Billing on personal accounts can be enabled/disabled. | ||
- **Team accounts**: Team accounts are billable accounts that can be shared by multiple users. Team accounts can be | ||
disabled if you only wish to allow personal accounts. Billing on team accounts can also be disabled. | ||
- **Permissions**: Permissions are handled using RLS, just like you're used to with Supabase. Basejump provides | ||
convenience methods that let you restrict access to rows based on a user's account access and role within an account | ||
- **Billing**: Basejump provides out of the box billing support for Stripe, but you can add your own providers easily. | ||
If you do, please consider contributing them so others can benefit! | ||
- **Testing**: Basejump is fully tested itself, but also provides a suite of testing tools that make it easier to test | ||
your own Supabase functions and schema. You can check it out | ||
at [database.dev/basejump/supabase_test_helpers](https://database.dev/basejump/supabase_test_helpers). You do not need | ||
to be using Basejump to use the testing tools. | ||
|
||
## Typescript and generated types | ||
## Quick Start (recommended) | ||
|
||
We've implemented automatic type generation based off of your Supabase database config. You can learn more about this | ||
setup [in the supabase docs on type generation](https://supabase.com/docs/guides/api/generating-types) | ||
Check out the getting started guide at [usebasejump.com](https://usebasejump.com). | ||
|
||
To update your types, run: | ||
## Contributing | ||
|
||
Yes please! Here's how you can get started locally | ||
|
||
#### Initialize Supabase | ||
|
||
```bash | ||
yarn generate-types | ||
supabase init && supabase start | ||
``` | ||
|
||
You can then reference them as | ||
#### Install dependencies using dbdev | ||
|
||
```javascript | ||
import Database from '@/types/supabase-types'; | ||
1. Install dbdev according to instructions on [database.dev](https://database.dev). | ||
2. Install supabase_test_helpers | ||
|
||
const profile: Database['public']['Tables']['profiles']['Row'] = {name: 'John Doe'}; | ||
```sql | ||
select dbdev.install('basejump-supabase_test_helpers'); | ||
``` | ||
|
||
## Code Formatting and linting | ||
|
||
The project is configured to use ESLint and Prettier. Prettier is run through ESLint, not on its own. | ||
#### Install local version of basejump_core | ||
|
||
* Prettier: [Prettier ESLint Plugin](https://github.com/prettier/eslint-plugin-prettier) | ||
* ESLint: [NextJS ESLint](https://nextjs.org/docs/basic-features/eslint) | ||
```bash | ||
dbdev install --connection postgres://postgres:postgres@localhost:54322/postgres --path . | ||
``` | ||
|
||
## Internationalizatoin and translations | ||
#### Enable basejump_core | ||
|
||
Basejump uses NextJS built in internationalization, and adds `next-translate` for translation support. | ||
```sql | ||
CREATE EXTENSION IF NOT EXISTS basejump_core with schema extensions; | ||
``` | ||
|
||
* [NextJS Internationalization](https://nextjs.org/docs/basic-features/i18n) | ||
* [next-translate](https://github.com/aralroca/next-translate) | ||
#### Make sure tests can run | ||
|
||
## Thanks & Credits | ||
```bash | ||
supabase test db | ||
``` | ||
|
||
<p>Hosting has generously been provided by Vercel</p> | ||
<a | ||
href="https://vercel.com?utm_source=basejump&utm_campaign=oss" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<img src="public/images/vercel-logo.svg" alt="Powered by Vercel" /> | ||
</a> | ||
### Add your changes and write tests. | ||
|
||
Make sure you're following the database.dev upgrade guidelines. you should NEVER be updating/changing existing version | ||
files. All changes should have valid migration files for postgres extensions. I'll try to flesh this section out more | ||
later. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.