Compare commits
2 Commits
feat/prelo
...
background
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff44f51a14 | ||
|
|
a9d2c82557 |
@@ -1,23 +1,30 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"linked": [],
|
||||
"fixed": [
|
||||
[
|
||||
"cojson",
|
||||
"cojson-storage-indexeddb",
|
||||
"cojson-storage-sqlite",
|
||||
"cojson-transport-ws",
|
||||
"jazz-auth-betterauth",
|
||||
"jazz-betterauth-client-plugin",
|
||||
"jazz-betterauth-server-plugin",
|
||||
"jazz-react-auth-betterauth",
|
||||
"jazz-run",
|
||||
"jazz-tools"
|
||||
]
|
||||
],
|
||||
"access": "public",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "minor"
|
||||
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [
|
||||
[
|
||||
"cojson",
|
||||
"jazz-tools",
|
||||
"jazz-browser",
|
||||
"jazz-browser-media-images",
|
||||
"jazz-browser-auth-clerk",
|
||||
"jazz-react-auth-clerk",
|
||||
"jazz-react",
|
||||
"jazz-react-native",
|
||||
"jazz-nodejs",
|
||||
"jazz-run",
|
||||
"cojson-transport-ws",
|
||||
"cojson-storage-indexeddb",
|
||||
"cojson-storage-sqlite"
|
||||
]
|
||||
],
|
||||
"access": "public",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": [],
|
||||
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
|
||||
"onlyUpdatePeerDependentsWhenOutOfRange": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# EditorConfig is awesome: https://editorconfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -1,2 +0,0 @@
|
||||
# Formatted workspace with biome
|
||||
be0a09a22295cd5d2ee3ef323e2d999da8a14110
|
||||
10
.github/ISSUE_TEMPLATE/docs-request.md
vendored
10
.github/ISSUE_TEMPLATE/docs-request.md
vendored
@@ -1,10 +0,0 @@
|
||||
---
|
||||
name: Docs request
|
||||
about: Allow people to quickly report issues & improvements for the docs
|
||||
title: 'Docs: '
|
||||
labels: docs, requested
|
||||
assignees: bensleveritt
|
||||
|
||||
---
|
||||
|
||||
|
||||
39
.github/actions/android-emulator/action.yml
vendored
39
.github/actions/android-emulator/action.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: Setup Android Emulator
|
||||
|
||||
inputs:
|
||||
api-level:
|
||||
description: 'API level to use for the emulator'
|
||||
required: true
|
||||
default: '29'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Enable KVM
|
||||
shell: bash
|
||||
run: |
|
||||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger --name-match=kvm
|
||||
|
||||
- name: Gradle cache
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: AVD cache
|
||||
uses: useblacksmith/cache@v5
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-${{ inputs.api-level }}
|
||||
|
||||
- name: Create AVD and Generate Snapshot for Caching
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: ${{ inputs.api-level }}
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
|
||||
disable-animations: false
|
||||
script: echo "Generated AVD snapshot for caching."
|
||||
36
.github/actions/source-code/action.yml
vendored
36
.github/actions/source-code/action.yml
vendored
@@ -1,36 +0,0 @@
|
||||
name: Get and Build Source Code
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Enable latestcorepack
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
|
||||
- name: Install Node.js
|
||||
uses: useblacksmith/setup-node@v5
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: useblacksmith/cache@v5
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: pnpm install --frozen-lockfile
|
||||
23
.github/pull_request_template.md
vendored
23
.github/pull_request_template.md
vendored
@@ -1,23 +0,0 @@
|
||||
# Description
|
||||
<!-- Please include a summary of the change and which issue is fixed -->
|
||||
<!-- Please also include relevant motivation and context -->
|
||||
<!-- Include any links to documentation like RFC’s if necessary -->
|
||||
<!-- Add a link to to relevant preview environments or anything that would simplify visual review process -->
|
||||
<!-- Supplemental screenshots and video are encouraged, but the primary description should be in text -->
|
||||
|
||||
## Manual testing instructions
|
||||
|
||||
<!-- Add any actions required to manually test the changes -->
|
||||
|
||||
## Tests
|
||||
|
||||
- [ ] Tests have been added and/or updated
|
||||
- [ ] Tests have not been updated, because: <!-- Insert reason for not updating tests here -->
|
||||
- [ ] I need help with writing tests
|
||||
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] I've updated the part of the docs that are affected the PR changes
|
||||
- [ ] I've generated a changeset, if a version bump is required
|
||||
- [ ] I've updated the jsDoc comments to the public APIs I've modified, or added them when missing
|
||||
58
.github/workflows/build-examples.yaml
vendored
Normal file
58
.github/workflows/build-examples.yaml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: Build Examples
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build-examples:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
example: [
|
||||
"chat",
|
||||
"chat-clerk",
|
||||
"inspector",
|
||||
"music-player",
|
||||
"password-manager",
|
||||
"pets",
|
||||
"todo",
|
||||
]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
|
||||
- name: Pnpm Build
|
||||
run: |
|
||||
pnpm install
|
||||
pnpm turbo build;
|
||||
working-directory: ./examples/${{ matrix.example }}
|
||||
30
.github/workflows/code-quality.yml
vendored
30
.github/workflows/code-quality.yml
vendored
@@ -1,30 +0,0 @@
|
||||
name: Code quality
|
||||
|
||||
concurrency:
|
||||
# For pushes, this lets concurrent runs happen, so each push gets a result.
|
||||
# But for other events (e.g. PRs), we can cancel the previous runs.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
pull_request:
|
||||
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Biome
|
||||
uses: biomejs/setup-biome@v2
|
||||
with:
|
||||
version: 1.9.4
|
||||
- name: Run Biome
|
||||
run: biome ci .
|
||||
|
||||
- name: Check Catalog Dependencies
|
||||
run: node scripts/check-catalog-deps.js
|
||||
90
.github/workflows/e2e-rn-test.yml
vendored
90
.github/workflows/e2e-rn-test.yml
vendored
@@ -1,90 +0,0 @@
|
||||
name: End-to-End Tests for React Native
|
||||
|
||||
concurrency:
|
||||
# For pushes, this lets concurrent runs happen, so each push gets a result.
|
||||
# But for other events (e.g. PRs), we can cancel the previous runs.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- ".github/actions/android-emulator/**"
|
||||
- ".github/actions/source-code/**"
|
||||
- ".github/workflows/e2e-rn-test.yml"
|
||||
- "examples/chat-rn-expo/**"
|
||||
- "packages/**"
|
||||
|
||||
jobs:
|
||||
e2e-tests:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2204
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Source Code
|
||||
uses: ./.github/actions/source-code/
|
||||
|
||||
- name: Create Output Directory
|
||||
run: |
|
||||
mkdir -p ~/output
|
||||
|
||||
- name: Setup JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: corretto
|
||||
java-version: 22
|
||||
cache: gradle
|
||||
|
||||
- name: Pnpm Build
|
||||
run: pnpm turbo build --filter="./packages/*"
|
||||
|
||||
- name: chat-rn-expo App Pre Build
|
||||
working-directory: ./examples/chat-rn-expo
|
||||
run: |
|
||||
pnpm expo prebuild --clean
|
||||
|
||||
- name: Install Maestro
|
||||
run: |
|
||||
curl -fsSL "https://get.maestro.mobile.dev" | bash
|
||||
|
||||
- name: Setup Android Emulator
|
||||
id: android-emulator
|
||||
uses: ./.github/actions/android-emulator/
|
||||
with:
|
||||
api-level: 29
|
||||
|
||||
- name: Test App
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
id: e2e_test
|
||||
continue-on-error: true
|
||||
with:
|
||||
api-level: 29
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
|
||||
disable-animations: true
|
||||
working-directory: ./examples/chat-rn-expo/
|
||||
# killall due to this issue: https://github.com/ReactiveCircus/android-emulator-runner/issues/385
|
||||
script: ./test/e2e/run.sh && ( killall -INT crashpad_handler || true )
|
||||
|
||||
- name: Copy Maestro Output
|
||||
if: steps.e2e_test.outcome != 'success'
|
||||
run: |
|
||||
cp -r ~/.maestro/tests/* ~/output
|
||||
|
||||
- name: Upload Output Files
|
||||
if: steps.e2e_test.outcome != 'success'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-test-output
|
||||
path: ~/output/*
|
||||
retention-days: 5
|
||||
|
||||
- name: Exit with Test Result
|
||||
if: always()
|
||||
run: |
|
||||
if [ "${{ steps.e2e_test.outcome }}" != "success" ]; then
|
||||
exit 1
|
||||
fi
|
||||
34
.github/workflows/jazz-run.yml
vendored
34
.github/workflows/jazz-run.yml
vendored
@@ -1,34 +0,0 @@
|
||||
name: Jazz Run Tests
|
||||
|
||||
concurrency:
|
||||
# For pushes, this lets concurrent runs happen, so each push gets a result.
|
||||
# But for other events (e.g. PRs), we can cancel the previous runs.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup Source Code
|
||||
uses: ./.github/actions/source-code/
|
||||
|
||||
- name: Build jazz-run
|
||||
run: pnpm exec turbo build && chmod +x dist/index.js;
|
||||
working-directory: ./packages/jazz-run
|
||||
|
||||
- name: Run create account
|
||||
run: ./dist/index.js account create --name "Jazz Run CI test"
|
||||
working-directory: ./packages/jazz-run
|
||||
21
.github/workflows/monorepo-linting.yml
vendored
Normal file
21
.github/workflows/monorepo-linting.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Monorepo linting
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
monorepo-linting:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
|
||||
- name: Run sherif
|
||||
run: npx sherif@1.0.0
|
||||
183
.github/workflows/playwright.yml
vendored
183
.github/workflows/playwright.yml
vendored
@@ -1,11 +1,5 @@
|
||||
name: Playwright Tests
|
||||
|
||||
concurrency:
|
||||
# For pushes, this lets concurrent runs happen, so each push gets a result.
|
||||
# But for other events (e.g. PRs), we can cancel the previous runs.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
@@ -15,144 +9,61 @@ on:
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
shard: ["1/2", "2/2"]
|
||||
project: ["e2e/BinaryCoStream", "e2e/CoValues", "examples/chat", "examples/music-player", "examples/pets"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup Source Code
|
||||
uses: ./.github/actions/source-code/
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Pnpm Build
|
||||
run: pnpm turbo build
|
||||
working-directory: ./${{ matrix.project }}
|
||||
|
||||
- name: Build jazz-run
|
||||
run: pnpm exec turbo build && chmod +x dist/index.js;
|
||||
working-directory: ./packages/jazz-run
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
run: pnpm exec playwright install
|
||||
run: pnpm exec playwright install --with-deps
|
||||
working-directory: ./${{ matrix.project }}
|
||||
|
||||
- name: Run Playwright tests for shard ${{ matrix.shard }}
|
||||
run: |
|
||||
# Parse shard information (e.g., "1/2" -> shard_num=1, total_shards=2)
|
||||
IFS='/' read -r shard_num total_shards <<< "${{ matrix.shard }}"
|
||||
shard_index=$((shard_num - 1)) # Convert to 0-based index
|
||||
|
||||
# Debug: Print parsed values
|
||||
echo "Parsed shard_num: $shard_num"
|
||||
echo "Parsed total_shards: $total_shards"
|
||||
echo "Calculated shard_index: $shard_index"
|
||||
|
||||
# Define all projects to test
|
||||
all_projects=(
|
||||
"tests/e2e"
|
||||
"examples/chat"
|
||||
"examples/chat-svelte"
|
||||
"examples/clerk"
|
||||
"examples/betterauth"
|
||||
"examples/file-share-svelte"
|
||||
"examples/form"
|
||||
"examples/inspector"
|
||||
"examples/music-player"
|
||||
"examples/organization"
|
||||
"examples/server-worker-http"
|
||||
"starters/react-passkey-auth"
|
||||
"starters/svelte-passkey-auth"
|
||||
"tests/jazz-svelte"
|
||||
)
|
||||
|
||||
# Calculate which projects this shard should run
|
||||
shard_projects=()
|
||||
for i in "${!all_projects[@]}"; do
|
||||
if [ $((i % total_shards)) -eq $shard_index ]; then
|
||||
shard_projects+=("${all_projects[i]}")
|
||||
fi
|
||||
done
|
||||
|
||||
# Track project results
|
||||
overall_exit_code=0
|
||||
failed_projects=()
|
||||
passed_projects=()
|
||||
|
||||
echo "=== Running tests for shard ${{ matrix.shard }} ==="
|
||||
echo "Projects in this shard:"
|
||||
printf '%s\n' "${shard_projects[@]}"
|
||||
echo
|
||||
|
||||
# Run tests for each project
|
||||
for project in "${shard_projects[@]}"; do
|
||||
echo "=== Testing project: $project ==="
|
||||
|
||||
# Check if project directory exists
|
||||
if [ ! -d "$project" ]; then
|
||||
echo "❌ FAILED: Project directory $project does not exist"
|
||||
failed_projects+=("$project (directory not found)")
|
||||
overall_exit_code=1
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if project has package.json
|
||||
if [ ! -f "$project/package.json" ]; then
|
||||
echo "❌ FAILED: No package.json found in $project"
|
||||
failed_projects+=("$project (no package.json)")
|
||||
overall_exit_code=1
|
||||
continue
|
||||
fi
|
||||
|
||||
# Build the project
|
||||
echo "🔨 Building $project..."
|
||||
cd "$project"
|
||||
|
||||
if [ -f .env.test ]; then
|
||||
cp .env.test .env
|
||||
fi
|
||||
|
||||
if ! pnpm turbo build; then
|
||||
echo "❌ BUILD FAILED: $project"
|
||||
failed_projects+=("$project (build failed)")
|
||||
overall_exit_code=1
|
||||
cd - > /dev/null
|
||||
continue
|
||||
fi
|
||||
|
||||
# Run Playwright tests
|
||||
echo "🧪 Running Playwright tests for $project..."
|
||||
if ! pnpm exec playwright test; then
|
||||
echo "❌ TESTS FAILED: $project"
|
||||
failed_projects+=("$project (tests failed)")
|
||||
overall_exit_code=1
|
||||
else
|
||||
echo "✅ TESTS PASSED: $project"
|
||||
passed_projects+=("$project")
|
||||
fi
|
||||
|
||||
cd - > /dev/null
|
||||
echo "=== Finished testing $project ==="
|
||||
echo
|
||||
done
|
||||
|
||||
# Print summary report
|
||||
echo "=========================================="
|
||||
echo "📊 TEST SUMMARY FOR SHARD ${{ matrix.shard }}"
|
||||
echo "=========================================="
|
||||
|
||||
if [ ${#passed_projects[@]} -gt 0 ]; then
|
||||
echo "✅ PASSED (${#passed_projects[@]}):"
|
||||
printf ' - %s\n' "${passed_projects[@]}"
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ ${#failed_projects[@]} -gt 0 ]; then
|
||||
echo "❌ FAILED (${#failed_projects[@]}):"
|
||||
printf ' - %s\n' "${failed_projects[@]}"
|
||||
echo
|
||||
fi
|
||||
|
||||
|
||||
echo "Total projects in shard: ${#shard_projects[@]}"
|
||||
echo "Passed: ${#passed_projects[@]}"
|
||||
echo "Failed: ${#failed_projects[@]}"
|
||||
echo "=========================================="
|
||||
|
||||
# Exit with overall status
|
||||
exit $overall_exit_code
|
||||
- name: Run Playwright tests
|
||||
run: pnpm exec playwright test
|
||||
working-directory: ./${{ matrix.project }}
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: ${{ hashFiles(format('{0}/package.json', matrix.project)) }}-playwright-report
|
||||
path: ./${{ matrix.project }}/playwright-report/
|
||||
retention-days: 30
|
||||
|
||||
109
.github/workflows/pre-release.yml
vendored
109
.github/workflows/pre-release.yml
vendored
@@ -1,109 +0,0 @@
|
||||
name: Pre-Publish tagged Pull Requests
|
||||
|
||||
concurrency:
|
||||
# For pushes, this lets concurrent runs happen, so each push gets a result.
|
||||
# But for other events (e.g. PRs), we can cancel the previous runs.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
|
||||
jobs:
|
||||
pre-release:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'pre-release')
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Source Code
|
||||
uses: ./.github/actions/source-code/
|
||||
|
||||
- name: Pnpm Build
|
||||
run: pnpm turbo build --filter="./packages/*"
|
||||
|
||||
- name: Pre publish
|
||||
run: pnpm exec pkg-pr-new publish --json output.json --comment=off "./packages/*"
|
||||
|
||||
- name: Post or update comment
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
|
||||
|
||||
const packages = output.packages
|
||||
.map((p) => `- ${p.name}: ${p.url}`)
|
||||
.join('\n');
|
||||
|
||||
const sha =
|
||||
context.event_name === 'pull_request'
|
||||
? context.payload.pull_request.head.sha
|
||||
: context.payload.after;
|
||||
|
||||
const resolutions = Object.fromEntries(
|
||||
output.packages.map((p) => [p.name, p.url])
|
||||
);
|
||||
|
||||
const commitUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${sha}`;
|
||||
|
||||
const body = `## Jazz pre-release
|
||||
|
||||
### Packages:
|
||||
|
||||
\`\`\`json
|
||||
${JSON.stringify(resolutions, null, 4)}
|
||||
\`\`\`
|
||||
|
||||
[View Commit](${commitUrl})`;
|
||||
|
||||
async function logPublishInfo() {
|
||||
console.log('\n' + '='.repeat(50));
|
||||
console.log('Publish Information');
|
||||
console.log('='.repeat(50));
|
||||
console.log('\nPublished Packages:');
|
||||
console.log(output.packages);
|
||||
console.log('\nTemplates:');
|
||||
console.log(templates);
|
||||
console.log(`\nCommit URL: ${commitUrl}`);
|
||||
console.log('\n' + '='.repeat(50));
|
||||
}
|
||||
|
||||
if (context.eventName === 'pull_request') {
|
||||
if (context.issue.number) {
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: body,
|
||||
});
|
||||
}
|
||||
} else if (context.eventName === 'push') {
|
||||
const pullRequests = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: 'open',
|
||||
head: `${context.repo.owner}:${context.ref.replace(
|
||||
'refs/heads/',
|
||||
''
|
||||
)}`,
|
||||
});
|
||||
|
||||
if (pullRequests.data.length > 0) {
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: pullRequests.data[0].number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: body,
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
'No open pull request found for this push. Logging publish information to console:'
|
||||
);
|
||||
await logPublishInfo();
|
||||
}
|
||||
}
|
||||
46
.github/workflows/release.yml
vendored
46
.github/workflows/release.yml
vendored
@@ -1,46 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
type: boolean
|
||||
description: "Run tmate session for debugging"
|
||||
required: false
|
||||
default: false
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Source Code
|
||||
uses: ./.github/actions/source-code/
|
||||
|
||||
- name: Build packages
|
||||
run: pnpm exec turbo run build --filter='./packages/*'
|
||||
|
||||
- name: Create Release Pull Request or Publish to npm
|
||||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
version: pnpm changeset-version
|
||||
publish: pnpm release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
# Enable tmate debugging only if the workflow is manually triggered, debug_enabled is true, and the workflow failed
|
||||
- name: Setup tmate session for debugging
|
||||
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
with:
|
||||
timeout-minutes: 15
|
||||
41
.github/workflows/unit-test.yml
vendored
41
.github/workflows/unit-test.yml
vendored
@@ -1,11 +1,5 @@
|
||||
name: Unit Tests
|
||||
|
||||
concurrency:
|
||||
# For pushes, this lets concurrent runs happen, so each push gets a result.
|
||||
# But for other events (e.g. PRs), we can cancel the previous runs.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
@@ -15,20 +9,39 @@ on:
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Source Code
|
||||
uses: ./.github/actions/source-code/
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Pnpm Build
|
||||
run: pnpm turbo build --filter="./packages/*"
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
run: pnpm exec playwright install
|
||||
run: pnpm turbo build
|
||||
|
||||
- name: Unit Tests
|
||||
run: pnpm test:ci
|
||||
|
||||
31
.gitignore
vendored
31
.gitignore
vendored
@@ -4,33 +4,4 @@ lerna-debug.log
|
||||
docsTmp
|
||||
.DS_Store
|
||||
.turbo
|
||||
coverage
|
||||
.direnv
|
||||
|
||||
# Typescript
|
||||
**/*.tsbuildinfo
|
||||
|
||||
# Next.js
|
||||
**/.next
|
||||
|
||||
# Vite output
|
||||
**/dist
|
||||
__screenshots__
|
||||
|
||||
# Playwright
|
||||
test-results
|
||||
|
||||
# Java
|
||||
.java-version
|
||||
|
||||
.husky
|
||||
|
||||
.vscode/*
|
||||
.idea/*
|
||||
|
||||
.svelte-kit
|
||||
|
||||
.cursorrules
|
||||
.windsurfrules
|
||||
|
||||
playwright-report
|
||||
coverage
|
||||
@@ -1 +1 @@
|
||||
22
|
||||
20
|
||||
9
.prettierrc.js
Normal file
9
.prettierrc.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @type {import("prettier").Config} */
|
||||
const config = {
|
||||
trailingComma: "all",
|
||||
tabWidth: 4,
|
||||
semi: true,
|
||||
singleQuote: false,
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,131 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
- Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to [the community leaders responsible for enforcement](mailto:hello@garden.co).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
@@ -1,99 +0,0 @@
|
||||
# Contribution Guide
|
||||
|
||||
Thank you for considering contributing to Jazz! Jazz is an open-source framework for building local-first apps. We value your time and effort and are excited to collaborate with you. This guide will help you get started with contributing.
|
||||
|
||||
## How to Contribute
|
||||
|
||||
### 1. Reporting Bugs
|
||||
|
||||
If you find a bug, please [open an issue with as much detail as possible](https://github.com/garden-co/jazz/issues). Include:
|
||||
|
||||
- A clear and descriptive title.
|
||||
- Steps to reproduce the issue.
|
||||
- What you expected to happen.
|
||||
- What actually happened.
|
||||
|
||||
### 2. Suggesting Enhancements
|
||||
|
||||
We welcome all ideas! If you have suggestions, feel free to open an issue marked with the "enhancement" label. Please provide context on why the enhancement would be beneficial and how it could be implemented.
|
||||
|
||||
### 3. Pull Requests
|
||||
|
||||
1. **Fork the repository** and create your feature branch (see [GitHub's guide on forking a repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo) if you're unfamiliar with the process):
|
||||
|
||||
2. **Make your changes**, ensuring that you follow our coding standards (`pnpm format` (prettier) and `pnpm lint` (eslint) will automatically let you know there are issues).
|
||||
|
||||
3. **Commit your changes** with a descriptive commit message.
|
||||
|
||||
4. **Push to your fork** and submit a pull request.
|
||||
|
||||
5. **Describe your pull request**, explaining the problem it solves or the enhancement it adds.
|
||||
|
||||
### 4. Code Style Guidelines
|
||||
|
||||
- We use [Prettier](https://prettier.io/) for formatting. Please ensure your code is formatted before submitting.
|
||||
- Write descriptive comments where necessary.
|
||||
|
||||
### 5. Local Setup
|
||||
|
||||
You'll need Node.js 22.x installed (we're working on support for 23.x), and pnpm 9.x installed. If you're using nix, run `nix develop` to get a shell with the correct versions of everything installed.
|
||||
|
||||
1. **Clone the repository**:
|
||||
```bash
|
||||
git clone https://github.com/garden-co/jazz.git
|
||||
```
|
||||
|
||||
2. **Install dependencies**:
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
3. **Install homepage dependencies**:
|
||||
|
||||
```bash
|
||||
cd homepage && pnpm install
|
||||
```
|
||||
|
||||
4. **Go back to the project root**:
|
||||
|
||||
```bash
|
||||
cd ..
|
||||
```
|
||||
|
||||
4. **Build the packages**:
|
||||
|
||||
```bash
|
||||
pnpm build:packages
|
||||
```
|
||||
|
||||
5. **Run tests** to verify everything is working:
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
### 6. Testing
|
||||
|
||||
Please write tests for any new features or bug fixes. We use Vitest for unit tests, and Playwright for e2e tests. Make sure all tests pass before submitting a pull request.
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
NB: You'll need to run `pnpm exec playwright install` to install the Playwright browsers before first run.
|
||||
|
||||
### 7. Communication
|
||||
|
||||
- If you're unsure about anything, feel free to ask questions by opening a discussion, reaching out via issues, or on our [Discord](https://discord.gg/utDMjHYg42).
|
||||
- Be respectful and constructive, this is a welcoming community for everyone.
|
||||
- Please be mindful of GitHub’s [Community Guidelines](https://docs.github.com/en/site-policy/github-terms/github-community-guidelines), which include being kind, avoiding disruptive behavior, and respecting others.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please read and adhere to our [Code of Conduct](./CODE_OF_CONDUCT.md) to ensure a positive experience for all contributors.
|
||||
|
||||
---
|
||||
|
||||
Thank you again for your interest in contributing to Jazz. Your help makes this project better for everyone!
|
||||
|
||||
If you have any questions, don't hesitate to reach out. Let's make something great together!
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright 2025, Garden Computing, Inc.
|
||||
Copyright 2024, Garden Computing, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
18
README.md
18
README.md
@@ -1,20 +1,12 @@
|
||||
# Jazz - Build local-first apps
|
||||
# Jazz - Instant sync
|
||||
|
||||
|
||||
|
||||
**Jazz is an open-source toolkit for building apps with *distributed state.***
|
||||
|
||||
## Getting started
|
||||
|
||||
We recommend reading the [homepage](https://jazz.tools) and [docs](https://jazz.tools/docs) to get an overview of what Jazz is and how it works.
|
||||
|
||||
If you're interested in contributing, please read [CONTRIBUTING.md](./CONTRIBUTING.md).
|
||||
|
||||
For community and support, please join our [Discord](https://discord.gg/utDMjHYg42).
|
||||
|
||||
---
|
||||
|
||||
- Homepage: [jazz.tools](https://jazz.tools)
|
||||
- Docs: [jazz.tools/docs](https://jazz.tools/docs)
|
||||
- Community & support: [Discord](https://discord.gg/utDMjHYg42)
|
||||
- Updates: [X](https://x.com/jazz_tools) & [Email](https://garden.co/news)
|
||||
- Updates: [Twitter](https://twitter.com/jazz_tools) & [Email](https://gcmp.io/news)
|
||||
|
||||
Copyright 2025 — Garden Computing, Inc.
|
||||
Copyright 2024 — Garden Computing, Inc.
|
||||
84
biome.json
84
biome.json
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"ignore": [
|
||||
"jazz-tools.json",
|
||||
"**/ios/**",
|
||||
"**/android/**",
|
||||
"tests/jazz-svelte/src/**",
|
||||
"examples/*svelte*/**",
|
||||
"starters/*svelte*/**",
|
||||
"examples/server-worker-inbox/src/routeTree.gen.ts",
|
||||
"homepage/homepage/**",
|
||||
"**/package.json"
|
||||
]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space"
|
||||
},
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"linter": {
|
||||
"enabled": false,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"correctness": {
|
||||
"useImportExtensions": {
|
||||
"level": "error",
|
||||
"options": {
|
||||
"suggestedExtensions": {
|
||||
"ts": {
|
||||
"module": "js",
|
||||
"component": "jsx"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"include": ["packages/**/src/**"],
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"include": ["packages/cojson/src/storage/*/**", "cojson-transport-ws/**"],
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"include": ["**/tests/**"],
|
||||
"linter": {
|
||||
"rules": {
|
||||
"correctness": {
|
||||
"useImportExtensions": "off"
|
||||
},
|
||||
"style": {
|
||||
"noNonNullAssertion": "off"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "info"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
55
e2e/BinaryCoStream/CHANGELOG.md
Normal file
55
e2e/BinaryCoStream/CHANGELOG.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# @jazz-e2e/binarycostream
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.8.7
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.8.6
|
||||
|
||||
## 0.0.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c3f4e6b]
|
||||
- Updated dependencies [d9152ed]
|
||||
- jazz-tools@0.8.5
|
||||
- cojson@0.8.5
|
||||
- jazz-react@0.8.5
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- hash-slash@0.2.1
|
||||
|
||||
## 0.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- cojson@0.8.3
|
||||
- jazz-react@0.8.3
|
||||
- jazz-tools@0.8.3
|
||||
|
||||
## 0.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a075f90]
|
||||
- jazz-tools@0.8.2
|
||||
- jazz-react@0.8.2
|
||||
|
||||
## 0.0.82
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- jazz-tools@0.8.1
|
||||
- jazz-react@0.8.1
|
||||
14
e2e/BinaryCoStream/index.html
Normal file
14
e2e/BinaryCoStream/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/jazz-logo.png" />
|
||||
<link rel="stylesheet" href="/src/index.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Jazz BinaryCoStream Tests</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/app.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
34
e2e/BinaryCoStream/package.json
Normal file
34
e2e/BinaryCoStream/package.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@jazz-e2e/binarycostream",
|
||||
"private": true,
|
||||
"version": "0.0.88",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "playwright test",
|
||||
"test:ui": "playwright test --ui"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,mdx,json}": "prettier --write"
|
||||
},
|
||||
"dependencies": {
|
||||
"cojson": "workspace:0.8.5",
|
||||
"hash-slash": "workspace:0.2.1",
|
||||
"is-ci": "^3.0.1",
|
||||
"jazz-react": "workspace:0.8.7",
|
||||
"jazz-tools": "workspace:0.8.5",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.46.1",
|
||||
"@types/node": "^22.5.1",
|
||||
"@types/react": "^18.2.19",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@vitejs/plugin-react-swc": "^3.3.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.10"
|
||||
}
|
||||
}
|
||||
49
e2e/BinaryCoStream/playwright.config.ts
Normal file
49
e2e/BinaryCoStream/playwright.config.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
import isCI from "is-ci";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: isCI,
|
||||
/* Retry on CI only */
|
||||
retries: isCI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: isCI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: "html",
|
||||
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: isCI ? "http://localhost:4173/" : "http://localhost:5173",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: isCI ? {
|
||||
command: "pnpm preview",
|
||||
url: "http://localhost:4173/",
|
||||
} : undefined,
|
||||
});
|
||||
42
e2e/BinaryCoStream/src/DownloaderPeer.tsx
Normal file
42
e2e/BinaryCoStream/src/DownloaderPeer.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Account, BinaryCoStream, ID } from "jazz-tools";
|
||||
import { useEffect } from "react";
|
||||
import { useAccount, useCoState } from "./jazz";
|
||||
import { UploadedFile } from "./schema";
|
||||
import { waitForCoValue } from "./lib/waitForCoValue";
|
||||
|
||||
async function getUploadedFile(
|
||||
me: Account,
|
||||
uploadedFileId: ID<UploadedFile>) {
|
||||
const uploadedFile = await waitForCoValue(UploadedFile, uploadedFileId, me, Boolean, {})
|
||||
|
||||
uploadedFile.coMapDownloaded = true;
|
||||
|
||||
await BinaryCoStream.loadAsBlob(uploadedFile._refs.file.id, me);
|
||||
|
||||
return uploadedFile;
|
||||
}
|
||||
|
||||
export function DownloaderPeer(props: { testCoMapId: ID<UploadedFile> }) {
|
||||
const account = useAccount();
|
||||
const testCoMap = useCoState(UploadedFile, props.testCoMapId, {});
|
||||
|
||||
useEffect(() => {
|
||||
getUploadedFile(account.me, props.testCoMapId).then(value => {
|
||||
value.syncCompleted = true;
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>Downloader Peer</h1>
|
||||
<div>Fetching: {props.testCoMapId}</div>
|
||||
<div data-testid="result">
|
||||
Covalue: {Boolean(testCoMap?.id) ? "Downloaded" : "Not Downloaded"}
|
||||
</div>
|
||||
<div data-testid="result">
|
||||
File:{" "}
|
||||
{Boolean(testCoMap?.syncCompleted) ? "Downloaded" : "Not Downloaded"}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,29 +1,26 @@
|
||||
import { coValueClassFromCoValueClassOrSchema } from "jazz-tools";
|
||||
import { useAccount, useCoState } from "jazz-tools/react";
|
||||
import { ID } from "jazz-tools";
|
||||
import { useEffect, useState } from "react";
|
||||
import { createCredentiallessIframe } from "../../lib/createCredentiallessIframe";
|
||||
import { waitForCoValue } from "../../lib/waitForCoValue";
|
||||
import { BytesRadioGroup } from "./lib/BytesRadioGroup";
|
||||
import { useAccount, useCoState } from "./jazz";
|
||||
import { createCredentiallessIframe } from "./lib/createCredentiallessIframe";
|
||||
import { generateTestFile } from "./lib/generateTestFile";
|
||||
import { getDownloaderPeerUrl } from "./lib/getDownloaderPeerUrl";
|
||||
import { getDefaultFileSize, getIsAutoUpload } from "./lib/searchParams";
|
||||
import { UploadedFile } from "./schema";
|
||||
import { waitForCoValue } from "./lib/waitForCoValue";
|
||||
import { getDefaultFileSize, getIsAutoUpload } from "./lib/searchParams";
|
||||
import { BytesRadioGroup } from "./lib/BytesRadioGroup";
|
||||
|
||||
export function UploaderPeer() {
|
||||
const account = useAccount();
|
||||
const [uploadedFileId, setUploadedFileId] = useState<string | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const [uploadedFileId, setUploadedFileId] = useState<
|
||||
ID<UploadedFile> | undefined
|
||||
>(undefined);
|
||||
const [syncDuration, setSyncDuration] = useState<number | null>(null);
|
||||
const [bytes, setBytes] = useState(getDefaultFileSize);
|
||||
const [synced, setSynced] = useState(false);
|
||||
|
||||
const testFile = useCoState(UploadedFile, uploadedFileId, {});
|
||||
|
||||
async function uploadTestFile() {
|
||||
if (!account.me) return;
|
||||
|
||||
setUploadedFileId(undefined);
|
||||
setSynced(false);
|
||||
if (!account) return;
|
||||
|
||||
// Mark the sync start
|
||||
performance.mark("sync-start");
|
||||
@@ -37,17 +34,14 @@ export function UploaderPeer() {
|
||||
setSyncDuration(null);
|
||||
setUploadedFileId(file.id);
|
||||
|
||||
account.me.waitForAllCoValuesSync().then(() => {
|
||||
setSynced(true);
|
||||
});
|
||||
|
||||
// The downloader peer will set the syncCompleted to true when the download is complete.
|
||||
// We use this to measure the sync duration.
|
||||
await waitForCoValue(
|
||||
coValueClassFromCoValueClassOrSchema(UploadedFile),
|
||||
UploadedFile,
|
||||
file.id,
|
||||
account.me,
|
||||
(value) => value.syncCompleted,
|
||||
{ loadAs: account.me },
|
||||
{}
|
||||
);
|
||||
|
||||
iframe.remove();
|
||||
@@ -69,28 +63,24 @@ export function UploaderPeer() {
|
||||
<BytesRadioGroup selectedValue={bytes} onChange={setBytes} />
|
||||
|
||||
<button onClick={uploadTestFile}>Upload Test File</button>
|
||||
{uploadedFileId && (
|
||||
<>
|
||||
<div>{uploadedFileId}</div>
|
||||
<div data-testid="synced-with-server">
|
||||
Synced with the server: {String(synced)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{uploadedFileId && <div>{uploadedFileId}</div>}
|
||||
{syncDuration && (
|
||||
<div data-testid="sync-duration">
|
||||
Two way sync duration: {syncDuration.toFixed(2)}ms
|
||||
Sync Duration: {syncDuration.toFixed(2)}ms
|
||||
</div>
|
||||
)}
|
||||
{uploadedFileId && (
|
||||
<div data-testid="result">
|
||||
Two way sync completed: {String(Boolean(syncDuration))}
|
||||
Sync Completed: {String(Boolean(syncDuration))}
|
||||
</div>
|
||||
)}
|
||||
{testFile?.coMapDownloaded && (
|
||||
<div data-testid="co-map-downloaded">CoMap synced!</div>
|
||||
<div data-testid="co-map-downloaded">
|
||||
CoMap synced!
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
24
e2e/BinaryCoStream/src/app.tsx
Normal file
24
e2e/BinaryCoStream/src/app.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { DownloaderPeer } from "./DownloaderPeer";
|
||||
import { UploaderPeer } from "./UploaderPeer";
|
||||
import { getValueId } from "./lib/searchParams";
|
||||
import { AuthAndJazz } from "./jazz";
|
||||
|
||||
function Main() {
|
||||
const valueId = getValueId();
|
||||
|
||||
if (valueId) {
|
||||
return <DownloaderPeer testCoMapId={valueId} />;
|
||||
}
|
||||
|
||||
return <UploaderPeer />;
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||
<React.StrictMode>
|
||||
<AuthAndJazz>
|
||||
<Main />
|
||||
</AuthAndJazz>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
36
e2e/BinaryCoStream/src/jazz.tsx
Normal file
36
e2e/BinaryCoStream/src/jazz.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { createJazzReactApp, useDemoAuth } from "jazz-react";
|
||||
import { getValueId } from "./lib/searchParams";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
const key = getValueId()
|
||||
? `downloader-e2e@jazz.tools`
|
||||
: `uploader-e2e@jazz.tools`;
|
||||
|
||||
const localSync = new URLSearchParams(location.search).has("localSync");
|
||||
|
||||
const Jazz = createJazzReactApp();
|
||||
|
||||
export const { useAccount, useCoState } = Jazz;
|
||||
|
||||
export function AuthAndJazz({ children }: { children: React.ReactNode }) {
|
||||
const [auth, state] = useDemoAuth();
|
||||
|
||||
const signedUp = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (state.state === "ready" && !signedUp.current) {
|
||||
state.signUp('Mister X');
|
||||
signedUp.current = true;
|
||||
}
|
||||
}, [state.state])
|
||||
|
||||
return (
|
||||
<Jazz.Provider auth={auth} peer={
|
||||
localSync
|
||||
? `ws://localhost:4200?key=${key}`
|
||||
: `wss://cloud.jazz.tools/?key=${key}`
|
||||
}>
|
||||
{children}
|
||||
</Jazz.Provider>
|
||||
);
|
||||
}
|
||||
@@ -4,54 +4,46 @@ export function BytesRadioGroup(props: {
|
||||
}) {
|
||||
return (
|
||||
<p>
|
||||
<BytesRadioInput
|
||||
label="1KB"
|
||||
value={1e3}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
<BytesRadioInput
|
||||
label="10KB"
|
||||
value={1e4}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
<BytesRadioInput
|
||||
label="1KB"
|
||||
value={1e3}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="10KB"
|
||||
value={1e4}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="100KB"
|
||||
value={1e5}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="150KB"
|
||||
value={1e5 + 5e4}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="200KB"
|
||||
value={2e6}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="500KB"
|
||||
value={5e6}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="1MB"
|
||||
value={1e6}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
onChange={props.onChange} />
|
||||
<BytesRadioInput
|
||||
label="10MB"
|
||||
value={1e7}
|
||||
selectedValue={props.selectedValue}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
onChange={props.onChange} />
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -68,8 +60,7 @@ function BytesRadioInput(props: {
|
||||
name="bytes"
|
||||
value={props.value}
|
||||
checked={props.value === props.selectedValue}
|
||||
onChange={() => props.onChange(props.value)}
|
||||
/>
|
||||
onChange={() => props.onChange(props.value)} />
|
||||
{props.label}
|
||||
</label>
|
||||
);
|
||||
27
e2e/BinaryCoStream/src/lib/generateTestFile.ts
Normal file
27
e2e/BinaryCoStream/src/lib/generateTestFile.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Account, Group, BinaryCoStream } from "jazz-tools";
|
||||
import { UploadedFile } from "../schema";
|
||||
|
||||
export async function generateTestFile(me: Account, bytes: number) {
|
||||
const group = Group.create({ owner: me });
|
||||
group.addMember("everyone", "writer");
|
||||
|
||||
const ownership = { owner: group };
|
||||
const testFile = UploadedFile.create(
|
||||
{
|
||||
file: await BinaryCoStream.createFromBlob(
|
||||
new Blob(['1'.repeat(bytes)], { type: 'image/png' }),
|
||||
ownership
|
||||
),
|
||||
syncCompleted: false,
|
||||
coMapDownloaded: false,
|
||||
},
|
||||
ownership
|
||||
);
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
|
||||
url.searchParams.set("valueId", testFile.id);
|
||||
|
||||
return testFile;
|
||||
}
|
||||
|
||||
8
e2e/BinaryCoStream/src/lib/getDownloaderPeerUrl.ts
Normal file
8
e2e/BinaryCoStream/src/lib/getDownloaderPeerUrl.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { UploadedFile } from "src/schema";
|
||||
|
||||
|
||||
export function getDownloaderPeerUrl(value: UploadedFile) {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set("valueId", value.id);
|
||||
return url.toString();
|
||||
}
|
||||
14
e2e/BinaryCoStream/src/lib/searchParams.ts
Normal file
14
e2e/BinaryCoStream/src/lib/searchParams.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ID } from "jazz-tools";
|
||||
import { UploadedFile } from "../schema";
|
||||
|
||||
export function getValueId() {
|
||||
return new URLSearchParams(location.search).get("valueId") as ID<UploadedFile> | undefined ?? undefined;
|
||||
}
|
||||
|
||||
export function getIsAutoUpload() {
|
||||
return new URLSearchParams(location.search).has("auto");
|
||||
}
|
||||
|
||||
export function getDefaultFileSize() {
|
||||
return parseInt(new URLSearchParams(location.search).get("fileSize") ?? 1e3.toString());
|
||||
}
|
||||
39
e2e/BinaryCoStream/src/lib/waitForCoValue.ts
Normal file
39
e2e/BinaryCoStream/src/lib/waitForCoValue.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
Account,
|
||||
CoValue,
|
||||
CoValueClass,
|
||||
DepthsIn,
|
||||
ID,
|
||||
subscribeToCoValue,
|
||||
} from "jazz-tools";
|
||||
|
||||
export function waitForCoValue<T extends CoValue>(
|
||||
coMap: CoValueClass<T>,
|
||||
valueId: ID<T>,
|
||||
account: Account,
|
||||
predicate: (value: T) => boolean,
|
||||
depth: DepthsIn<T>
|
||||
) {
|
||||
return new Promise<T>((resolve) => {
|
||||
function subscribe() {
|
||||
const unsubscribe = subscribeToCoValue(
|
||||
coMap,
|
||||
valueId,
|
||||
account,
|
||||
depth,
|
||||
(value) => {
|
||||
if (predicate(value)) {
|
||||
resolve(value);
|
||||
unsubscribe();
|
||||
}
|
||||
},
|
||||
() => {
|
||||
unsubscribe();
|
||||
setTimeout(subscribe, 100);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
subscribe();
|
||||
});
|
||||
}
|
||||
7
e2e/BinaryCoStream/src/schema.tsx
Normal file
7
e2e/BinaryCoStream/src/schema.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { BinaryCoStream, co, CoMap } from "jazz-tools";
|
||||
|
||||
export class UploadedFile extends CoMap {
|
||||
file = co.ref(BinaryCoStream);
|
||||
syncCompleted = co.boolean;
|
||||
coMapDownloaded = co.boolean;
|
||||
}
|
||||
@@ -1,33 +1,23 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { setTimeout } from "node:timers/promises";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("FileStream - Sync", () => {
|
||||
test.describe("BinaryCoStream - Sync", () => {
|
||||
test("should sync a file between the two peers", async ({ page }) => {
|
||||
await page.goto("/file-stream");
|
||||
await page.goto("/");
|
||||
|
||||
await page.getByRole("button", { name: "Upload Test File" }).click();
|
||||
|
||||
await page.getByTestId("sync-duration").waitFor();
|
||||
|
||||
await expect(page.getByTestId("synced-with-server")).toHaveText(
|
||||
"Synced with the server: true",
|
||||
);
|
||||
|
||||
await expect(page.getByTestId("result")).toHaveText(
|
||||
"Two way sync completed: true",
|
||||
);
|
||||
await expect(page.getByTestId("result")).toHaveText("Sync Completed: true");
|
||||
});
|
||||
|
||||
test("should handle reconnections", async ({ page, browser }) => {
|
||||
const context = browser.contexts()[0];
|
||||
await page.goto("/file-stream?fileSize=" + 1e6); // 1MB file
|
||||
await page.goto("/?fileSize=" + 1e6); // 1MB file
|
||||
|
||||
await page.getByRole("button", { name: "Upload Test File" }).click();
|
||||
|
||||
await expect(page.getByTestId("synced-with-server")).toHaveText(
|
||||
"Synced with the server: false",
|
||||
);
|
||||
|
||||
// Wait for the coMapDonwloaded signal to ensure that the iframe is loaded
|
||||
await page.getByTestId("co-map-downloaded").waitFor();
|
||||
|
||||
@@ -41,12 +31,6 @@ test.describe("FileStream - Sync", () => {
|
||||
// Wait for the sync to complete
|
||||
await page.getByTestId("sync-duration").waitFor();
|
||||
|
||||
await expect(page.getByTestId("synced-with-server")).toHaveText(
|
||||
"Synced with the server: true",
|
||||
);
|
||||
|
||||
await expect(page.getByTestId("result")).toHaveText(
|
||||
"Two way sync completed: true",
|
||||
);
|
||||
await expect(page.getByTestId("result")).toHaveText("Sync Completed: true");
|
||||
});
|
||||
});
|
||||
@@ -21,5 +21,5 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": ["src"],
|
||||
}
|
||||
10
e2e/BinaryCoStream/vite.config.ts
Normal file
10
e2e/BinaryCoStream/vite.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react-swc'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
build: {
|
||||
minify: false
|
||||
}
|
||||
})
|
||||
@@ -22,15 +22,9 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
sync-db/
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
|
||||
sync-db/
|
||||
|
||||
# env files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
47
e2e/CoValues/CHANGELOG.md
Normal file
47
e2e/CoValues/CHANGELOG.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# @jazz-e2e/covalues
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.8.7
|
||||
|
||||
## 0.0.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.8.6
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c3f4e6b]
|
||||
- Updated dependencies [d9152ed]
|
||||
- jazz-tools@0.8.5
|
||||
- cojson@0.8.5
|
||||
- jazz-react@0.8.5
|
||||
|
||||
## 0.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- hash-slash@0.2.1
|
||||
|
||||
## 0.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- cojson@0.8.3
|
||||
- jazz-react@0.8.3
|
||||
- jazz-tools@0.8.3
|
||||
|
||||
## 0.0.82
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a075f90]
|
||||
- jazz-tools@0.8.2
|
||||
- jazz-react@0.8.2
|
||||
@@ -1,23 +1,23 @@
|
||||
{
|
||||
"name": "@jazz/e2e-test-suite",
|
||||
"name": "@jazz-e2e/covalues",
|
||||
"private": true,
|
||||
"version": "0.0.110",
|
||||
"version": "0.0.87",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev:local": "VITE_WS_PEER=ws://localhost:4200/ vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"format-and-lint": "biome check .",
|
||||
"format-and-lint:fix": "biome check . --write",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"sync": "jazz-run sync"
|
||||
"test": "playwright test",
|
||||
"test:ui": "playwright test --ui"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,mdx,json}": "prettier --write"
|
||||
},
|
||||
"dependencies": {
|
||||
"cojson": "workspace:*",
|
||||
"hash-slash": "workspace:*",
|
||||
"is-ci": "^3.0.1",
|
||||
"jazz-react": "workspace:*",
|
||||
"jazz-tools": "workspace:*",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
@@ -25,14 +25,13 @@
|
||||
"react-router-dom": "^6.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.50.1",
|
||||
"@playwright/test": "^1.46.1",
|
||||
"@types/node": "^22.5.1",
|
||||
"@types/react": "^18.2.19",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@vitejs/plugin-react-swc": "^3.10.1",
|
||||
"@vitejs/plugin-react-swc": "^3.3.2",
|
||||
"jstat": "^1.9.6",
|
||||
"typescript": "catalog:",
|
||||
"jazz-run": "workspace:*",
|
||||
"vite": "^6.3.5"
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.10"
|
||||
}
|
||||
}
|
||||
49
e2e/CoValues/playwright.config.ts
Normal file
49
e2e/CoValues/playwright.config.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
import isCI from "is-ci";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: isCI,
|
||||
/* Retry on CI only */
|
||||
retries: isCI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: isCI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: "html",
|
||||
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: isCI ? "http://localhost:4173/" : "http://localhost:5173",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: isCI ? {
|
||||
command: "pnpm preview",
|
||||
url: "http://localhost:4173/",
|
||||
} : undefined,
|
||||
});
|
||||
25
e2e/CoValues/src/app.tsx
Normal file
25
e2e/CoValues/src/app.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { AuthAndJazz } from "./jazz";
|
||||
import { TestInput } from "./pages/TestInput";
|
||||
import { RouterProvider, createHashRouter } from "react-router-dom";
|
||||
|
||||
const router = createHashRouter([
|
||||
{
|
||||
path: "/",
|
||||
element: <TestInput />,
|
||||
},
|
||||
{
|
||||
path: "/test-input",
|
||||
element: <TestInput />,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||
<React.StrictMode>
|
||||
<AuthAndJazz>
|
||||
<RouterProvider router={router} />
|
||||
</AuthAndJazz>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
25
e2e/CoValues/src/jazz.tsx
Normal file
25
e2e/CoValues/src/jazz.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createJazzReactApp } from "jazz-react";
|
||||
import { ephemeralCredentialsAuth } from "jazz-tools";
|
||||
import { useState } from "react";
|
||||
|
||||
const key = `test-comap@jazz.tools`;
|
||||
|
||||
const localSync = new URLSearchParams(location.search).has("localSync");
|
||||
|
||||
const Jazz = createJazzReactApp();
|
||||
|
||||
export const { useAccount, useCoState } = Jazz;
|
||||
|
||||
export function AuthAndJazz({ children }: { children: React.ReactNode }) {
|
||||
const [ephemeralAuth] = useState(ephemeralCredentialsAuth())
|
||||
|
||||
return (
|
||||
<Jazz.Provider auth={ephemeralAuth} peer={
|
||||
localSync
|
||||
? `ws://localhost:4200?key=${key}`
|
||||
: `wss://cloud.jazz.tools/?key=${key}`
|
||||
}>
|
||||
{children}
|
||||
</Jazz.Provider>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CoMap, Group, ID, coField } from "jazz-tools";
|
||||
import { useAccount, useCoState } from "jazz-tools/react";
|
||||
import { co, CoMap, Group, ID } from "jazz-tools";
|
||||
import { useAccount, useCoState } from "../jazz";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export class InputTestCoMap extends CoMap {
|
||||
title = coField.string;
|
||||
title = co.string;
|
||||
}
|
||||
|
||||
export function TestInput() {
|
||||
@@ -1,14 +1,14 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { test, expect } from "@playwright/test";
|
||||
|
||||
test.describe("CoMap - TestInput", () => {
|
||||
test("should keep the cursor position when typing", async ({ page }) => {
|
||||
await page.goto("/test-input");
|
||||
|
||||
await page.getByRole("textbox").fill("xx");
|
||||
await page.getByRole("textbox").press("ArrowLeft");
|
||||
await page.getByRole('textbox').press('ArrowLeft');
|
||||
await page.getByRole("textbox").press("y");
|
||||
await page.getByRole("textbox").press("y");
|
||||
|
||||
await expect(page.getByRole("textbox")).toHaveValue("xyyx");
|
||||
await expect(page.getByRole('textbox')).toHaveValue("xyyx");
|
||||
});
|
||||
});
|
||||
@@ -19,11 +19,7 @@
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
10
e2e/CoValues/vite.config.ts
Normal file
10
e2e/CoValues/vite.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react-swc'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
build: {
|
||||
minify: false
|
||||
}
|
||||
})
|
||||
@@ -1 +0,0 @@
|
||||
BETTER_AUTH_SECRET="TEST_SECRET"
|
||||
49
examples/betterauth/.gitignore
vendored
49
examples/betterauth/.gitignore
vendored
@@ -1,49 +0,0 @@
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
sqlite.db
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
@@ -1,298 +0,0 @@
|
||||
# betterauth
|
||||
|
||||
## 0.1.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [048ac1d]
|
||||
- jazz-tools@0.14.22
|
||||
- jazz-betterauth-server-plugin@0.14.22
|
||||
- jazz-inspector@0.14.22
|
||||
- jazz-react@0.14.22
|
||||
- jazz-react-auth-betterauth@0.14.22
|
||||
- jazz-betterauth-client-plugin@0.14.22
|
||||
|
||||
## 0.1.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e7e505e]
|
||||
- Updated dependencies [13b57aa]
|
||||
- Updated dependencies [5662faa]
|
||||
- Updated dependencies [2116a59]
|
||||
- jazz-tools@0.14.21
|
||||
- jazz-betterauth-server-plugin@0.14.21
|
||||
- jazz-inspector@0.14.21
|
||||
- jazz-react@0.14.21
|
||||
- jazz-react-auth-betterauth@0.14.21
|
||||
- jazz-betterauth-client-plugin@0.14.21
|
||||
|
||||
## 0.1.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6f72419]
|
||||
- Updated dependencies [04b20c2]
|
||||
- jazz-tools@0.14.20
|
||||
- jazz-betterauth-server-plugin@0.14.20
|
||||
- jazz-inspector@0.14.20
|
||||
- jazz-react@0.14.20
|
||||
- jazz-react-auth-betterauth@0.14.20
|
||||
- jazz-betterauth-client-plugin@0.14.20
|
||||
|
||||
## 0.1.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-betterauth-client-plugin@0.14.19
|
||||
- jazz-betterauth-server-plugin@0.14.19
|
||||
- jazz-react-auth-betterauth@0.14.19
|
||||
- jazz-inspector@0.14.19
|
||||
- jazz-react@0.14.19
|
||||
- jazz-tools@0.14.19
|
||||
|
||||
## 0.1.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4b950bc]
|
||||
- Updated dependencies [d6d9c0a]
|
||||
- Updated dependencies [c559054]
|
||||
- jazz-tools@0.14.18
|
||||
- jazz-betterauth-server-plugin@0.14.18
|
||||
- jazz-inspector@0.14.18
|
||||
- jazz-react@0.14.18
|
||||
- jazz-react-auth-betterauth@0.14.18
|
||||
- jazz-betterauth-client-plugin@0.14.18
|
||||
|
||||
## 0.1.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e512df4]
|
||||
- jazz-betterauth-server-plugin@0.14.17
|
||||
- jazz-tools@0.14.17
|
||||
- jazz-betterauth-client-plugin@0.14.17
|
||||
- jazz-inspector@0.14.17
|
||||
- jazz-react@0.14.17
|
||||
- jazz-react-auth-betterauth@0.14.17
|
||||
|
||||
## 0.1.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-betterauth-server-plugin@0.14.16
|
||||
- jazz-inspector@0.14.16
|
||||
- jazz-react@0.14.16
|
||||
- jazz-react-auth-betterauth@0.14.16
|
||||
- jazz-tools@0.14.16
|
||||
- jazz-betterauth-client-plugin@0.14.16
|
||||
|
||||
## 0.1.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f9590f9]
|
||||
- jazz-react@0.14.15
|
||||
- jazz-betterauth-server-plugin@0.14.15
|
||||
- jazz-inspector@0.14.15
|
||||
- jazz-react-auth-betterauth@0.14.15
|
||||
- jazz-tools@0.14.15
|
||||
- jazz-betterauth-client-plugin@0.14.15
|
||||
|
||||
## 0.1.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e32a1f7]
|
||||
- jazz-tools@0.14.14
|
||||
- jazz-betterauth-server-plugin@0.14.14
|
||||
- jazz-inspector@0.14.14
|
||||
- jazz-react@0.14.14
|
||||
- jazz-react-auth-betterauth@0.14.14
|
||||
- jazz-betterauth-client-plugin@0.14.14
|
||||
|
||||
## 0.1.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.14.13
|
||||
- jazz-react@0.14.13
|
||||
- jazz-react-auth-betterauth@0.14.13
|
||||
|
||||
## 0.1.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.14.12
|
||||
- jazz-react@0.14.12
|
||||
- jazz-react-auth-betterauth@0.14.12
|
||||
|
||||
## 0.1.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [dc746a2]
|
||||
- Updated dependencies [f869d9a]
|
||||
- Updated dependencies [3fe6832]
|
||||
- jazz-react-auth-betterauth@0.14.10
|
||||
- jazz-inspector@0.14.10
|
||||
- jazz-react@0.14.10
|
||||
- jazz-tools@0.14.10
|
||||
- jazz-betterauth-server-plugin@0.14.10
|
||||
- jazz-betterauth-client-plugin@0.14.10
|
||||
|
||||
## 0.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [22c2600]
|
||||
- jazz-tools@0.14.9
|
||||
- jazz-betterauth-server-plugin@0.14.9
|
||||
- jazz-inspector@0.14.9
|
||||
- jazz-react@0.14.9
|
||||
- jazz-react-auth-betterauth@0.14.9
|
||||
- jazz-betterauth-client-plugin@0.14.9
|
||||
|
||||
## 0.1.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [637ae13]
|
||||
- jazz-tools@0.14.8
|
||||
- jazz-betterauth-server-plugin@0.14.8
|
||||
- jazz-inspector@0.14.8
|
||||
- jazz-react@0.14.8
|
||||
- jazz-react-auth-betterauth@0.14.8
|
||||
- jazz-betterauth-client-plugin@0.14.8
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [365b0ea]
|
||||
- jazz-tools@0.14.7
|
||||
- jazz-betterauth-server-plugin@0.14.7
|
||||
- jazz-inspector@0.14.7
|
||||
- jazz-react@0.14.7
|
||||
- jazz-react-auth-betterauth@0.14.7
|
||||
- jazz-betterauth-client-plugin@0.14.7
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9d6d9fe]
|
||||
- Updated dependencies [9d6d9fe]
|
||||
- jazz-tools@0.14.6
|
||||
- jazz-betterauth-server-plugin@0.14.6
|
||||
- jazz-inspector@0.14.6
|
||||
- jazz-react@0.14.6
|
||||
- jazz-react-auth-betterauth@0.14.6
|
||||
- jazz-betterauth-client-plugin@0.14.6
|
||||
|
||||
## 0.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [91cbb2f]
|
||||
- Updated dependencies [20b3d88]
|
||||
- jazz-tools@0.14.5
|
||||
- jazz-betterauth-server-plugin@0.14.5
|
||||
- jazz-inspector@0.14.5
|
||||
- jazz-react@0.14.5
|
||||
- jazz-react-auth-betterauth@0.14.5
|
||||
- jazz-betterauth-client-plugin@0.14.5
|
||||
|
||||
## 0.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [011af55]
|
||||
- jazz-tools@0.14.4
|
||||
- jazz-betterauth-server-plugin@0.14.4
|
||||
- jazz-inspector@0.14.4
|
||||
- jazz-react@0.14.4
|
||||
- jazz-react-auth-betterauth@0.14.4
|
||||
- jazz-betterauth-client-plugin@0.14.4
|
||||
|
||||
## 0.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3d1027f]
|
||||
- Updated dependencies [c240eed]
|
||||
- jazz-tools@0.14.2
|
||||
- jazz-betterauth-server-plugin@0.14.2
|
||||
- jazz-inspector@0.14.2
|
||||
- jazz-react@0.14.2
|
||||
- jazz-react-auth-betterauth@0.14.2
|
||||
- jazz-betterauth-client-plugin@0.14.2
|
||||
|
||||
## 0.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [cdfc105]
|
||||
- jazz-tools@0.14.1
|
||||
- jazz-betterauth-server-plugin@0.14.1
|
||||
- jazz-inspector@0.14.1
|
||||
- jazz-react@0.14.1
|
||||
- jazz-react-auth-betterauth@0.14.1
|
||||
- jazz-betterauth-client-plugin@0.14.1
|
||||
|
||||
## 0.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5835ed1]
|
||||
- jazz-tools@0.14.0
|
||||
- jazz-betterauth-server-plugin@0.14.0
|
||||
- jazz-inspector@0.14.0
|
||||
- jazz-react@0.14.0
|
||||
- jazz-react-auth-betterauth@0.14.0
|
||||
- jazz-betterauth-client-plugin@0.14.0
|
||||
|
||||
## 0.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-betterauth-server-plugin@0.13.32
|
||||
- jazz-react@0.13.32
|
||||
- jazz-react-auth-betterauth@0.13.32
|
||||
- jazz-betterauth-client-plugin@0.13.32
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e5b170f]
|
||||
- jazz-tools@0.13.31
|
||||
- jazz-betterauth-server-plugin@0.13.31
|
||||
- jazz-inspector@0.13.31
|
||||
- jazz-react@0.13.31
|
||||
- jazz-react-auth-betterauth@0.13.31
|
||||
- jazz-betterauth-client-plugin@0.13.31
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-betterauth-server-plugin@0.13.30
|
||||
- jazz-inspector@0.13.30
|
||||
- jazz-react@0.13.30
|
||||
- jazz-react-auth-betterauth@0.13.30
|
||||
- jazz-tools@0.13.30
|
||||
- jazz-betterauth-client-plugin@0.13.30
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8e5ff13]
|
||||
- jazz-inspector@0.13.29
|
||||
- jazz-betterauth-server-plugin@0.0.1
|
||||
- jazz-react@0.13.29
|
||||
- jazz-react-auth-betterauth@0.0.1
|
||||
- jazz-tools@0.13.29
|
||||
- jazz-betterauth-client-plugin@0.0.1
|
||||
@@ -1,82 +0,0 @@
|
||||
# Better Auth Integration Example
|
||||
|
||||
This example demonstrates how to integrate [Better Auth](https://www.better-auth.com/) with Jazz.
|
||||
|
||||
## Getting started
|
||||
|
||||
To run this example, you may either:
|
||||
|
||||
- Clone the Jazz monorepo and run this example from within.
|
||||
- Create a new Jazz project using this example as a template, and run that new project.
|
||||
|
||||
### Setting environment variables
|
||||
|
||||
- `NEXT_PUBLIC_AUTH_BASE_URL`: A URL to a Better Auth server. If undefined, the example will self-host a Better Auth server.
|
||||
- `BETTER_AUTH_SECRET`: The encryption secret used by the self-hosted Better Auth server (required only if `NEXT_PUBLIC_AUTH_BASE_URL` is undefined)
|
||||
- `GITHUB_CLIENT_ID`: The client ID for the GitHub OAuth provider used by the self-hosted Better Auth server (required only if `NEXT_PUBLIC_AUTH_BASE_URL` is undefined)
|
||||
- `GITHUB_CLIENT_SECRET`: The client secret for the GitHub OAuth provider used by the self-hosted Better Auth server (required only if `NEXT_PUBLIC_AUTH_BASE_URL` is undefined)
|
||||
|
||||
### Using this example as a template
|
||||
|
||||
1. Create a new Jazz project, and use this example as a template.
|
||||
|
||||
```sh
|
||||
npx create-jazz-app@latest betterauth-app --example betterauth
|
||||
```
|
||||
|
||||
2. Navigate to the new project and install dependencies.
|
||||
|
||||
```sh
|
||||
cd betterauth-app
|
||||
pnpm install
|
||||
```
|
||||
|
||||
3. Create a .env file (don't forget to set your [BETTER_AUTH_SECRET](https://www.better-auth.com/docs/installation#set-environment-variables)!)
|
||||
|
||||
```sh
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
4. Start the development server
|
||||
|
||||
```sh
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
https://www.better-auth.com/docs/installation#set-environment-variables
|
||||
|
||||
### Using the monorepo
|
||||
|
||||
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||
|
||||
Clone the jazz repository.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/garden-co/jazz.git
|
||||
```
|
||||
|
||||
Install and build dependencies.
|
||||
|
||||
```bash
|
||||
pnpm i && npx turbo build
|
||||
```
|
||||
|
||||
Go to the example directory.
|
||||
|
||||
```bash
|
||||
cd jazz/examples/betterauth/
|
||||
```
|
||||
|
||||
Create a .env file (don't forget to set your [BETTER_AUTH_SECRET](https://www.better-auth.com/docs/installation#set-environment-variables)!)
|
||||
|
||||
```sh
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
Start the dev server.
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"iconLibrary": "lucide"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"name": "betterauth",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"format-and-lint": "biome check .",
|
||||
"format-and-lint:fix": "biome check . --write",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"email": "email dev --dir src/components/emails"
|
||||
},
|
||||
"dependencies": {
|
||||
"@icons-pack/react-simple-icons": "^12.8.0",
|
||||
"@radix-ui/react-label": "^2.1.6",
|
||||
"@radix-ui/react-slot": "^1.2.2",
|
||||
"better-auth": "^1.2.4",
|
||||
"better-sqlite3": "^11.9.1",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"jazz-react-auth-betterauth": "workspace:*",
|
||||
"jazz-betterauth-client-plugin": "workspace:*",
|
||||
"jazz-betterauth-server-plugin": "workspace:*",
|
||||
"jazz-tools": "workspace:*",
|
||||
"lucide-react": "^0.510.0",
|
||||
"next": "15.3.2",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"sonner": "^2.0.3",
|
||||
"tailwind-merge": "^3.3.0",
|
||||
"tw-animate-css": "^1.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@playwright/test": "^1.50.1",
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/better-sqlite3": "^7.6.12",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"react-email": "^4.0.11",
|
||||
"tailwindcss": "^4",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
import isCI from "is-ci";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: isCI,
|
||||
/* Retry on CI only */
|
||||
retries: isCI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: isCI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: "html",
|
||||
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: "http://localhost:3000/",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
permissions: ["clipboard-read", "clipboard-write"],
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: [
|
||||
{
|
||||
command: "pnpm dev",
|
||||
url: "http://localhost:3000/",
|
||||
reuseExistingServer: !isCI,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
const config = {
|
||||
plugins: ["@tailwindcss/postcss"],
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,15 +0,0 @@
|
||||
<svg
|
||||
viewBox="0 0 386 146"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path id="text"
|
||||
d="M176.725 33.865H188.275V22.7H176.725V33.865ZM164.9 129.4H172.875C182.72 129.4 188.275 123.9 188.275 114.22V43.6H176.725V109.545C176.725 115.65 173.975 118.51 167.925 118.51H164.9V129.4ZM245.298 53.28C241.613 45.47 233.363 41.95 222.748 41.95C208.998 41.95 200.748 48.44 197.888 58.615L208.613 61.915C210.648 55.315 216.368 52.565 222.638 52.565C231.933 52.565 235.673 56.415 236.058 64.61C226.433 65.93 216.643 67.195 209.768 69.23C200.583 72.145 195.743 77.865 195.743 86.83C195.743 96.51 202.673 104.65 215.818 104.65C225.443 104.65 232.318 101.35 237.213 94.365V103H247.388V66.425C247.388 61.475 247.168 57.185 245.298 53.28ZM217.853 95.245C210.483 95.245 207.128 91.34 207.128 86.72C207.128 82.045 210.593 79.515 215.323 77.92C220.328 76.435 226.983 75.5 235.948 74.18C235.893 76.93 235.673 80.725 234.738 83.475C233.418 89.25 227.643 95.245 217.853 95.245ZM251.22 103H301.545V92.715H269.535L303.195 45.47V43.6H254.3V53.885H284.935L251.22 101.185V103ZM304.815 103H355.14V92.715H323.13L356.79 45.47V43.6H307.895V53.885H338.53L304.815 101.185V103Z"
|
||||
/>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M136.179 44.8277C136.179 44.8277 136.179 44.8277 136.179 44.8276V21.168C117.931 28.5527 97.9854 32.6192 77.0897 32.6192C65.1466 32.6192 53.5138 31.2908 42.331 28.7737V51.4076C42.331 51.4076 42.331 51.4076 42.331 51.4076V81.1508C41.2955 80.4385 40.1568 79.8458 38.9405 79.3915C36.1732 78.358 33.128 78.0876 30.1902 78.6145C27.2524 79.1414 24.5539 80.4419 22.4358 82.3516C20.3178 84.2613 18.8754 86.6944 18.291 89.3433C17.7066 91.9921 18.0066 94.7377 19.1528 97.2329C20.2991 99.728 22.2403 101.861 24.7308 103.361C27.2214 104.862 30.1495 105.662 33.1448 105.662H33.1455C33.6061 105.662 33.8365 105.662 34.0314 105.659C44.5583 105.449 53.042 96.9656 53.2513 86.4386C53.2534 86.3306 53.2544 86.2116 53.2548 86.0486H53.2552V85.7149L53.2552 85.5521V82.0762L53.2552 53.1993C61.0533 54.2324 69.0092 54.7656 77.0897 54.7656C77.6696 54.7656 78.2489 54.7629 78.8276 54.7574V110.696C77.792 109.983 76.6533 109.391 75.437 108.936C72.6697 107.903 69.6246 107.632 66.6867 108.159C63.7489 108.686 61.0504 109.987 58.9323 111.896C56.8143 113.806 55.3719 116.239 54.7875 118.888C54.2032 121.537 54.5031 124.283 55.6494 126.778C56.7956 129.273 58.7368 131.405 61.2273 132.906C63.7179 134.406 66.646 135.207 69.6414 135.207C70.1024 135.207 70.3329 135.207 70.5279 135.203C81.0548 134.994 89.5385 126.51 89.7478 115.983C89.7517 115.788 89.7517 115.558 89.7517 115.097V111.621L89.7517 54.3266C101.962 53.4768 113.837 51.4075 125.255 48.2397V80.9017C124.219 80.1894 123.081 79.5966 121.864 79.1424C119.097 78.1089 116.052 77.8384 113.114 78.3653C110.176 78.8922 107.478 80.1927 105.36 82.1025C103.242 84.0122 101.799 86.4453 101.215 89.0941C100.631 91.743 100.931 94.4886 102.077 96.9837C103.223 99.4789 105.164 101.612 107.655 103.112C110.145 104.612 113.073 105.413 116.069 105.413C116.53 105.413 116.76 105.413 116.955 105.409C127.482 105.2 135.966 96.7164 136.175 86.1895C136.179 85.9945 136.179 85.764 136.179 85.3029V81.8271L136.179 44.8277Z"
|
||||
fill="#146AFF"
|
||||
/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,12 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 125 125"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M118.179 29.6597V6C99.931 13.3847 79.9854 17.4512 59.0897 17.4512C47.1466 17.4512 35.5138 16.1228 24.331 13.6057V36.2396V65.9828C23.2955 65.2705 22.1568 64.6778 20.9405 64.2235C18.1732 63.19 15.128 62.9196 12.1902 63.4465C9.25242 63.9734 6.55392 65.2739 4.43582 67.1836C2.31782 69.0933 0.875416 71.5264 0.291016 74.1753C-0.293384 76.8241 0.00661504 79.5697 1.15281 82.0649C2.29911 84.56 4.24032 86.693 6.73082 88.193C9.22142 89.694 12.1495 90.494 15.1448 90.494C15.6054 90.494 15.8365 90.494 16.0314 90.491C26.5583 90.281 35.042 81.7976 35.2513 71.2706C35.2534 71.1626 35.2544 71.0436 35.2548 70.8806L35.2552 70.5469V70.3841V66.9082V38.0313C43.0533 39.0644 51.0092 39.5976 59.0897 39.5976C59.6696 39.5976 60.2489 39.5949 60.8276 39.5894V95.528C59.792 94.815 58.6533 94.223 57.437 93.768C54.6697 92.735 51.6246 92.464 48.6867 92.991C45.7489 93.518 43.0504 94.819 40.9323 96.728C38.8143 98.638 37.3719 101.071 36.7875 103.72C36.2032 106.369 36.5031 109.115 37.6494 111.61C38.7956 114.105 40.7368 116.237 43.2273 117.738C45.7179 119.238 48.646 120.039 51.6414 120.039C52.1024 120.039 52.3329 120.039 52.5279 120.035C63.0548 119.826 71.5385 111.342 71.7478 100.815C71.7517 100.62 71.7517 100.39 71.7517 99.929V96.453V39.1586C83.962 38.3088 95.837 36.2395 107.255 33.0717V65.7337C106.219 65.0214 105.081 64.4286 103.864 63.9744C101.097 62.9409 98.052 62.6704 95.114 63.1973C92.176 63.7242 89.478 65.0247 87.36 66.9345C85.242 68.8442 83.799 71.2773 83.215 73.9261C82.631 76.575 82.931 79.3206 84.077 81.8157C85.223 84.3109 87.164 86.444 89.655 87.944C92.145 89.444 95.073 90.245 98.069 90.245C98.53 90.245 98.76 90.245 98.955 90.241C109.482 90.032 117.966 81.5484 118.175 71.0215C118.179 70.8265 118.179 70.596 118.179 70.1349V66.6591V29.6597Z"
|
||||
fill="#146AFF"
|
||||
/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.9 KiB |
@@ -1,22 +0,0 @@
|
||||
import { Navbar } from "@/components/navbar";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Jazz Example: Better Auth",
|
||||
description: "Jazz example application demonstrating Better Auth integration",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
<div className="container mx-auto pt-16 min-h-screen flex flex-col items-center justify-center">
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Account } from "jazz-tools";
|
||||
import { useAccount } from "jazz-tools/react";
|
||||
import {
|
||||
AppWindowMacIcon,
|
||||
FileTextIcon,
|
||||
GlobeIcon,
|
||||
WrenchIcon,
|
||||
} from "lucide-react";
|
||||
import Image from "next/image";
|
||||
|
||||
export default function Home() {
|
||||
const { me } = useAccount(Account, { resolve: { profile: {} } });
|
||||
|
||||
if (!me) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grow flex flex-col items-center justify-center">
|
||||
<main className="flex flex-col gap-8 row-start-2 grow justify-center">
|
||||
<Image
|
||||
src="/jazz-logo.svg"
|
||||
alt="Jazz logo"
|
||||
width={180}
|
||||
height={38}
|
||||
priority
|
||||
/>
|
||||
<p className="text-sm/6 text-center sm:text-left">
|
||||
Signed in as{" "}
|
||||
<span className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-mono font-semibold">
|
||||
{me.profile.name}
|
||||
</span>{" "}
|
||||
with id{" "}
|
||||
<span className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-mono font-semibold">
|
||||
{me.id}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div className="flex gap-4 items-center flex-row">
|
||||
<Button asChild size="lg">
|
||||
<a
|
||||
href="https://jazz.tools/docs"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image src="/jazz.svg" alt="" width={20} height={20} />
|
||||
Start building
|
||||
</a>
|
||||
</Button>
|
||||
|
||||
<Button asChild variant="secondary" size="lg">
|
||||
<a
|
||||
href="https://jazz.tools/docs"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<FileTextIcon className="size-4" />
|
||||
Read the docs
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer className="flex gap-4 py-8">
|
||||
<Button asChild variant="ghost">
|
||||
<a
|
||||
href="https://jazz.tools/api-reference"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<FileTextIcon className="size-4" />
|
||||
API reference
|
||||
</a>
|
||||
</Button>
|
||||
<Button asChild variant="ghost">
|
||||
<a
|
||||
href="https://jazz.tools/examples"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<AppWindowMacIcon className="size-4" />
|
||||
Examples
|
||||
</a>
|
||||
</Button>
|
||||
|
||||
<Button asChild variant="ghost">
|
||||
<a
|
||||
href="https://jazz.tools/status"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<GlobeIcon className="size-4" />
|
||||
Status
|
||||
</a>
|
||||
</Button>
|
||||
|
||||
<Button asChild variant="ghost">
|
||||
<a
|
||||
href="https://jazz.tools/showcase"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<WrenchIcon className="size-4" />
|
||||
Built with Jazz
|
||||
</a>
|
||||
</Button>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { UserSettings } from "@/components/user-settings";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Settings | Jazz Example: Better Auth",
|
||||
};
|
||||
|
||||
export default function SettingsPage() {
|
||||
return (
|
||||
<div className="max-w-screen-md w-full mx-auto px-4">
|
||||
<UserSettings />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { toNextJsHandler } from "better-auth/next-js";
|
||||
|
||||
export const { GET, POST } = (() => {
|
||||
if (!process.env.NEXT_PUBLIC_AUTH_BASE_URL) {
|
||||
return toNextJsHandler(auth.handler);
|
||||
} else {
|
||||
return { GET: undefined, POST: undefined };
|
||||
}
|
||||
})();
|
||||
@@ -1,10 +0,0 @@
|
||||
import { ForgotPasswordForm } from "@/components/forgot-password-form";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Forgot password | Jazz Example: Better Auth",
|
||||
};
|
||||
|
||||
export default function ForgotPasswordPage() {
|
||||
return <ForgotPasswordForm />;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function AuthLayout({ children }: Props) {
|
||||
return (
|
||||
<div className="bg-muted flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10">
|
||||
<div className="flex w-full max-w-sm flex-col gap-6">
|
||||
<Link
|
||||
href="/"
|
||||
className="flex items-center gap-2 self-center font-medium"
|
||||
>
|
||||
<Image src="/jazz.svg" alt="Jazz Logo" width={24} height={24} />
|
||||
Jazz BetterAuth Demo
|
||||
</Link>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { ResetPasswordForm } from "@/components/reset-password-form";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Reset password | Jazz Example: Better Auth",
|
||||
};
|
||||
|
||||
export default function ResetPasswordPage() {
|
||||
return <ResetPasswordForm />;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { SigninForm } from "@/components/signin-form";
|
||||
import type { Metadata } from "next";
|
||||
import { ssoProviders } from "../sso-providers";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Sign in | Jazz Example: Better Auth",
|
||||
};
|
||||
|
||||
export default function LoginPage() {
|
||||
return <SigninForm providers={ssoProviders} />;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { SignupForm } from "@/components/signup-form";
|
||||
import type { Metadata } from "next";
|
||||
import { ssoProviders } from "../sso-providers";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Sign up | Jazz Example: Better Auth",
|
||||
};
|
||||
|
||||
export default function LoginPage() {
|
||||
return <SignupForm providers={ssoProviders} />;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import type { SSOProviderType } from "jazz-react-auth-betterauth";
|
||||
|
||||
// Fill in the providers you want to use
|
||||
export const ssoProviders: SSOProviderType[] = ["github"];
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,123 +0,0 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
:root {
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--destructive-foreground: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
--chart-2: oklch(0.6 0.118 184.704);
|
||||
--chart-3: oklch(0.398 0.07 227.392);
|
||||
--chart-4: oklch(0.828 0.189 84.429);
|
||||
--chart-5: oklch(0.769 0.188 70.08);
|
||||
--radius: 0.625rem;
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.145 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.145 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.985 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.396 0.141 25.723);
|
||||
--destructive-foreground: oklch(0.637 0.237 25.331);
|
||||
--border: oklch(0.269 0 0);
|
||||
--input: oklch(0.269 0 0);
|
||||
--ring: oklch(0.439 0 0);
|
||||
--chart-1: oklch(0.488 0.243 264.376);
|
||||
--chart-2: oklch(0.696 0.17 162.48);
|
||||
--chart-3: oklch(0.769 0.188 70.08);
|
||||
--chart-4: oklch(0.627 0.265 303.9);
|
||||
--chart-5: oklch(0.645 0.246 16.439);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(0.269 0 0);
|
||||
--sidebar-ring: oklch(0.439 0 0);
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { JazzAndAuth } from "@/components/JazzAndAuth";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Jazz Example: Better Auth",
|
||||
description: "Jazz example application demonstrating Better Auth integration",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className="antialiased">
|
||||
<JazzAndAuth>
|
||||
{children}
|
||||
<Toaster richColors />
|
||||
</JazzAndAuth>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { AuthProvider } from "jazz-react-auth-betterauth";
|
||||
import { JazzReactProvider } from "jazz-tools/react";
|
||||
import { type ReactNode, lazy } from "react";
|
||||
|
||||
const JazzDevTools =
|
||||
process.env.NODE_ENV === "production"
|
||||
? () => null
|
||||
: lazy(() =>
|
||||
import("jazz-tools/inspector").then((res) => ({
|
||||
default: res.JazzInspector,
|
||||
})),
|
||||
);
|
||||
|
||||
export function JazzAndAuth({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<JazzReactProvider
|
||||
sync={{
|
||||
peer: "wss://cloud.jazz.tools/?key=betterauth-example@garden.co",
|
||||
}}
|
||||
>
|
||||
<AuthProvider
|
||||
options={{
|
||||
baseURL: process.env.NEXT_PUBLIC_AUTH_BASE_URL,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</AuthProvider>
|
||||
<JazzDevTools />
|
||||
</JazzReactProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
SiApple,
|
||||
SiDiscord,
|
||||
SiDropbox,
|
||||
SiFacebook,
|
||||
SiGithub,
|
||||
SiGitlab,
|
||||
SiGoogle,
|
||||
SiKick,
|
||||
SiReddit,
|
||||
SiRoblox,
|
||||
SiSpotify,
|
||||
SiTiktok,
|
||||
SiTwitch,
|
||||
SiVk,
|
||||
SiX,
|
||||
SiZoom,
|
||||
} from "@icons-pack/react-simple-icons";
|
||||
import { type SSOProviderType, useAuth } from "jazz-react-auth-betterauth";
|
||||
import { useRouter } from "next/navigation";
|
||||
import type { ReactNode } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
interface SocialProvider {
|
||||
name: string;
|
||||
icon?: ReactNode;
|
||||
}
|
||||
|
||||
const socialProviderMap: Record<SSOProviderType, SocialProvider> = {
|
||||
github: {
|
||||
name: "GitHub",
|
||||
icon: <SiGithub />,
|
||||
},
|
||||
google: {
|
||||
name: "Google",
|
||||
icon: <SiGoogle />,
|
||||
},
|
||||
apple: {
|
||||
name: "Apple",
|
||||
icon: <SiApple />,
|
||||
},
|
||||
discord: {
|
||||
name: "Discord",
|
||||
icon: <SiDiscord />,
|
||||
},
|
||||
facebook: {
|
||||
name: "Facebook",
|
||||
icon: <SiFacebook />,
|
||||
},
|
||||
microsoft: {
|
||||
name: "Microsoft",
|
||||
},
|
||||
twitter: {
|
||||
name: "X",
|
||||
icon: <SiX />,
|
||||
},
|
||||
dropbox: {
|
||||
name: "Dropbox",
|
||||
icon: <SiDropbox />,
|
||||
},
|
||||
linkedin: {
|
||||
name: "LinkedIn",
|
||||
},
|
||||
gitlab: {
|
||||
name: "GitLab",
|
||||
icon: <SiGitlab />,
|
||||
},
|
||||
kick: {
|
||||
name: "Kick",
|
||||
icon: <SiKick />,
|
||||
},
|
||||
tiktok: {
|
||||
name: "TikTok",
|
||||
icon: <SiTiktok />,
|
||||
},
|
||||
twitch: {
|
||||
name: "Twitch",
|
||||
icon: <SiTwitch />,
|
||||
},
|
||||
vk: {
|
||||
name: "VK",
|
||||
icon: <SiVk />,
|
||||
},
|
||||
zoom: {
|
||||
name: "Zoom",
|
||||
icon: <SiZoom />,
|
||||
},
|
||||
roblox: {
|
||||
name: "Roblox",
|
||||
icon: <SiRoblox />,
|
||||
},
|
||||
reddit: {
|
||||
name: "Reddit",
|
||||
icon: <SiReddit />,
|
||||
},
|
||||
spotify: {
|
||||
name: "Spotify",
|
||||
icon: <SiSpotify />,
|
||||
},
|
||||
};
|
||||
|
||||
interface Props {
|
||||
provider: SSOProviderType;
|
||||
}
|
||||
|
||||
export function SSOButton({ provider }: Props) {
|
||||
const auth = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
auth.authClient.signIn.social(
|
||||
{
|
||||
provider,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
router.push("/");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Error", {
|
||||
description: error.error.message,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
{socialProviderMap[provider].icon}
|
||||
Continue with {socialProviderMap[provider].name}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useAuth } from "jazz-react-auth-betterauth";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export function ForgotPasswordForm() {
|
||||
const router = useRouter();
|
||||
const [email, setEmail] = useState("");
|
||||
const auth = useAuth();
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
auth.authClient.forgetPassword(
|
||||
{ email, redirectTo: `${window.location.origin}/auth/reset-password` },
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success("Email sent");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Error", {
|
||||
description: error.error.message,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<Card>
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="text-xl">Recover password</CardTitle>
|
||||
<CardDescription>
|
||||
Enter your email to receive a link to reset your password
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button type="submit" className="w-full">
|
||||
Recover password
|
||||
</Button>
|
||||
</div>
|
||||
<div className="text-center text-sm">
|
||||
Back to{" "}
|
||||
<Link
|
||||
href="/auth/sign-in"
|
||||
className="underline underline-offset-4"
|
||||
>
|
||||
Sign in
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useAuth } from "jazz-react-auth-betterauth";
|
||||
import { Account } from "jazz-tools";
|
||||
import { useAccount, useIsAuthenticated } from "jazz-tools/react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export function Navbar() {
|
||||
const { authClient } = useAuth();
|
||||
const { logOut } = useAccount(Account, { resolve: { profile: {} } });
|
||||
|
||||
const isAuthenticated = useIsAuthenticated();
|
||||
|
||||
const signOut = useCallback(() => {
|
||||
authClient.signOut().catch(console.error).finally(logOut);
|
||||
}, [logOut, authClient]);
|
||||
|
||||
return (
|
||||
<header className="absolute p-4 top-0 left-0 w-full z-10 flex justify-between">
|
||||
<nav className="flex gap-4">
|
||||
<Link href="/">
|
||||
<Image
|
||||
src="/jazz-logo.svg"
|
||||
alt="Jazz logo"
|
||||
width={96}
|
||||
height={96}
|
||||
priority
|
||||
/>
|
||||
</Link>
|
||||
{isAuthenticated && (
|
||||
<Button asChild variant="link">
|
||||
<Link href="/settings">Settings</Link>
|
||||
</Button>
|
||||
)}
|
||||
</nav>
|
||||
<nav className="flex gap-4">
|
||||
{isAuthenticated ? (
|
||||
<Button onClick={signOut}>Sign out</Button>
|
||||
) : (
|
||||
<>
|
||||
<Button asChild variant="secondary">
|
||||
<Link href="/auth/sign-in">Sign in</Link>
|
||||
</Button>
|
||||
<Button asChild>
|
||||
<Link href="/auth/sign-up">Sign up</Link>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</nav>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useAuth } from "jazz-react-auth-betterauth";
|
||||
import Link from "next/link";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export function ResetPasswordForm() {
|
||||
const router = useRouter();
|
||||
const [password, setPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const auth = useAuth();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
const token = searchParams.get("token");
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
toast.error("Passwords do not match");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!token) {
|
||||
toast.error("Invalid token");
|
||||
return;
|
||||
}
|
||||
|
||||
auth.authClient.resetPassword(
|
||||
{ newPassword: password, token },
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success("Password successfully updated");
|
||||
router.push("/auth/sign-in");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Error", {
|
||||
description: error.error.message,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<Card>
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="text-xl">Reset password</CardTitle>
|
||||
<CardDescription>Enter your new password</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="password">New password</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="confirmPassword">Confirm password</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
required
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button type="submit" className="w-full">
|
||||
Set password
|
||||
</Button>
|
||||
</div>
|
||||
<div className="text-center text-sm">
|
||||
Back to{" "}
|
||||
<Link
|
||||
href="/auth/sign-in"
|
||||
className="underline underline-offset-4"
|
||||
>
|
||||
Sign in
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { type SSOProviderType, useAuth } from "jazz-react-auth-betterauth";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { SSOButton } from "./SSOButton";
|
||||
|
||||
interface Props {
|
||||
providers: SSOProviderType[];
|
||||
}
|
||||
|
||||
export function SigninForm({ providers }: Props) {
|
||||
const router = useRouter();
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
const auth = useAuth();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
await auth.authClient.signIn.email(
|
||||
{ email, password },
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await auth.logIn();
|
||||
router.push("/");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Error", {
|
||||
description: error.error.message,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<Card>
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="text-xl">Welcome back</CardTitle>
|
||||
<CardDescription>
|
||||
Sign in with one of the following providers
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="grid gap-6">
|
||||
{providers.length > 0 && (
|
||||
<>
|
||||
<div className="flex flex-col gap-4">
|
||||
{providers?.map((provider) => (
|
||||
<SSOButton key={provider} provider={provider} />
|
||||
))}
|
||||
</div>
|
||||
<div className="after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t">
|
||||
<span className="bg-card text-muted-foreground relative z-10 px-2">
|
||||
Or continue with
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<Link
|
||||
href="/auth/forgot-password"
|
||||
className="ml-auto inline-block text-sm underline-offset-4 hover:underline"
|
||||
>
|
||||
Forgot your password?
|
||||
</Link>
|
||||
</div>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" className="w-full">
|
||||
Sign in
|
||||
</Button>
|
||||
</div>
|
||||
<div className="text-center text-sm">
|
||||
Don't have an account?{" "}
|
||||
<Link
|
||||
href="/auth/sign-up"
|
||||
className="underline underline-offset-4"
|
||||
>
|
||||
Sign up
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { type SSOProviderType, useAuth } from "jazz-react-auth-betterauth";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { SSOButton } from "./SSOButton";
|
||||
|
||||
interface Props {
|
||||
providers: SSOProviderType[];
|
||||
}
|
||||
|
||||
export function SignupForm({ providers }: Props) {
|
||||
const router = useRouter();
|
||||
const auth = useAuth();
|
||||
const [name, setName] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
toast.error("Error", {
|
||||
description: "Passwords do not match",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await auth.authClient.signUp.email(
|
||||
{
|
||||
email,
|
||||
password,
|
||||
name,
|
||||
},
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await auth.signIn();
|
||||
router.push("/");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Sign up error", {
|
||||
description: error.error.message,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<Card>
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="text-xl">Welcome</CardTitle>
|
||||
<CardDescription>
|
||||
Sign up with one of the following providers
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="grid gap-6">
|
||||
{providers.length > 0 && (
|
||||
<>
|
||||
<div className="flex flex-col gap-4">
|
||||
{providers?.map((provider) => (
|
||||
<SSOButton key={provider} provider={provider} />
|
||||
))}
|
||||
</div>
|
||||
<div className="after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t">
|
||||
<span className="bg-card text-muted-foreground relative z-10 px-2">
|
||||
Or continue with
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="name">Name</Label>
|
||||
<Input
|
||||
id="name"
|
||||
type="text"
|
||||
placeholder="John Doe"
|
||||
required
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="********"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="confirmPassword">Confirm password</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
required
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" className="w-full">
|
||||
Sign up
|
||||
</Button>
|
||||
</div>
|
||||
<div className="text-center text-sm">
|
||||
Already have an account?{" "}
|
||||
<Link
|
||||
href="/auth/sign-in"
|
||||
className="underline underline-offset-4"
|
||||
>
|
||||
Sign in
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||
outline:
|
||||
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
||||
ghost:
|
||||
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
||||
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
||||
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
||||
icon: "size-9",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
function Button({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"button"> &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean;
|
||||
}) {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
data-slot="button"
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Button, buttonVariants };
|
||||
@@ -1,92 +0,0 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card"
|
||||
className={cn(
|
||||
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-title"
|
||||
className={cn("leading-none font-semibold", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-muted-foreground text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-action"
|
||||
className={cn(
|
||||
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-6", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
data-slot="input"
|
||||
className={cn(
|
||||
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
||||
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Input };
|
||||
@@ -1,22 +0,0 @@
|
||||
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Label({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
||||
return (
|
||||
<LabelPrimitive.Root
|
||||
data-slot="label"
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Label };
|
||||
@@ -1,22 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Toaster as Sonner, type ToasterProps } from "sonner";
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
return (
|
||||
<Sonner
|
||||
theme="light"
|
||||
className="toaster group"
|
||||
style={
|
||||
{
|
||||
"--normal-bg": "var(--popover)",
|
||||
"--normal-text": "var(--popover-foreground)",
|
||||
"--normal-border": "var(--border)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export { Toaster };
|
||||
@@ -1,60 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useAuth } from "jazz-react-auth-betterauth";
|
||||
import { useAccount, useIsAuthenticated } from "jazz-tools/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export function UserSettings() {
|
||||
const router = useRouter();
|
||||
const { authClient } = useAuth();
|
||||
const { logOut } = useAccount();
|
||||
const isAuthenticated = useIsAuthenticated();
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return (
|
||||
<div className="flex flex-col gap-8">
|
||||
<h1 className="text-center text-2xl">Forbidden</h1>
|
||||
<p className="text-center text-sm text-muted-foreground">
|
||||
Please{" "}
|
||||
<Link href="/auth/sign-in" className="underline text-primary">
|
||||
sign in
|
||||
</Link>{" "}
|
||||
to access this page.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-8">
|
||||
<h1 className="text-4xl font-semibold">Settings</h1>
|
||||
|
||||
<Button
|
||||
variant="destructive"
|
||||
className="relative"
|
||||
type="button"
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
authClient.deleteUser(undefined, {
|
||||
onSuccess: () => {
|
||||
logOut();
|
||||
router.push("/");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Error", {
|
||||
description: error.error.message,
|
||||
});
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
Delete account
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import { betterAuth } from "better-auth";
|
||||
import { getMigrations } from "better-auth/db";
|
||||
import Database from "better-sqlite3";
|
||||
import { jazzPlugin } from "jazz-betterauth-server-plugin";
|
||||
import { socialProviders } from "./socialProviders";
|
||||
|
||||
export const auth = await (async () => {
|
||||
// Configure Better Auth server
|
||||
const auth = betterAuth({
|
||||
appName: "Jazz Example: Better Auth",
|
||||
database: new Database("sqlite.db"),
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
async sendResetPassword({ url }) {
|
||||
// Here we can send an email to the user with the reset password link
|
||||
console.log("****** RESET PASSWORD ******");
|
||||
console.log("navigate to", url, "to reset your password");
|
||||
console.log("******");
|
||||
},
|
||||
},
|
||||
emailVerification: {
|
||||
async sendVerificationEmail(data) {
|
||||
console.error("Not implemented");
|
||||
},
|
||||
},
|
||||
socialProviders,
|
||||
user: {
|
||||
deleteUser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
plugins: [jazzPlugin()],
|
||||
databaseHooks: {
|
||||
user: {
|
||||
create: {
|
||||
async after(user) {
|
||||
// Here we can send a welcome email to the user
|
||||
console.error("Not implemented");
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Run database migrations
|
||||
const migrations = await getMigrations(auth.options);
|
||||
await migrations.runMigrations();
|
||||
|
||||
return auth;
|
||||
})();
|
||||
@@ -1,186 +0,0 @@
|
||||
const apple =
|
||||
process.env.APPLE_CLIENT_ID &&
|
||||
process.env.APPLE_CLIENT_SECRET &&
|
||||
process.env.APPLE_APP_BUNDLE_IDENTIFIER
|
||||
? {
|
||||
apple: {
|
||||
clientId: process.env.APPLE_CLIENT_ID as string,
|
||||
clientSecret: process.env.APPLE_CLIENT_SECRET as string,
|
||||
// For native iOS
|
||||
appBundleIdentifier: process.env
|
||||
.APPLE_APP_BUNDLE_IDENTIFIER as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const discord =
|
||||
process.env.DISCORD_CLIENT_ID && process.env.DISCORD_CLIENT_SECRET
|
||||
? {
|
||||
discord: {
|
||||
clientId: process.env.DISCORD_CLIENT_ID as string,
|
||||
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const facebook =
|
||||
process.env.FACEBOOK_CLIENT_ID && process.env.FACEBOOK_CLIENT_SECRET
|
||||
? {
|
||||
facebook: {
|
||||
clientId: process.env.FACEBOOK_CLIENT_ID as string,
|
||||
clientSecret: process.env.FACEBOOK_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const github =
|
||||
process.env.GITHUB_CLIENT_ID && process.env.GITHUB_CLIENT_SECRET
|
||||
? {
|
||||
github: {
|
||||
clientId: process.env.GITHUB_CLIENT_ID as string,
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const google =
|
||||
process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET
|
||||
? {
|
||||
google: {
|
||||
clientId: process.env.GOOGLE_CLIENT_ID as string,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const kick =
|
||||
process.env.KICK_CLIENT_ID && process.env.KICK_CLIENT_SECRET
|
||||
? {
|
||||
kick: {
|
||||
clientId: process.env.KICK_CLIENT_ID as string,
|
||||
clientSecret: process.env.KICK_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const microsoft =
|
||||
process.env.MICROSOFT_CLIENT_ID && process.env.MICROSOFT_CLIENT_SECRET
|
||||
? {
|
||||
microsoft: {
|
||||
clientId: process.env.MICROSOFT_CLIENT_ID as string,
|
||||
clientSecret: process.env.MICROSOFT_CLIENT_SECRET as string,
|
||||
tenantId: "common",
|
||||
requireSelectAccount: true,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const tiktok =
|
||||
process.env.TIKTOK_CLIENT_ID &&
|
||||
process.env.TIKTOK_CLIENT_SECRET &&
|
||||
process.env.TIKTOK_CLIENT_KEY
|
||||
? {
|
||||
tiktok: {
|
||||
clientId: process.env.TIKTOK_CLIENT_ID,
|
||||
clientSecret: process.env.TIKTOK_CLIENT_SECRET,
|
||||
clientKey: process.env.TIKTOK_CLIENT_KEY,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const twitch =
|
||||
process.env.TWITCH_CLIENT_ID && process.env.TWITCH_CLIENT_SECRET
|
||||
? {
|
||||
twitch: {
|
||||
clientId: process.env.TWITCH_CLIENT_ID as string,
|
||||
clientSecret: process.env.TWITCH_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const twitter =
|
||||
process.env.TWITTER_CLIENT_ID && process.env.TWITTER_CLIENT_SECRET
|
||||
? {
|
||||
twitter: {
|
||||
clientId: process.env.TWITTER_CLIENT_ID,
|
||||
clientSecret: process.env.TWITTER_CLIENT_SECRET,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const dropbox =
|
||||
process.env.DROPBOX_CLIENT_ID && process.env.DROPBOX_CLIENT_SECRET
|
||||
? {
|
||||
dropbox: {
|
||||
clientId: process.env.DROPBOX_CLIENT_ID as string,
|
||||
clientSecret: process.env.DROPBOX_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const linkedin =
|
||||
process.env.LINKEDIN_CLIENT_ID && process.env.LINKEDIN_CLIENT_SECRET
|
||||
? {
|
||||
linkedin: {
|
||||
clientId: process.env.LINKEDIN_CLIENT_ID as string,
|
||||
clientSecret: process.env.LINKEDIN_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const gitlab =
|
||||
process.env.GITLAB_CLIENT_ID &&
|
||||
process.env.GITLAB_CLIENT_SECRET &&
|
||||
process.env.GITLAB_ISSUER
|
||||
? {
|
||||
gitlab: {
|
||||
clientId: process.env.GITLAB_CLIENT_ID as string,
|
||||
clientSecret: process.env.GITLAB_CLIENT_SECRET as string,
|
||||
issuer: process.env.GITLAB_ISSUER as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const reddit =
|
||||
process.env.REDDIT_CLIENT_ID && process.env.REDDIT_CLIENT_SECRET
|
||||
? {
|
||||
reddit: {
|
||||
clientId: process.env.REDDIT_CLIENT_ID as string,
|
||||
clientSecret: process.env.REDDIT_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const roblox =
|
||||
process.env.ROBLOX_CLIENT_ID && process.env.ROBLOX_CLIENT_SECRET
|
||||
? {
|
||||
roblox: {
|
||||
clientId: process.env.ROBLOX_CLIENT_ID,
|
||||
clientSecret: process.env.ROBLOX_CLIENT_SECRET,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const spotify =
|
||||
process.env.SPOTIFY_CLIENT_ID && process.env.SPOTIFY_CLIENT_SECRET
|
||||
? {
|
||||
spotify: {
|
||||
clientId: process.env.SPOTIFY_CLIENT_ID as string,
|
||||
clientSecret: process.env.SPOTIFY_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const vk =
|
||||
process.env.VK_CLIENT_ID && process.env.VK_CLIENT_SECRET
|
||||
? {
|
||||
vk: {
|
||||
clientId: process.env.VK_CLIENT_ID as string,
|
||||
clientSecret: process.env.VK_CLIENT_SECRET as string,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
|
||||
export const socialProviders = {
|
||||
...(apple && { ...apple }),
|
||||
...(discord && { ...discord }),
|
||||
...(facebook && { ...facebook }),
|
||||
...(github && { ...github }),
|
||||
...(google && { ...google }),
|
||||
...(kick && { ...kick }),
|
||||
...(microsoft && { ...microsoft }),
|
||||
...(tiktok && { ...tiktok }),
|
||||
...(twitch && { ...twitch }),
|
||||
...(twitter && { ...twitter }),
|
||||
...(dropbox && { ...dropbox }),
|
||||
...(linkedin && { ...linkedin }),
|
||||
...(gitlab && { ...gitlab }),
|
||||
...(reddit && { ...reddit }),
|
||||
...(roblox && { ...roblox }),
|
||||
...(spotify && { ...spotify }),
|
||||
...(vk && { ...vk }),
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { test } from "@playwright/test";
|
||||
import { HomePage } from "./pages/HomePage";
|
||||
|
||||
test("should sign up, sign in, and logout", async ({ page }) => {
|
||||
const username = randomBytes(4).toString("hex");
|
||||
const email = `${username}@example.com`;
|
||||
const password = randomBytes(8).toString("hex");
|
||||
|
||||
// Sign up
|
||||
await page.goto("/");
|
||||
const homePage = new HomePage(page);
|
||||
await homePage.expectLoggedOut();
|
||||
await homePage.signUpLink.click();
|
||||
await homePage.signUpEmail(username, email, password);
|
||||
await homePage.expectLoggedIn(username);
|
||||
|
||||
// Log out & sign in
|
||||
await homePage.logout();
|
||||
await homePage.expectLoggedOut();
|
||||
await homePage.signInLink.click();
|
||||
await homePage.signInEmail(email, password);
|
||||
await homePage.expectLoggedIn(username);
|
||||
|
||||
// Logout
|
||||
await homePage.logout();
|
||||
await homePage.expectLoggedOut();
|
||||
});
|
||||
@@ -1,76 +0,0 @@
|
||||
import { type Page, expect } from "@playwright/test";
|
||||
|
||||
export class HomePage {
|
||||
constructor(public page: Page) {}
|
||||
|
||||
usernameInput = this.page.getByRole("textbox", {
|
||||
name: "Name",
|
||||
exact: true,
|
||||
});
|
||||
emailInput = this.page.getByRole("textbox", {
|
||||
name: "Email",
|
||||
exact: true,
|
||||
});
|
||||
passwordInput = this.page.getByRole("textbox", {
|
||||
name: "Password",
|
||||
exact: true,
|
||||
});
|
||||
confirmPasswordInput = this.page.getByRole("textbox", {
|
||||
name: "Confirm password",
|
||||
exact: true,
|
||||
});
|
||||
signUpButton = this.page.getByRole("button", {
|
||||
name: "Sign up",
|
||||
exact: true,
|
||||
});
|
||||
signInButton = this.page.getByRole("button", {
|
||||
name: "Sign in",
|
||||
exact: true,
|
||||
});
|
||||
signUpLink = this.page.getByRole("link", {
|
||||
name: "Sign up",
|
||||
exact: true,
|
||||
});
|
||||
signInLink = this.page.getByRole("link", {
|
||||
name: "Sign in",
|
||||
exact: true,
|
||||
});
|
||||
logoutButton = this.page.getByRole("button", {
|
||||
name: "Sign out",
|
||||
exact: true,
|
||||
});
|
||||
|
||||
async signUpEmail(name: string, email: string, password: string) {
|
||||
await this.usernameInput.fill(name);
|
||||
await this.emailInput.fill(email);
|
||||
await this.passwordInput.fill(password);
|
||||
await this.confirmPasswordInput.fill(password);
|
||||
await this.signUpButton.click();
|
||||
}
|
||||
|
||||
async signInEmail(email: string, password: string) {
|
||||
await this.emailInput.fill(email);
|
||||
await this.passwordInput.fill(password);
|
||||
await this.signInButton.click();
|
||||
}
|
||||
|
||||
async logout() {
|
||||
await this.logoutButton.click();
|
||||
}
|
||||
|
||||
async expectLoggedIn(name?: string) {
|
||||
await expect(this.logoutButton).toBeVisible();
|
||||
await expect(this.signInLink).not.toBeVisible();
|
||||
await expect(this.signUpLink).not.toBeVisible();
|
||||
if (name) {
|
||||
await expect(this.page.getByText(`Signed in as ${name}`)).toBeVisible();
|
||||
}
|
||||
}
|
||||
|
||||
async expectLoggedOut() {
|
||||
await expect(this.logoutButton).not.toBeVisible();
|
||||
await expect(this.signInLink).toBeVisible();
|
||||
await expect(this.signUpLink).toBeVisible();
|
||||
await expect(this.page.getByText(`Anonymous user`)).toBeVisible();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user