Skip to content

Commit

Permalink
feat: migrate to Nextjs, MUI and viem/wagmi v2
Browse files Browse the repository at this point in the history
  • Loading branch information
0xArdy authored May 1, 2024
2 parents 503ae55 + f9bb01d commit 95f3f82
Show file tree
Hide file tree
Showing 57 changed files with 11,669 additions and 7,650 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VITE_RPC_URL= # Example: https://localhost:8545
VITE_PROJECT_ID= # ProjectId from walletConnect
VITE_ALCHEMY_KEY= # API key from Alchemy
NEXT_PUBLIC_RPC_URL= # Example: https://localhost:8545
NEXT_PUBLIC_PROJECT_ID= # ProjectID from WalletConnect
NEXT_PUBLIC_ALCHEMY_KEY= # API key from Alchemy
33 changes: 17 additions & 16 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended",
'prettier',
'eslint:recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'plugin:@next/next/recommended',
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
settings: {
react: {
version: 'detect',
},
},
};
67 changes: 28 additions & 39 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test
name: Build and Format

on:
pull_request:
Expand All @@ -10,32 +10,24 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Install Node
uses: actions/setup-node@v3
with:
node-version: "18.7"
registry-url: "https://registry.npmjs.org"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
node-version: '21.4'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'

- name: Install project dependencies
run: yarn --prefer-offline
id: install
run: pnpm install --frozen-lockfile --prefer-frozen-lockfile

- name: Build project dependencies
run: yarn run build
id: build
run: pnpm run build
env:
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }}

check:
name: Check for crypto
Expand All @@ -58,32 +50,29 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.7"
registry-url: "https://registry.npmjs.org"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: pnpm/action-setup@v2
with:
version: 8.15

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: actions/setup-node@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
node-version: '21.4'
cache: 'pnpm'

- name: Install project dependencies
run: yarn --prefer-offline
id: install
- name: Install Dependencies
run: pnpm install

- name: Build the project
run: pnpm run build

- name: Run Prettier
run: yarn prettier
run: pnpm prettier

- name: Run Linter
run: yarn lint
run: pnpm lint

- name: Run Tests
run: yarn test
- name: Cypress run
uses: cypress-io/github-action@v5
with:
start: pnpm start, pnpm test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
.next
next-env.d.ts
dist
dist-ssr
*.local
Expand All @@ -24,4 +26,5 @@ dist-ssr
*.sw?

.eslintcache
.env
.env
tsconfig.tsbuildinfo
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,32 @@
3. Install the project dependencies by running:

```bash
yarn install
pnpm install
```

## Available Scripts

Available scripts that can be run using `yarn`:
Available scripts that can be run using `pnpm`:

| Script | Description |
| -------------- | ------------------------------------------------------------ |
| `dev` | Start the development server using Vite. |
| `dev` | Start the development server using Next. |
| `build` | Build the project for production. |
| `preview` | Preview the production build using Vite. |
| `preview` | Preview the production build using Next. |
| `lint` | Run ESLint on the source code to check for coding standards. |
| `lint:fix` | Run ESLint and automatically fix code formatting issues. |
| `prettier` | Check code formatting using Prettier. |
| `prettier:fix` | Format code using Prettier and automatically fix issues. |
| `format` | Run Prettier and ESLint to format and fix code issues. |
| `format:check` | Check code formatting and linting without making changes. |
| `test` | Run unit tests using Vitest. |
| `test:watch` | Run Vitest in watch mode. |
| `test` | Run tests using Cypress |
| `test:watch` | Run Cypress in watch mode. |

## Technologies Used

This boilerplate leverages the latest technologies, including:

- [Vite](https://vitejs.dev/)
- [Vitest](https://vitest.dev/)
- [NextJS](https://nextjs.org/)
- [Wagmi](https://wagmi.sh/)
- [Viem](https://viem.sh/)
- [Rainbowkit](https://www.rainbowkit.com/)
7 changes: 7 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
},
});
5 changes: 5 additions & 0 deletions cypress/cypress.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace Cypress {
interface Chainable {
getByTestId(testId: string): Chainable<JQuery<HTMLElement>>;
}
}
6 changes: 6 additions & 0 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('Renders every component', () => {
it('Renders App component', () => {
cy.visit('/');
cy.getByTestId('boilerplate-title').should('exist');
});
});
4 changes: 4 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference types="cypress" />
Cypress.Commands.add('getByTestId', (testId) => {
return cy.get(`[data-testid="${testId}"]`);
});
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './commands';
9 changes: 9 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"types": ["cypress"],
},
"include": ["**/*.ts"]
}

13 changes: 0 additions & 13 deletions index.html

This file was deleted.

4 changes: 4 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
52 changes: 32 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,62 @@
{
"name": "web3-react-boilerplate-private",
"name": "web3-react-boilerplate",
"private": true,
"version": "0.0.0",
"type": "module",
"license": "MIT",
"author": "Wonderland",
"engines": {
"node": ">=18.17.0"
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"dev": "next dev",
"build": "next build",
"start": "next start -p 3000",
"preview": "next start",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
"lint:fix": "yarn run lint -- --fix",
"lint:fix": "pnpm run lint -- --fix",
"prettier": "prettier src --check",
"prettier:fix": "yarn run prettier -- --write",
"format": "yarn run prettier:fix && yarn run lint:fix",
"format:check": "yarn run prettier && yarn run lint",
"prettier:fix": "pnpm run prettier -- --write",
"format": "pnpm run prettier:fix && yarn run lint:fix",
"format:check": "pnpm run prettier && yarn run lint",
"prepare": "husky install && wonderland-crypto-husky-checks install",
"test": "vitest run --dir src/tests/",
"test:watch": "vitest --dir src/tests/"
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"test": "pnpm cypress:run"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": "eslint --cache --fix",
"src/**/*.{js,jsx,ts,tsx,css,scss,md,html}": "prettier --write --ignore-unknown"
},
"dependencies": {
"@rainbow-me/rainbowkit": "1.0.9",
"@emotion/cache": "11.11.0",
"@emotion/react": "11.11.3",
"@emotion/server": "11.11.0",
"@emotion/styled": "11.11.0",
"@mui/icons-material": "5.15.6",
"@mui/material": "5.15.14",
"@mui/material-nextjs": "5.15.11",
"@next/eslint-plugin-next": "14.1.3",
"@rainbow-me/rainbowkit": "2.0.2",
"@tanstack/react-query": "5.28.0",
"next": "14.1.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-router-dom": "6.15.0",
"viem": "1.19.15",
"wagmi": "1.4.12"
"viem": "2.8.6",
"wagmi": "2.5.7"
},
"devDependencies": {
"@defi-wonderland/crypto-husky-checks": "1.3.0",
"@testing-library/jest-dom": "6.1.2",
"@testing-library/react": "14.0.0",
"@testing-library/react": "14.2.1",
"@testing-library/user-event": "14.4.3",
"@types/lodash.merge": "4.6.7",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",
"@typescript-eslint/eslint-plugin": "6.0.0",
"@typescript-eslint/parser": "6.0.0",
"@vitejs/plugin-react": "4.0.3",
"cypress": "13.7.0",
"eslint": "8.45.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
Expand All @@ -51,13 +66,10 @@
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react-refresh": "0.4.3",
"husky": "8.0.3",
"jsdom": "22.1.0",
"jsdom": "24.0.0",
"lodash.merge": "4.6.2",
"prettier": "3.0.3",
"styled-components": "6.0.7",
"typescript": "5.0.2",
"vite": "4.4.5",
"vite-tsconfig-paths": "4.2.0",
"vitest": "0.34.3"
"typescript": "5.4.2"
}
}
Loading

0 comments on commit 95f3f82

Please sign in to comment.