Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Mar 29, 2024
0 parents commit d58e1d9
Show file tree
Hide file tree
Showing 129 changed files with 5,202 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# FIXME: Configure environment variables for your project

# For security reason, don't push secret key in your git repo.
# Append .local to the environement files to prevent your secret key from being commited to Git.

# Database
# Please use a working DATABASE_URL. Otherwise, Next.js build will timeout and you will get the following error: "because it took more than 60 seconds"
# DATABASE_URL=libsql://[RANDOM-CHARS]-[DB-NAME]-[ORG-NAME].turso.io
DATABASE_URL=file:next-js-boilerplate.db

# Clerk authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_cG9ldGljLXlhay0zMi5jbGVyay5hY2NvdW50cy5kZXYk

NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in

# Stripe
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51Ilz7WEK74ldPEzAEv0ob3pQuxSEvPp8pWNOsBXtU1MFdxchmlmIvpjiJxJfTELoViteODEmAwNwOoktE3FCMRDl00nTXobyBe

######## [BEGIN] SENSITIVE DATA ######## For security reason, don't update the following variables (secret key) directly in this file.
######## Please create a new file named `.env.local`, all environment files ending with `.local` won't be tracked by Git.
######## After creating the file, you can add the following variables.
CLERK_SECRET_KEY=your_clerk_secret_key

# DATABASE_AUTH_TOKEN=

# LOGTAIL_SOURCE_TOKEN=

STRIPE_SECRET_KEY=your_stripe_secret_key

STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
######## [END] SENSITIVE DATA
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
out
!.storybook
107 changes: 107 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
// Configuration for JavaScript files
"extends": [
"airbnb-base",
"next/core-web-vitals", // Needed to avoid warning in next.js build: 'The Next.js plugin was not detected in your ESLint configuration'
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"endOfLine": "auto"
}
] // Avoid conflict rule between Prettier and Airbnb Eslint
},
"settings": {
"tailwindcss": {
"callees": ["classnames", "clsx", "ctl", "cva", "tv", "cn"]
}
},
"overrides": [
// Configuration for TypeScript files
{
"files": ["**/*.ts", "**/*.tsx"],
"plugins": [
"@typescript-eslint",
"unused-imports",
"tailwindcss",
"simple-import-sort"
],
"extends": [
"plugin:tailwindcss/recommended",
"airbnb",
"airbnb-typescript",
"next/core-web-vitals",
"plugin:prettier/recommended"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"endOfLine": "auto"
}
], // Avoid conflict rule between Prettier and Airbnb Eslint
"import/extensions": "off", // Avoid missing file extension errors, TypeScript already provides a similar feature
"react/function-component-definition": "off", // Disable Airbnb's specific function type
"react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
"react/require-default-props": "off", // Allow non-defined react props as undefined
"react/jsx-props-no-spreading": "off", // _app.tsx uses spread operator and also, react-hook-form
"jsx-a11y/aria-role": "off", // Remove false positive errors with role attribute in Clerk components
"react/no-unstable-nested-components": "off", // Needed by i18n library
"@typescript-eslint/comma-dangle": "off", // Avoid conflict rule between Eslint and Prettier
"@typescript-eslint/consistent-type-imports": "error", // Ensure `import type` is used when it's necessary
"no-restricted-syntax": [
"error",
"ForInStatement",
"LabeledStatement",
"WithStatement"
], // Overrides Airbnb configuration and enable no-restricted-syntax
"import/prefer-default-export": "off", // Named export is easier to refactor automatically
"simple-import-sort/imports": "error", // Import configuration for `eslint-plugin-simple-import-sort`
"simple-import-sort/exports": "error", // Export configuration for `eslint-plugin-simple-import-sort`
"import/order": "off", // Avoid conflict rule between `eslint-plugin-import` and `eslint-plugin-simple-import-sort`
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
]
}
},
// Configuration for testing
{
"files": ["**/*.test.ts", "**/*.test.tsx"],
"plugins": ["jest", "jest-formatting", "testing-library", "jest-dom"],
"extends": [
"plugin:jest/recommended",
"plugin:jest-formatting/recommended",
"plugin:testing-library/react",
"plugin:jest-dom/recommended"
]
},
// Configuration for e2e testing (Playwright)
{
"files": ["**/*.spec.ts"],
"extends": ["plugin:playwright/recommended"]
},
// Configuration for Storybook
{
"files": ["*.stories.*"],
"extends": ["plugin:storybook/recommended"],
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
}
}
]
}
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: ixartz
custom:
["https://donate.stripe.com/7sI5m5146ehfddm7tj", "https://nextlessjs.com"]
88 changes: 88 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
strategy:
matrix:
node-version: [18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

name: Build with ${{ matrix.node-version }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run build

test:
strategy:
matrix:
node-version: [20.x]

name: Run all tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Retrieve Git history, needed to verify commits
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci

- name: Set SENTRY_AUTH_TOKEN env if secret exists
run: |
if [[ -n "${{ secrets.SENTRY_AUTH_TOKEN }}" ]]; then
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> $GITHUB_ENV
fi
- name: Build Next.js for E2E tests
run: npm run build

- if: github.event_name == 'pull_request'
name: Validate all commits from PR
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Linter
run: npm run lint

- name: Type checking
run: npm run check-types

- name: Run unit tests
run: npm run test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Install Playwright (used for Storybook and E2E tests)
run: npx playwright install --with-deps

- name: Run E2E tests
run: npx percy exec -- npm run test:e2e
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: test-results/
retention-days: 7
60 changes: 60 additions & 0 deletions .github/workflows/checkly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Checkly

on: [deployment_status]

env:
CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }}
CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }}
ENVIRONMENT_URL: ${{ github.event.deployment_status.environment_url }}
CHECKLY_TEST_ENVIRONMENT: ${{ github.event.deployment_status.environment }}

jobs:
test-e2e:
strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

if: github.event.deployment_status.state == 'success' # Only run when the deployment was successful.

name: Test E2E on Checkly
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
with:
ref: "${{ github.event.deployment_status.deployment.ref }}"
fetch-depth: 0

- name: Set branch name # workaround to detect branch name in "deployment_status" actions
run: echo "CHECKLY_TEST_REPO_BRANCH=$(git show -s --pretty=%D HEAD | tr -s ',' '\n' | sed 's/^ //' | grep -e 'origin/' | head -1 | sed 's/\origin\///g')" >> $GITHUB_ENV

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Restore or cache node_modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Run checks # run the checks passing in the ENVIRONMENT_URL and recording a test session.
id: run-checks
run: npx checkly test -e ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }} --reporter=github --record

- name: Create summary # export the markdown report to the job summary.
id: create-summary
run: cat checkly-github-report.md > $GITHUB_STEP_SUMMARY

- name: Deploy checks # if the test run was successful and we are on Production, deploy the checks
id: deploy-checks
if: steps.run-checks.outcome == 'success' && github.event.deployment_status.environment == 'Production'
run: npx checkly deploy --force
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main

jobs:
release:
strategy:
matrix:
node-version: [20.x]

name: Create a new release
runs-on: ubuntu-latest

permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: HUSKY=0 npm ci

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
33 changes: 33 additions & 0 deletions .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update dependencies

on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *"

jobs:
update:
strategy:
matrix:
node-version: [20.x]

name: Update all dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci

- run: npx npm-check-updates -u # Update dependencies
- run: rm -Rf node_modules package-lock.json
- run: npm install
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: "build: update dependencies to the latest version"
title: Update dependencies to the latest version

0 comments on commit d58e1d9

Please sign in to comment.