Skip to content

Commit

Permalink
Merge branch 'main' into remove-hasPaid
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Apr 22, 2024
2 parents e4d75d7 + 2d94e28 commit 3303a92
Show file tree
Hide file tree
Showing 30 changed files with 5,204 additions and 5,066 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: e2e tests

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
WASP_TELEMETRY_DISABLE: 1
WASP_VERSION: 0.13.2

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Wasp
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v ${{ env.WASP_VERSION }}

- name: Docker setup
uses: docker/setup-buildx-action@v3

# In order for the app to run in the dev mode we need to set the required env vars even if they aren't actually used by the app.
# This step sets mock env vars in order to pass the validation steps so the app can run
# in the CI environment. For env vars that are actually used in tests and therefore need real values, we set them in
# the GitHub secrets settings and access them in a step below.
- name: Set required wasp app env vars to mock values
run: |
cd app
cp .env.server.example .env.server
- name: Cache global node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('app/package-lock.json') }}-${{ hashFiles('e2e-tests/package-lock.json') }}-wasp${{ env.WASP_VERSION }}-node${{ steps.setup-node.outputs.node-version }}
restore-keys: |
node-modules-${{ runner.os }}-
- name: Install Node.js dependencies for Playwright tests
if: steps.cache-e2e-tests.outputs.cache-hit != 'true'
run: |
cd e2e-tests
npm ci
- name: Store Playwright's Version
run: |
cd e2e-tests
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}-${{ runner.os }}

- name: Set up Playwright
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: |
cd e2e-tests
npx playwright install --with-deps
- name: Install Stripe CLI
run: |
curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg
echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
sudo apt update
sudo apt install stripe
# For Stripe webhooks to work in development, we need to run the Stripe CLI to listen for webhook events.
# The Stripe CLI will receive the webhook events from Stripe test payments and
# forward them to our local server so that we can test the payment flow in our e2e tests.
- name: Run Stripe CLI to listen for webhooks
env:
STRIPE_DEVICE_NAME: ${{ secrets.STRIPE_DEVICE_NAME }}
run: |
stripe listen --api-key ${{ secrets.STRIPE_KEY }} --forward-to localhost:3001/stripe-webhook &
- name: Run Playwright tests
env:
# The e2e tests are testing parts of the app that need certain env vars, so we need to access them here.
# These secretes can be set in your GitHub repo settings, e.g. https://github.com/<account>/<repo>/settings/secrets/actions
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
STRIPE_KEY: ${{ secrets.STRIPE_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
HOBBY_SUBSCRIPTION_PRICE_ID: ${{ secrets.HOBBY_SUBSCRIPTION_PRICE_ID }}
PRO_SUBSCRIPTION_PRICE_ID: ${{ secrets.PRO_SUBSCRIPTION_PRICE_ID }}
CREDITS_PRICE_ID: ${{ secrets.CREDITS_PRICE_ID }}
SKIP_EMAIL_VERIFICATION_IN_DEV: true
run: |
cd e2e-tests
npm run e2e:playwright
30 changes: 30 additions & 0 deletions .github/workflows/retag-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Retag Commit

on:
push:
branches:
- main

jobs:
retag:
runs-on: ubuntu-latest
env:
TAG_NAME: wasp-v0.13-template
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Configure Git
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Delete Old Tag
run: |
git tag -d ${{ env.TAG_NAME }} || true
git push origin :refs/tags/${{ env.TAG_NAME }} || true
- name: Add New Tag
run: |
git tag ${{ env.TAG_NAME }}
git push origin ${{ env.TAG_NAME }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*/.wasp/
*/.env.server
*/.env.client
*/.DS_Store
*/node_modules
*/migrations
*/.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Contributing is simple:
3. Create a new feature branch for your work. See [above](#the-default-template-vs-the-deployed-site--docs) for which branch to base your feature branch off of.
4. Create a pull request.
5. Make a "Da Boi" meme while you wait for us to review your PR.
6. If you don't know who "Da Boi" is, head back to the [Wasp Discord](https://discord.gg/aCamt5wCpS) and find out :)
6. If you don't know who "Da Boi" is, head back to the [Wasp Discord](https://discord.gg/aCamt5wCpS) and find out :)
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The template itself is built on top of some very powerful tools and frameworks,
- 📧 [SendGrid](https://sendgrid.com), [MailGun](https://mailgun.com), or SMTP - for email sending
- 💅 [TailwindCSS](https://tailwindcss.com) - for styling
- 🧑‍💼 [TailAdmin](https://tailadmin.com/) - admin dashboard & components for TailwindCSS
- 🧪 [Playwright](https://playwright.dev) - end-to-end tests with Playwright

Because we're using Wasp as the full-stack framework, we can leverage a lot of its features to build our SaaS in record time, including:

Expand Down Expand Up @@ -62,7 +63,17 @@ For everything you need to know about getting started and using this template, c

We've documented everything in great detail, including installation instructions, pulling updates to the template, guides for integrating services, SEO, deployment, and more. 🚀


## Changes & Contributions

### Template Versioning

Whenever a user starts a new Open SaaS project with `wasp new -t saas`, Wasp looks for a specific tag on the repo, and pulls the project at the commit associated with that tag. In the case of Open SaaS, the tag is `wasp-v{{version}}-template`, where `{{version}}` is the current version of Wasp, e.g. `wasp-v0.13-template`.

For simplicity, we automatically re-apply the tag to the most recent commit on the `main` branch via the `.github/workflows/retag-commit.yml` workflow. This way, users always get the latest version of the template when they start a new project via `wasp new -t saas`.d

### Contributing

Note that we've tried to get as many of the core features of a SaaS app into this template as possible, but there still might be some missing features or functionality.

We could always use some help tying up loose ends, so consider [contributing](https://github.com/wasp-lang/open-saas/blob/main/CONTRIBUTING.md)!
Expand Down
6 changes: 4 additions & 2 deletions app/.env.client.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# learn more about client side env vars https://wasp-lang.dev/docs/project/env-vars
REACT_APP_SOME_VAR_NAME=foo
# All client-side env vars must start with REACT_APP_ https://wasp-lang.dev/docs/project/env-vars

# Find your test url at https://dashboard.stripe.com/test/settings/billing/portal
REACT_APP_STRIPE_CUSTOMER_PORTAL=
4 changes: 2 additions & 2 deletions app/.env.server.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ GOOGLE_CLIENT_SECRET=GOC...

# get your sendgrid api key at https://app.sendgrid.com/settings/api_keys
SENDGRID_API_KEY=test...
# if not explicitly set to true, emails will be logged to console but not actually sent during development
SEND_EMAILS_IN_DEVELOPMENT=false
# Skips the email verification flow in development every time you sign up a new user.
SKIP_EMAIL_VERIFICATION_IN_DEV=true

# (OPTIONAL) get your openai api key at https://platform.openai.com/account
OPENAI_API_KEY=sk-k...
Expand Down
66 changes: 33 additions & 33 deletions app/main.wasp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app OpenSaaS {
wasp: {
version: "^0.13.0"
version: "^0.13.2"
},
title: "My Open SaaS App",
head: [
Expand All @@ -24,8 +24,20 @@ app OpenSaaS {
auth: {
userEntity: User,
methods: {
usernameAndPassword: { // !IMPORTANT: this method is only suitable for dev/testing. Use social or email methods in production.
userSignupFields: import { getUsernameAndPasswordUserFields } from "@src/server/auth/setUsername.js",
email: {
fromField: {
name: "Open SaaS App",
email: "[email protected]"
},
emailVerification: {
clientRoute: EmailVerificationRoute,
getEmailContentFn: import { getVerificationEmailContent } from "@src/server/auth/email.js",
},
passwordReset: {
clientRoute: PasswordResetRoute,
getEmailContentFn: import { getPasswordResetEmailContent } from "@src/server/auth/email.js",
},
userSignupFields: import { getEmailUserFields } from "@src/server/auth/setUsername.js",
},
// google: { // Guide for setting up Auth via Google https://wasp-lang.dev/docs/auth/social-auth/overview
// userSignupFields: import { getGoogleUserFields } from "@src/server/auth/setUsername.js",
Expand All @@ -35,22 +47,6 @@ app OpenSaaS {
// userSignupFields: import { getGitHubUserFields } from "@src/server/auth/setUsername.js",
// configFn: import { getGitHubAuthConfig } from "@src/server/auth/setUsername.js",
// },
// email: {
// fromField: {
// name: "Open SaaS App",
// // make sure this address is the same you registered your SendGrid or MailGun account with!
// email: "[email protected]"
// },
// emailVerification: {
// clientRoute: EmailVerificationRoute,
// getEmailContentFn: import { getVerificationEmailContent } from "@src/server/auth/email.js",
// },
// passwordReset: {
// clientRoute: PasswordResetRoute,
// getEmailContentFn: import { getPasswordResetEmailContent } from "@src/server/auth/email.js",
// },
// userSignupFields: import { getEmailUserFields } from "@src/server/auth/setUsername.js",
// },
},
onAuthFailedRedirectTo: "/login",
onAuthSucceededRedirectTo: "/demo-app",
Expand All @@ -64,11 +60,15 @@ app OpenSaaS {
client: {
rootComponent: import App from "@src/client/App",
},

emailSender: {
provider: SendGrid,
// Note that the "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the confirmation email token (it will not be sent to an address)!
// Please use SendGrid in production. See: https://docs.opensaas.sh/guides/email-sending/
provider: Dummy,
defaultFrom: {
name: "Open SaaS App",
// make sure this address is the same you registered your SendGrid or MailGun account with!
// When using SendGrid, you must use the same email address that you configured your account to send out emails with!
email: "[email protected]"
},
},
Expand Down Expand Up @@ -189,20 +189,20 @@ page SignupPage {
component: import { Signup } from "@src/client/auth/SignupPage"
}

// route RequestPasswordResetRoute { path: "/request-password-reset", to: RequestPasswordResetPage }
// page RequestPasswordResetPage {
// component: import { RequestPasswordReset } from "@src/client/auth/RequestPasswordReset",
// }
route RequestPasswordResetRoute { path: "/request-password-reset", to: RequestPasswordResetPage }
page RequestPasswordResetPage {
component: import { RequestPasswordReset } from "@src/client/auth/RequestPasswordReset",
}

// route PasswordResetRoute { path: "/password-reset", to: PasswordResetPage }
// page PasswordResetPage {
// component: import { PasswordReset } from "@src/client/auth/PasswordReset",
// }
route PasswordResetRoute { path: "/password-reset", to: PasswordResetPage }
page PasswordResetPage {
component: import { PasswordReset } from "@src/client/auth/PasswordReset",
}

// route EmailVerificationRoute { path: "/email-verification", to: EmailVerificationPage }
// page EmailVerificationPage {
// component: import { EmailVerification } from "@src/client/auth/EmailVerification",
// }
route EmailVerificationRoute { path: "/email-verification", to: EmailVerificationPage }
page EmailVerificationPage {
component: import { EmailVerification } from "@src/client/auth/EmailVerification",
}

route DemoAppRoute { path: "/demo-app", to: DemoAppPage }
page DemoAppPage {
Expand Down
Loading

0 comments on commit 3303a92

Please sign in to comment.