diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4de9931..8c9c47c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -6,6 +6,9 @@ jobs: e2e: if: github.event.deployment_status.state == 'success' runs-on: ubuntu-latest + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} steps: - name: 🏗 Setup Repository @@ -18,6 +21,6 @@ jobs: run: bunx playwright install --with-deps - name: ✅ e2e - run: bun run e2e + run: bun turbo e2e env: BASE_URL: ${{ github.event.deployment_status.environment_url }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a33ed9c..951dd87 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -3,8 +3,11 @@ name: pull_request on: [pull_request] jobs: - validate: + check: runs-on: ubuntu-latest + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} steps: - name: 🏗 Setup Repository @@ -13,20 +16,5 @@ jobs: - name: 📦 Install uses: ./.github/actions/install - - name: 🚨 Lint - run: bun run lint - - - name: 🎨 Format - run: bun run format - - - name: 🏷️ Check Types - run: bun run typecheck - - - name: ✅ Test - run: bun run coverage - - - name: 🧱 Build - run: bun run build - - - name: 🧱 Stories Build - run: bun run sb:build + - name: 🚨 Check + run: bun check diff --git a/.gitignore b/.gitignore index 1191814..78dfc96 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ storybook-static # env .env* + +# turbo +.turbo diff --git a/.vscode/settings.json b/.vscode/settings.json index 41860e2..07d8648 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,7 @@ "tailwindcss", "tanstack", "tiged", + "turborepo", "typecheck", "vite", "vitest", diff --git a/README.md b/README.md index 2ed822b..cc21853 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ - 🩺 [eslint][eslint] for static analysis. - 🎨 [prettier][prettier] for formatting. - 🩺 [lefthook][lefthook] for fast Git hooks management. +- 👷 [Turborepo](https://turbo.build/repo/docs) for caching and task parallelization. - 👷 [GitHub Actions][GitHub Actions] for easy workflow automation. ## 🛠️ Usage @@ -45,7 +46,7 @@ bun install Or if you already have `bun` installed you upgrade, by running the following command: ``` - bun upgrade --stable +bun upgrade --stable ``` And to download new browsers for Playwright, run the following command: @@ -54,31 +55,40 @@ And to download new browsers for Playwright, run the following command: bunx playwright install ``` +And install Turborepo, run the following command: + +``` +bun install --global turbo +``` + Then to run the development server, run the following command: ``` -bun dev +turbo dev ``` Your application will be available at http://localhost:5173/ ❤️ ## 🧞 Available Tasks -| Command | Action | -| :------------------- | :------------------------------------------------------- | -| `bun install` | Installs dependencies | -| `bun run dev` | Starts local dev server at http://localhost:5173/ | -| `bun run build` | Build your production site to `./dist/` | -| `bun run preview` | Preview your build locally, before deploying | -| `bun run test` | Unit tests your code with vitest | -| `bun run e2e` | E2E tests your code with playwright | -| `bun run lint` | Lints everything with eslint | -| `bun run lint:fix` | Fixes lint errors with eslint | -| `bun run format` | Checks formatting with prettier | -| `bun run format:fix` | Fixes formatting errors with prettier | -| `bun run typecheck` | Checks types with TypeScript | -| `bun run sb` | Starts storybook at http://localhost:6006 | -| `bun run sb:build` | Build your production storybook to `./storybook-static/` | +| Command | Action | +| :----------------- | :------------------------------------------------------- | +| `bun install` | Installs dependencies | +| `turbo dev` | Starts local dev server at http://localhost:5173/ | +| `turbo build` | Build your production site to `./dist/` | +| `turbo preview` | Preview your build locally, before deploying | +| `turbo test` | Unit tests your code with vitest | +| `turbo e2e` | E2E tests your code with playwright | +| `turbo lint` | Lints everything with eslint | +| `turbo lint:fix` | Fixes lint errors with eslint | +| `turbo format` | Checks formatting with prettier | +| `turbo format:fix` | Fixes formatting errors with prettier | +| `turbo typecheck` | Checks types with TypeScript | +| `turbo sb` | Starts storybook at http://localhost:6006 | +| `turbo sb:build` | Build your production storybook to `./storybook-static/` | +| `turbo check` | Checks everything | + +_You can also run all tasks with `bun run`, i.e `bun run dev`_ ## 💡 Recommendations diff --git a/bun.lockb b/bun.lockb index adcf385..2a40664 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 8921df6..54e7062 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "scripts": { "build": "bunx --bun vite build", + "check": "turbo format lint typecheck coverage build sb:build", "coverage": "vitest run --coverage", "dev": "vite", "e2e": "playwright test", @@ -74,6 +75,7 @@ "prettier": "3.3.3", "storybook": "8.2.9", "tailwindcss": "3.4.10", + "turbo": "2.0.14", "typescript": "5.4.5", "vite": "5.4.2", "vite-tsconfig-paths": "5.0.1", diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..70e25ff --- /dev/null +++ b/turbo.json @@ -0,0 +1,51 @@ +{ + "$schema": "https://turbo.build/schema.v2.json", + "tasks": { + "build": { + "outputs": ["dist/**"] + }, + "typecheck": { + "dependsOn": ["^typecheck"] + }, + "format": { + "dependsOn": ["^format"] + }, + "format:fix": { + "dependsOn": ["^format:fix"] + }, + "lint": { + "dependsOn": ["^lint"] + }, + "lint:fix": { + "dependsOn": ["^lint:fix"] + }, + "test": { + "persistent": true, + "cache": false + }, + "coverage": { + "outputs": ["coverage/**"], + "dependsOn": ["^coverage"] + }, + "preview": { + "persistent": true, + "cache": false + }, + "dev": { + "persistent": true, + "cache": false + }, + "sb": { + "persistent": true, + "cache": false + }, + "sb:build": { + "outputs": ["storybook-static/**"] + }, + "e2e": { + "env": ["BASE_URL"], + "passThroughEnv": ["BASE_URL"], + "outputs": ["playwright-report/**", "test-results/**"] + } + } +}